Framework-agnostic application-layer API security engine.
Rust port of guard-core's
detection engine. Work in progress: the CPU-bound detection pipeline
is the core, and the first pipeline stage has landed: the rate-limit and
dynamic-ban [tower] layer for Axum/tonic-shaped stacks. Handlers,
protocols, decorators, and other I/O layers are not yet ported.
Re-exports the detection engine modules:
- [
detection_exclusions] - the per-route detection exclusion resolution and the multi-surface request scan (scan_request): excluded headers/params/body fields, enabled detection categories, and the detection scan-body toggle, resolved from the global config and the route config exactly as the reference's_resolve_*helpers do - [
compiler] - regex pattern compilation with LRU caching and ReDoS safety validation - [
detect] - the spec 4.0.2 detection pipeline entry point (detect, [detect::DetectConfig], [detect::DetectVerdict]) - [
preprocessor] - unicode NFKC normalization, URL/HTML decoding, null byte removal, whitespace collapsing, and attack-preserving truncation - [
semantic] - token extraction, Shannon entropy, encoding layer detection, attack probability scoring, obfuscation detection, code injection risk analysis, and aggregate threat scoring - [
cloud_provider] - the cloud-provider blocking pipeline stage as atower::Layer(403 "Cloud provider IP not allowed", region carve-outs, skip-state aware) - [
geo] - the geo country blocking pipeline stage as atower::Layer(403 "Forbidden", loopback exemption, whitelist-skip only) - [
tower] - the rate-limit and dynamic IP ban pipeline stage as atower::Layer(429 throttled shape, 403 banned shapes, exempt-IP handling, the auto-ban feeds, and passive mode) - [
request_limits] - the request size and content-type pipeline stage as atower::Layer(413 size shape, 415 content-type shape, fail-secure 500 on a junk content-length) - [
headers_auth] - the required-headers and authentication pipeline stage as atower::Layer(dynamic 400 required-header shapes, fixed 401 authentication shape, route rules with a global verifier fallback) - [
event_types] / [events] - the referenceEVENT_*constants and theSecurityEventBushook seam over the referenceSecurityEventrecord - [
responses] - the referencecustom_error_responsesmap and theon_blockblock hook with the reference payload and exclusion set - [
logging] - the referencelog_activityline shapes with themuted_check_logsandlog_sensitive_*redaction knobs - [
redact] - the merged sensitive-name sets and the[REDACTED]redaction the log lines run through
Usage
use preprocessor;
use AttackKeywords;
use AttackStructures;
use ;
let raw = "<scr\u{200B}ipt>alert(1)</script>";
let clean = preprocess;
let kw = default;
let st = default;
let result = analyze;
let score = get_threat_score;
assert!;