webscope

package
v0.33.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 14, 2026 License: GPL-3.0 Imports: 6 Imported by: 0

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

This section is empty.

Variables

View Source
var ErrOutOfScope = errors.New("outside the job's web scope")

ErrOutOfScope is the error of a request outside the web scope.

Functions

func CleanPath

func CleanPath(u *url.URL) (string, error)

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.

func HostMatches

func HostMatches(pattern, host string) bool

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.
	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"`
}

Scope is a job's web scope.

func (*Scope) Allows

func (s *Scope) Allows(method string, u *url.URL, targets []string) error

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

func (s *Scope) Validate() error

Validate checks the scope's bounds and syntax. A job whose scope is invalid is refused, never run unrestricted.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL