Expand description
The reference decorator system (guard_core/decorators/*.py): the
SecurityDecorator registry and its mixin method surface, ported
method for method.
Python applies decorators to route functions and stamps a route id on
the callable; Rust has no runtime function attributes, so the idiom is
a named route id: every mixin method takes the route id the
application chose (the reference derives it from
module.qualname, the stand-in is the caller’s stable name, by
convention "<METHOD> <path>"), and the registry hands the
RouteConfig carrier to the adapters’ with_route_configs
resolvers. Semantics are the reference’s, exactly:
- first touch creates the route’s
RouteConfigwithenable_suspicious_detectionseeded from the config’senable_penetration_detectionand bumps the revision (BaseSecurityDecorator._ensure_route_config), - every mutation is revision-tracked
(
RouteConfigRevision), bypasskeeps only the referenceVALID_BYPASS_CHECKSnames and drops the rest (the unknowns are returned to the caller, the reference logs them),block_cloudswith no argument blocks everyVALID_CLOUD_PROVIDERSentry; named entries outside the reference set are ignored and returned,require_auth/api_key_authconflict withrequire_authorization_headerand fail closed (DecoratorError),return_monitor/behavior_analysisvalidate everyreturn_patterncompiles (the reference_validate_return_pattern_body_scan’s compile half),honeypot_detectionregisters the reference’s honeypot validator (form and JSON trap-field probe over the buffered body, POST/PUT/ PATCH only,403 "Forbidden").
Structs§
- Decorator
Error - Why a decorator factory refused a value: the reference raises
ValueErroron the auth-conflict combinations and on an uncompilablereturn_pattern. - Security
Decorator - The decorator registry (
SecurityDecorator): the config it reads its defaults from, the per-routeRouteConfigs, and the revision counter every mutation bumps.
Constants§
- VALID_
BYPASS_ CHECKS - The reference
VALID_BYPASS_CHECKS: the names [SecurityDecorator:: bypass] keeps. - VALID_
CLOUD_ PROVIDERS - The reference
VALID_CLOUD_PROVIDERS(CloudProvider = Literal["AWS", "GCP", "Azure", "DigitalOcean", "Linode", "Vultr"]).