Documentation
¶
Overview ¶
Package webscope is the web scope of a job: which hosts, paths and methods a web tool (a crawler, a DAST scanner) may request. The platform puts it in the job; the SDK refuses every request outside it, whatever the tool does (tool.Context.HTTP), and the sensor maps it onto the flags of a tool that makes its own requests.
A job without a web scope is unrestricted by this package (the target hosts and the egress guard still apply).
Stability: Beta (docs/STABILITY.md).
Index ¶
Constants ¶
const ( // MaxRequestsPerHostLimit is the largest MaxRequestsPerHost a scope // may carry. MaxRequestsPerHostLimit = 1_000_000 )
Bounds of a web scope.
Variables ¶
var ErrOutOfScope = errors.New("outside the job's web scope")
ErrOutOfScope is the error of a request outside the web scope.
Functions ¶
func CleanPath ¶
CleanPath is the path a server sees for u: percent-decoded, dot segments resolved, never empty. A path with an encoded slash, backslash or NUL, a control character, or a dot segment with parameters ("..;") is refused: servers disagree on it (webpath.CleanPath).
func HostMatches ¶
HostMatches reports whether host matches the pattern: equal ignoring case and a trailing dot, or, for "*.example.com", example.com and any name under it.
Types ¶
type Scope ¶
type Scope struct {
// Hosts are the hosts a request may go to: a host name or address
// ("app.example.com"), or "*.example.com" for the domain and every
// name under it. Empty: the job's target hosts.
Hosts []string `json:"hosts,omitempty"`
// PathPrefixes are the paths a request may go to ("/app", "/api/v2/").
// A prefix matches itself and the paths under it, at a segment
// boundary. Empty: every path.
PathPrefixes []string `json:"path_prefixes,omitempty"`
// DenyPaths are paths a request never goes to ("/logout", "/admin"),
// whatever PathPrefixes allows. A deny path matches every path that
// starts with it, ignoring case: over-blocking is the safe side. A
// segment "*" matches any one segment ("/tenants/*/admin"). A deny path
// holds as written and percent-decoded (webpath.Denied).
DenyPaths []string `json:"deny_paths,omitempty"`
// Methods are the HTTP methods a request may use. Empty: GET, HEAD
// and OPTIONS.
Methods []string `json:"methods,omitempty"`
// MaxRequestsPerHost is the most HTTP requests the task may send to
// one host name, whatever the port, connection or scheme (0: no cap).
// The task's forwarder counts every request it lets through and
// refuses the ones past the cap, as it refuses a request outside the
// scope; the task cannot reset the count.
MaxRequestsPerHost int `json:"max_requests_per_host,omitempty"`
}
Scope is a job's web scope.
func (*Scope) Allows ¶
Allows reports whether a request may go to u with method; the error names why not. targets are the job's target hosts, the hosts of a scope that names none.
func (*Scope) Validate ¶
Validate checks the scope's bounds and syntax, and adds the clean form of every deny path that is written another way ("/files/My%20Docs" also denies as "/files/My Docs"), so a deny list from a platform that stored escaped paths holds on a tool that reads the list itself. A job whose scope is invalid is refused, never run unrestricted.