Expand description
The exclude_paths matcher: the reference
core/validation/path_matching.py.
A request path is normalized before it is compared, so an encoded or dot-segmented spelling cannot slip past (or into) an exclusion:
- percent-decode runs of
%XXas UTF-8, up to four rounds; an invalid UTF-8 run, or a%XXstill left after the fourth round, makes the path unmatchable (never excluded); - fold
\to/, drop empty and.segments, resolve..against the segments seen so far, and treat a..;param/.;paramsegment as its dot form.
An exclusion matches the normalized path when it equals it or is a
/-bounded prefix of it (/static excludes /static and
/static/app.js, never /staticx); an exclusion of / matches every
path. Exclusions normalize the same way, and an exclusion that cannot
normalize is dropped.
§Example
use guard_core_engine::path_matching::PathExclusions;
let exclusions = PathExclusions::new(["/static", "/docs"]);
assert!(exclusions.is_excluded("/static/app.js"));
assert!(exclusions.is_excluded("/static/../static/app.js"));
assert!(!exclusions.is_excluded("/static/../admin"));
assert!(!exclusions.is_excluded("/staticx"));Structs§
- Path
Exclusions - The configured exclusions, normalized once.
Functions§
- normalize_
exclude_ paths normalize_exclude_paths: the entries that normalize, in order.- normalize_
url_ path normalize_url_path: the comparable form of a raw request path,Nonewhen it cannot be decoded safely.- path_
is_ excluded path_is_excluded: normalize both sides and match.- path_
matches_ exclusions path_matches_exclusions: the already-normalized path against already-normalized exclusions.