application capa

application-security

Forge security umbrella — composes infrastructure-hardening (response headers) + infrastructure-waf (request) + body limit into one correctly-ordered stack.

Forge security umbrella — composes infrastructure-hardening (response headers) + infrastructure-waf (request) + body limit into one correctly-ordered stack.

Tierapplication
Roleunclassified (baselined)
Pathcrates/application/security
Edition2024
Targetsapplication_security
Public items15 across 0 modules
Tests3

What it is for

application-security — the security umbrella for forge apps.

Composes the two security halves + a request-body ceiling into one correctly-ordered Tower stack and applies it to an axum::Router:

# Ordering (the reason this crate exists)

Response headers must be outermost so they apply to every response — including a WAF 403 block — and the body-limit sits just inside them, ahead of the WAF. axum Router::layer is last-added-outermost (the opposite of tower::ServiceBuilder), so SecurityStack::apply adds the WAF first (innermost) and the header layer last (outermost). App authors never hand-order these.

let router = SecurityStack::recommended()?.apply(router);

Resource ceilings beyond body-size (request timeout, global concurrency) are intentionally deferred: a correct global concurrency cap on axum needs GlobalConcurrencyLimitLayer (per-clone semaphores don't cap globally), and a timeout layer must return a 408 response rather than a non-Infallible error to satisfy axum's Router::layer bounds. Tracked for a follow-up.

B-009 Gate-0.5 finding: neither wrapped library crate ships a migrations/ directory — infrastructure-hardening (crates/infrastructure/hardening) is response-header middleware and infrastructure-waf (crates/infrastructure/waf) is request-side signature/rate-limit middleware; both are stateless Tower layers with no schema of their own. migrations() staying empty is correct, not an oversight. Nothing to vendor. permission_codes() was already declared before this pass.

Capabilities

crate root

application-security — the security umbrella for forge apps.

Item
pub const DEFAULT_BODY_LIMIT: usize

SecurityModule

application-security — the security umbrella for forge apps.

Item
pub struct SecurityModule
SecurityModule :: fn new() -> Self
SecurityModule :: fn name(& self) -> & 'static str
SecurityModule :: fn version(& self) -> & 'static str
SecurityModule :: fn migrations(& self) -> Vec <MigrationSet>
SecurityModule :: async fn migrate_pending(& self, _pool : & PgPool) -> Result <u32, MigrationError>
SecurityModule :: fn permission_codes(& self) -> Vec <String>

SecurityStack

application-security — the security umbrella for forge apps.

Item
pub struct SecurityStack
SecurityStack :: fn recommended() -> Result <Self, SecurityStackError>
SecurityStack :: fn with_waf_config(waf_config : infrastructure_waf::WafConfig,) -> Result <Self, SecurityStackError>
SecurityStack :: fn body_limit(mut self, bytes : usize) -> Self
SecurityStack :: fn apply(self, router : axum::Router) -> axum::Router

SecurityStackError

application-security — the security umbrella for forge apps.

Item
pub struct SecurityStackError
SecurityStackError :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result

How to use it

No examples/ target and no doctest in this crate's rustdoc. The tests listed under Verification are the closest executable usage.

Module structure

No public modules: the crate root is its whole surface.

Public surface

`crate root`

ItemWhat it is
pub const DEFAULT_BODY_LIMIT: usizeDefault request body-size ceiling (2 MiB).
pub struct SecurityStackErrorError building the security stack (e.g
SecurityStackError :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result
pub struct SecurityStackThe composed forge security stack: WAF + body-limit + response headers.
SecurityStack :: fn recommended() -> Result <Self, SecurityStackError>Build the recommended stack: default WAF + secure-default response headers + a 2 MiB request-body ceiling
SecurityStack :: fn with_waf_config(waf_config : infrastructure_waf::WafConfig,) -> Result <Self, SecurityStackError>Build the stack with a caller-supplied infrastructure_waf::WafConfig (e.g
SecurityStack :: fn body_limit(mut self, bytes : usize) -> SelfOverride the request body-size ceiling (bytes).
SecurityStack :: fn apply(self, router : axum::Router) -> axum::RouterApply the stack to a router
pub struct SecurityModuleForge module identity for application-security.
SecurityModule :: fn new() -> SelfCreate the module.
SecurityModule :: fn name(& self) -> & 'static str
SecurityModule :: fn version(& self) -> & 'static str
SecurityModule :: fn migrations(& self) -> Vec <MigrationSet>
SecurityModule :: async fn migrate_pending(& self, _pool : & PgPool) -> Result <u32, MigrationError>
SecurityModule :: fn permission_codes(& self) -> Vec <String>

Re-exports. Exported here, defined elsewhere.

ExportDefined in
infrastructure_hardeninginfrastructure_hardening
infrastructure_wafinfrastructure_waf

Boundary

Reaches into infrastructure.

Shares tier application with 120 other crates: application-agreements, application-ai, application-analytics, application-approvals, application-assessments, application-audit-log, application-auth, application-billing, … (120 total).

_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._

Where it sits

Tier (ontology)application
Architectural role (taxonomy)unclassified (baselined)
Locationcrates/application/security
Vocabulary in force (lexicon)current

Tier flow. Which tiers this crate's own edges cross.

flowchart LR
  n_application["application"] --> n_infrastructure["infrastructure"]

Dependencies

Runtime, in this workspace.

CrateTierOptionalOnly on
`application-core`applicationnoalways
`infrastructure-hardening`infrastructurenoalways
`infrastructure-waf`infrastructurenoalways

Runtime, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
async-trait^0.1noalways
axum^0.7multipartnoalways
sqlx^0.8runtime-tokio, postgres, chrono, uuid, jsonnoalways

Development, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
http^1.1noalways
tokio^1fullnoalways
tower^0.5utilnoalways

Build. None.

Depended on by. Nothing in this workspace.

Signal flow — what reaches this crate, and what it reaches.

flowchart LR
  SELF["application-security"]
  SELF -->|runtime| n_application_core["application-core"]
  SELF -->|runtime| n_infrastructure_hardening["infrastructure-hardening"]
  SELF -->|runtime| n_infrastructure_waf["infrastructure-waf"]
  classDef self fill:#1f883d,stroke:#1f883d,color:#fff;
  class SELF self;

Feature flags

No Cargo features are defined: every capability is unconditional, so no consumer can receive a half-wired crate.

Targets

KindNameSource
libapplication_security`src/lib.rs`

Error model

Error typeNamed by
SecurityStackErrordeclared, no public signature returns it

Operational characteristics

PropertyEvidence
async public surfaceyes
async runtimenone detected
database accessyes
network I/Oyes
unsafe codenone detected
environment variablesyes

No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.

Configuration

VariableRead in
CARGO_PKG_VERSIONsrc/lib.rs

No workspace crate depends on this one.

Verification

KindCount
Unit tests3
Integration tests0
Examples0
Doctests0

Evidence by module. How often each public module is named by something executable.

ModuleTestsExamplesConsumers
crate root400

What the tests establish, by name:

Documentation coverage

MeasureDocumentedTotal
Public items with rustdoc915
Public modules with a //! block00
pie showData
    title Public items with rustdoc
    "Documented" : 9
    "No rustdoc detected" : 6

Metrics

MetricValue
Rust source files1
Source lines187
Code lines110
Public API items15
Public modules0
Tests3
Examples0
Cargo features0
Direct runtime dependencies6
Workspace reverse dependencies0
pie showData
    title Public API by kind
    "constant" : 1
    "method" : 11
    "struct" : 3
pie showData
    title Rust source composition
    "Code" : 110
    "Blank or comment" : 77

Generation

Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.

Todas las application · Manual