internal/check¶
import "github.com/nuqs-org/nuqs/internal/check"
Package check defines what a check is. This is the main extension point of Nuqs.
A check looks at one service on one host and says whether it found a problem. To add a check you write a type with two methods, Info and Run, and add it to the list in package checks. That's it.
Functions¶
Applies¶
Applies reports whether a check with this info should run on the service.
func Applies(info Info, svc model.Service) bool
Defined in internal/check/check.go:69
Validate¶
Validate makes sure a list of checks is usable: every ID is well formed and unique, and every check has a title and a fix. The engine calls this before a scan so a broken check fails loudly instead of silently.
func Validate(checks []Check) error
Defined in internal/check/check.go:84
Types¶
Check¶
Check is the interface every check implements.
Run returns nil, nil when the service is fine. It returns an error only when it couldn't do its job (connection refused, timeout and so on), never to say "vulnerable". Run must respect ctx, the engine uses it for timeouts.
type Check interface {
Info() Info
Run(ctx context.Context, t Target) (*Result, error)
}
Defined in internal/check/check.go:63
Info¶
Info describes a check. The engine uses it to decide where the check runs and to fill in the finding, so Run only has to return evidence.
type Info struct {
ID string // short and unique, like "telnet-open"
Title string // one line shown to users
Severity model.Severity // how bad it is when found
Fix string // what the user should do about it
// Where the check applies. A service matches if its port is in Ports OR
// its Nmap service name is in Services. Leave both empty to match every service.
Ports []int
Services []string
}
Defined in internal/check/check.go:21
Result¶
Result is what a check returns when it finds something.
type Result struct {
Evidence string // what we saw, in plain words, for example "server sent 230 after anonymous login"
// Confidence is how sure the check is. Leave it empty when the check saw
// the problem itself, that counts as model.Confirmed. Set model.Inferred
// when the finding comes only from a version number or from Nmap guessing
// the service from the port.
Confidence model.Confidence
}
Defined in internal/check/check.go:48
Target¶
Target is what a check runs against: one host and one of its services.
type Target struct {
Host string
Service model.Service
}
Defined in internal/check/check.go:34
Target.Address¶
Address returns "host:port", with brackets around IPv6 hosts.
func (t Target) Address() string
Defined in internal/check/check.go:40