webpath

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: Apache-2.0 Imports: 5 Imported by: 4 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

View Source
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.

View Source
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.

Functions

func CleanPath

func CleanPath(escaped string) (string, error)

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

func Denied(p string, deny []string) (string, bool)

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").

func Destructive

func Destructive(p string) bool

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

func HasDotSegment(p string) bool

HasDotSegment reports whether a path has a "." or ".." segment.

func Readings

func Readings(p string) []string

Readings are the paths a server may act on for a clean path: the path itself and, when a segment has parameters (";jsessionid=..."), the path without them. A check must pass for every reading.

func Under

func Under(p, prefix string) bool

Under reports whether a clean path is the prefix or under it, at a segment boundary, in every reading. An empty prefix or "/" is every path.

Types

This section is empty.

Jump to

Keyboard shortcuts

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