RustSecurityTagger
Inherits FrameworkTagger < FileHelper < Tagger < Reference < Object
Rust-specific security tagger.
rust_auth already classifies authentication (request guards,
extractors, auth middleware), so this tagger covers the other
framework-level security protections that a reviewer wants to know
are (or are not) in front of an endpoint. Each protection maps onto a
tag whose description says whether the configuration is hardened or a
risk:
- cors — CORS middleware. Permissive configs (any origin, wildcard) are flagged as a risk; restricted allow-lists are recorded as informational.
- rate-limit — request throttling (actix-governor / tower_governor / actix-limitation / tower limit).
- security-headers — hardening response headers (HSTS, CSP, X-Frame-Options, X-Content-Type-Options, …).
- body-limit — request body size cap (DoS mitigation). A disabled limit is flagged as a risk.
Detection is two-pronged:
-
Source middleware — every
.rsfile is pre-scanned for the builder calls above. The enclosing Actixweb::scope("/x")(if any) gives the URL prefix the protection applies to; app-wide middleware (App::new().wrap(..),Router::new().layer(..)) maps to/so it tags every endpoint. Test modules (#[cfg(test)]) andtests//benches//examples/files are skipped so test-only middleware can't taint real endpoints. -
Loco config — Loco wires its middleware in
config/*.yaml(middlewares: { cors:, limit_payload:, secure_headers: }) rather than in code, so those files are parsed too and applied app-wide.
Scope mapping errs toward false negatives (a too-narrow prefix tags fewer endpoints) rather than false positives, in keeping with the rest of Noir's tagging.
Constants
--- Request body size limit ----------------------------------------
--- CORS ----------------------------------------------------------- Permissive: any origin is accepted. The classic finding.
Configured (restricted) CORS — present but not wide open.
--- Rate limiting --------------------------------------------------
Match the application of a limiter (.wrap/.layer) or a Layer
type that is only ever applied — never a bare GovernorConfigBuilder
value, which is config and would mis-map an app-wide tag onto every
endpoint even when the limiter is wrapped onto one scope.
--- Security response headers --------------------------------------
The header name — as a quoted literal ("X-Frame-Options") or the
http crate's HeaderName constant (X_FRAME_OPTIONS) — is a
strong signal the app sets it (request-side reads of these are rare).
Framework-agnostic: works for Actix DefaultHeaders, tower-http
SetResponseHeaderLayer, and helmet-style crates alike.
Constructors
Class methods
Kept in lock-step with rust_auth (the guard-support invariant in
techs_spec requires every framework-tagger target to be a
guard-supported tech, which currently excludes Salvo/Poem).
Instance methods
The per-endpoint shape: look at each endpoint, tag in place, hand the
array back. Fifteen framework taggers carried a byte-identical copy of
this; they now declare only check_endpoint.
Not every framework tagger fits it — eleven still override perform
because they need a pre-scan over the project (config files, middleware
registration) before the per-endpoint pass, or they group endpoints
first. Those keep their own.