infrastructure capa

infrastructure-dlp-detect

Deterministic host-side DLP detection: scan free text for US SSN and payment-card PAN (Luhn), returning fully-masked, structure-preserving findings with optional keyed-HMAC fingerprints. Pure, zero-I/O, regex-only; the caller supplies the key via a Fingerprinter. Detectors lifted from infrastructure-waf::pattern_detector.

Deterministic host-side DLP detection: scan free text for US SSN and payment-card PAN (Luhn), returning fully-masked, structure-preserving findings with optional keyed-HMAC fingerprints. Pure, zero-I/O, regex-only; the caller supplies the key via a Fingerprinter. Detectors lifted from infrastructure-waf::pattern_detector.

Tierinfrastructure
Roleunclassified (baselined)
Pathcrates/infrastructure/dlp-detect
Edition2021
Targetsinfrastructure_dlp_detect
Public items24 across 2 modules
Tests105

What it is for

infrastructure-dlp-detect — deterministic host-side DLP detection.

Scans free text for US Social Security Numbers, payment-card PANs, and a set of format-shaped PII classes (phone, DOB, postal address, medical record number, case/docket number — added Sprint 3.8, see detectors.rs) and returns Findings that are fully masked (structure-preserving for the numeric classes; no digit survives) plus an optional keyed-HMAC fingerprint for dedup/correlation.

Design invariants (from sprint 2.5 Gate-1.5 consensus):

here; it belongs behind RBAC in the consuming module.

supplies a Fingerprinter. Fingerprinting is computed over the normalized (digits-only) value internally, so the raw value never leaves detect.

on it does not violate the "no raw in logs/serialization" rule — that rule binds the sensor's raw buffers, not this already-masked output.

Detectors (SSN area/group/serial rules, Luhn) are lifted from infrastructure-waf::pattern_detector; WAF is repointed at this crate (T2).

Capabilities

crate root

infrastructure-dlp-detect — deterministic host-side DLP detection.

