Documentation
¶
Overview ¶
Package webpath is the one reading of a web request path shared by the platform and the sensor: how a server sees a path (CleanPath), whether a path falls under an excluded path (Denied) or an allowed prefix (Under), and whether a path names a state-changing action (Destructive).
The platform plans path discovery and filters candidate lists with these functions, and the sensor's web scope refuses requests with the same ones, so a candidate the platform keeps is never one the sensor would refuse for a different reason, and an exclusion can never be read two ways.
Index ¶
- Variables
- func CheckCandidate(escaped string) error
- func CleanDeny(d string) (string, error)
- func CleanPath(escaped string) (string, error)
- func Denied(p string, deny []string) (string, bool)
- func Destructive(p string) bool
- func HasDotSegment(p string) bool
- func Readings(p string) []string
- func Under(p, prefix string) bool
Constants ¶
This section is empty.
Variables ¶
var ( ErrEncodedSeparator = errors.New("encoded separator in the path") ErrBadEscape = errors.New("invalid percent-encoding in the path") ErrControl = errors.New("control character in the path") ErrDotParams = errors.New("dot segment with parameters in the path") )
Errors of CleanPath.
var DestructiveVerbs = []string{
"logout", "logoff", "signout", "delete", "remove", "destroy", "drop", "purge", "wipe",
"reset", "shutdown", "restart", "reboot", "kill", "unsubscribe", "cancel", "revoke",
}
DestructiveVerbs are the words that mark a path as a state-changing action a GET may still trigger (a logout link, "/admin/delete?id=1"). Discovery never requests such a path and a crawler never follows one.
var ErrCandidate = errors.New("candidate path is not plain ASCII")
ErrCandidate is the error of CheckCandidate.
Functions ¶
func CheckCandidate ¶ added in v1.3.1
CheckCandidate checks a guessed candidate path (escaped) before it is requested: CleanPath must accept it, and it may hold neither an escaped percent sign ("%25", read twice by some servers) nor a byte outside printable ASCII, raw or decoded (servers fold such letters to ASCII in different ways). A guess list never needs either.
func CleanDeny ¶ added in v1.3.1
CleanDeny is the stored form of a deny path: percent-decoded and cleaned as CleanPath reads a request ("/files/My%20Docs" is "/files/My Docs"), so it compares with the path a server sees. A deny path CleanPath refuses is an error; a trailing slash is kept.
func CleanPath ¶
CleanPath is the path a server sees for an escaped request path: percent-decoded, backslashes read as slashes, dot segments resolved, never empty, a trailing slash kept. 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 Denied ¶
Denied returns the first deny path that a clean path falls under, in any reading. A deny path matches every path that starts with it, ignoring case: over-blocking is the safe side ("/admin" also denies "/Admin" and "/administrator"). A segment "*" of a deny path matches any one segment ("/tenants/*/admin" denies "/tenants/acme/admin/x"), as the platform's path exclusions read it.
Both sides are compared in the form a lenient server reads them: case folded to ASCII (a letter whose case folding includes an ASCII letter, such as U+017F for "s" or U+212A for "k", is that letter), and trailing dots and spaces of a segment dropped ("/admin./x" is "/admin/x" to a Windows server). A deny path is taken both as written and percent-decoded (an exclusion stored as "/files/My%20Docs" denies "/files/My Docs/a.bak"), so a deny list of either form holds.
func Destructive ¶
Destructive reports whether a path (escaped or clean) names a state-changing action: a segment has a word that is one of DestructiveVerbs, or that starts with one ("deleteUser", "logout_all", "resetPassword"), or two adjacent words that join into one ("log-out", "sign_out"). Words are split on anything that is not a letter or a digit, and on a lower-to-upper case change. Over-blocking is the safe side.
func HasDotSegment ¶
HasDotSegment reports whether a path has a "." or ".." segment.
func Readings ¶
Readings are the paths a server may act on for a clean path: the path itself; when a segment has parameters (";jsessionid=..."), the path without them; and when the path still holds a percent-escape, the path a server that decodes twice sees ("/%2561dmin" reaches it as "/admin"). A check must pass for every reading.
Types ¶
This section is empty.