Item
fn detect(text : & str, policy : & DlpPolicy <'_>) -> Vec <Finding>

Confidence

infrastructure-dlp-detect — deterministic host-side DLP detection.

Item
pub enum Confidence

DlpFindingType

infrastructure-dlp-detect — deterministic host-side DLP detection.

Item
pub enum DlpFindingType
DlpFindingType :: fn as_str(& self) -> & 'static str
DlpFindingType :: fn from_str_name(s : & str) -> Option <Self>

DlpPolicy

infrastructure-dlp-detect — deterministic host-side DLP detection.

Item
pub struct DlpPolicy<'a>

Finding

infrastructure-dlp-detect — deterministic host-side DLP detection.

Item
pub struct Finding

Fingerprinter

infrastructure-dlp-detect — deterministic host-side DLP detection.

Item
pub trait Fingerprinter

entropy (other)

Shannon entropy + corroborated high-entropy secret detection (Sprint 3.6 T2).

Item
pub const DEFAULT_ENTROPY_THRESHOLD: f64
fn shannon_entropy(s : & str) -> f64

policy (other)

Screening policy + verdicts for the outbound DLP gate (Sprint 3.6 T4).

Item
fn screen(text : & str, policy : & ScreenPolicy) -> Result <Verdict, ScreenError>
fn screen_at(text : & str, policy : & ScreenPolicy, now_unix : i64) -> Result <Verdict, ScreenError>

Action

Screening policy + verdicts for the outbound DLP gate (Sprint 3.6 T4).

Item
pub enum Action

AllowlistEntry

Screening policy + verdicts for the outbound DLP gate (Sprint 3.6 T4).

Item
pub struct AllowlistEntry

PolicyError

Screening policy + verdicts for the outbound DLP gate (Sprint 3.6 T4).

Item
pub enum PolicyError
PolicyError :: fn fmt(& self, f : & mut core::fmt::Formatter <'_>) -> core::fmt::Result

ScreenError

Screening policy + verdicts for the outbound DLP gate (Sprint 3.6 T4).

Item
pub enum ScreenError
ScreenError :: fn fmt(& self, f : & mut core::fmt::Formatter <'_>) -> core::fmt::Result

ScreenPolicy

Screening policy + verdicts for the outbound DLP gate (Sprint 3.6 T4).

Item
pub struct ScreenPolicy
ScreenPolicy :: fn default() -> Self
ScreenPolicy :: fn from_toml_str(source : & str) -> Result <Self, PolicyError>
ScreenPolicy :: fn policy_version(& self) -> String
ScreenPolicy :: fn action_for(& self, class : DlpFindingType) -> Action

Verdict

Screening policy + verdicts for the outbound DLP gate (Sprint 3.6 T4).

Item
pub enum Verdict

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

infrastructure_dlp_detect

flowchart TD
  n_infrastructure_dlp_detect["infrastructure_dlp_detect"]
  n_infrastructure_dlp_detect --> n_entropy["entropy"]
  n_infrastructure_dlp_detect --> n_policy["policy"]

Public surface

`crate root`

ItemWhat it is
pub enum DlpFindingTypeThe category of a detected sensitive value
DlpFindingType :: fn as_str(& self) -> & 'static strStable machine identifier for the finding type.
DlpFindingType :: fn from_str_name(s : & str) -> Option <Self>Parse a stable machine identifier (the Self::as_str form) back into a finding type
pub enum ConfidenceDetection confidence grade
pub struct FindingA single detected sensitive value
pub trait FingerprinterSupplies a keyed fingerprint over a normalized (digits-only) value
pub struct DlpPolicy<'a>Detection policy
fn detect(text : & str, policy : & DlpPolicy <'_>) -> Vec <Finding>Scan text and return all sensitive-value findings, sorted by position

`entropy`

ItemWhat it is
pub const DEFAULT_ENTROPY_THRESHOLD: f64Default corroborated-entropy threshold (bits/char), matching the historical cookie_decode secret heuristic (entropy > 4.5 && len > 20).
fn shannon_entropy(s : & str) -> f64Shannon entropy of a string (bits per character).

`policy`

ItemWhat it is
pub enum ActionPer-class enforcement action.
pub struct AllowlistEntryA validated allowlist entry: a deliberate, expiring exemption for one exact value (keyed-HMAC fingerprint) of one class.
pub enum VerdictThe screening outcome for one text.
pub enum ScreenErrorScreening runtime failure (distinct from policy-load failure).
ScreenError :: fn fmt(& self, f : & mut core::fmt::Formatter <'_>) -> core::fmt::Result
pub enum PolicyErrorPolicy-load failure
PolicyError :: fn fmt(& self, f : & mut core::fmt::Formatter <'_>) -> core::fmt::Result
pub struct ScreenPolicyTOML-loadable screening policy
ScreenPolicy :: fn default() -> SelfThe built-in default policy: default actions, no allowlist, no denylist, no auto-redact, default entropy threshold.
ScreenPolicy :: fn from_toml_str(source : & str) -> Result <Self, PolicyError>Parse and validate a policy from TOML text
ScreenPolicy :: fn policy_version(& self) -> Stringsha256 hex of the canonical policy bytes (the TOML source; empty string for the built-in default policy).
ScreenPolicy :: fn action_for(& self, class : DlpFindingType) -> ActionThe effective action for a class: explicit entry, else the settled default table.
fn screen(text : & str, policy : & ScreenPolicy) -> Result <Verdict, ScreenError>Screen text against policy, using the current system clock for allowlist expiry
fn screen_at(text : & str, policy : & ScreenPolicy, now_unix : i64) -> Result <Verdict, ScreenError>Fully deterministic screening with an injected clock (unix seconds).

Re-exports. Exported here, defined elsewhere.

ExportDefined in
HmacFingerprinterfingerprint::HmacFingerprinter
redactredact::redact
shannon_entropyentropy::shannon_entropy
{screen,screen_at,Action,AllowlistEntry,PolicyError,ScreenError,ScreenPolicy,Verdict,}policy::{screen,screen_at,Action,AllowlistEntry,PolicyError,ScreenError,ScreenPolicy,Verdict,}

Boundary

Depends on no other workspace tier.

Shares tier infrastructure with 82 other crates: infrastructure-acquire, infrastructure-adapters-google-calendar, infrastructure-adapters-google-gmail, infrastructure-adapters-google-places, infrastructure-adapters-google-trends, infrastructure-adapters-shodan, infrastructure-adapters-yelp, infrastructure-agent, … (82 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)infrastructure
Architectural role (taxonomy)unclassified (baselined)
Locationcrates/infrastructure/dlp-detect
Vocabulary in force (lexicon)current

Dependencies

Runtime, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
hmac^0.12yesalways
once_cell^1noalways
regex^1noalways
serde^1deriveyesalways
sha2^0.10yesalways
toml^0.8yesalways

Development. None.

Build. None.

Depended on by. 14 workspace crates.

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

flowchart LR
  n_application_conversation["application-conversation"] -->|uses| SELF
  n_application_wiki["application-wiki"] -->|uses| SELF
  n_infrastructure_agent["infrastructure-agent"] -->|uses| SELF
  n_infrastructure_browser_automation["infrastructure-browser-automation"] -->|uses| SELF
  n_infrastructure_dlp["infrastructure-dlp"] -->|uses| SELF
  n_infrastructure_ocr_tesseract["infrastructure-ocr-tesseract"] -->|uses| SELF
  n_infrastructure_waf["infrastructure-waf"] -->|uses| SELF
  n_operations_dlp_agent["operations-dlp-agent"] -->|uses| SELF
  n_operations_dlp_sensor["operations-dlp-sensor"] -->|uses| SELF
  n_platform_privacy_scan_api["platform-privacy-scan-api"] -->|uses| SELF
  n_tools_ask_ai_core["tools-ask-ai-core"] -->|uses| SELF
  n_tools_corpus["tools-corpus"] -->|uses| SELF
  n_tools_knowitall["tools-knowitall"] -->|uses| SELF
  n_tools_prompt_shaper["tools-prompt-shaper"] -->|uses| SELF
  SELF["infrastructure-dlp-detect"]
  classDef self fill:#1f883d,stroke:#1f883d,color:#fff;
  class SELF self;

Feature flags

FeatureEnablesOn by default
defaultyes
fingerprintdep:hmac, dep:sha2no
policydep:toml, dep:serde, fingerprintno
serdedep:serdeno
flowchart LR
  n_default["default"]
  n_fingerprint["fingerprint"] --> n_dep_hmac["dep:hmac"]
  n_fingerprint["fingerprint"] --> n_dep_sha2["dep:sha2"]
  n_policy["policy"] --> n_dep_toml["dep:toml"]
  n_policy["policy"] --> n_dep_serde["dep:serde"]
  n_policy["policy"] --> n_fingerprint["fingerprint"]
  n_serde["serde"] --> n_dep_serde["dep:serde"]

Targets

KindNameSource
libinfrastructure_dlp_detect`src/lib.rs`

Error model

Error typeNamed by
PolicyErrordeclared, no public signature returns it
ScreenErrorscreen, screen_at

Operational characteristics

PropertyEvidence
async public surfacenone detected
async runtimenone detected
database accessnone detected
network I/Onone detected
unsafe codenone detected
environment variablesnone detected

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

Configuration

No environment variable is read with a literal name anywhere in this crate. A variable whose key is computed at run time cannot be listed here, and is not claimed to be absent.

14 workspace crates depend on this one: application-conversation, application-wiki, infrastructure-agent, infrastructure-browser-automation, infrastructure-dlp, infrastructure-ocr-tesseract, infrastructure-waf, operations-dlp-agent, operations-dlp-sensor, platform-privacy-scan-api, tools-ask-ai-core, tools-corpus, … (14 total).

Verification

KindCount
Unit tests105
Integration tests0
Examples0
Doctests0

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

ModuleTestsExamplesConsumers
crate root6035
entropy201
policy8025

What the tests establish, by name:

Documentation coverage

MeasureDocumentedTotal
Public items with rustdoc2224
Public modules with a //! block22
pie showData
    title Public items with rustdoc
    "Documented" : 22
    "No rustdoc detected" : 2

Metrics

MetricValue
Rust source files6
Source lines2708
Code lines2055
Public API items24
Public modules2
Tests105
Examples0
Cargo features4
Direct runtime dependencies6
Workspace reverse dependencies14
pie showData
    title Public API by kind
    "constant" : 1
    "enum" : 6
    "function" : 4
    "method" : 8
    "struct" : 4
    "trait" : 1
pie showData
    title Rust source composition
    "Code" : 2055
    "Blank or comment" : 653

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 infrastructure · Manual