<!-- Copyright (c) 2026 defconxt. All rights reserved. -->
<!-- Licensed under AGPL-3.0 — see LICENSE file for details. -->
<!-- NERF is a trademark of defconxt. -->
# PII Detection — API Reference

## Scan File

```bash
node scripts/agent.js --action scan --input /var/log/app.log
node scripts/agent.js --action scan --input data.csv --categories "ssn,email,credit_card"
```

## Scan Directory

```bash
node scripts/agent.js --action scan-dir --input /var/log/ \
  --extensions ".log,.csv,.json" --output /tmp/pii_scan.json
```

## Classify Findings

```bash
node scripts/agent.js --action classify --findings /tmp/pii_findings.json
```

## Supported PII Patterns

| Pattern | Regex | Sensitivity |
|---------|-------|-------------|
| ssn | `\d{3}-\d{2}-\d{4}` | Critical |
| email | RFC-5322 simplified | High |
| phone_us | US phone with optional +1 | High |
| credit_card | Visa/MC/Amex/Discover | Critical |
| ip_v4 | Dotted quad | Medium |
| date_of_birth | MM/DD/YYYY | Medium |
| iban | ISO 13616 | Critical |

## Output Format

```json
{
  "type": "ssn",
  "sensitivity": "critical",
  "line": 42,
  "column": 15,
  "redacted_value": "123-***-4567",
  "context": "user record: SSN 123-45-6789 for account..."
}
```

## Integration Points

| Stage | Scanning Method |
|-------|----------------|
| Ingestion | Scan API payloads before storage |
| Logging | Pre-write log scrubber |
| Export | Scan before third-party transfer |
| Analytics | Scan before aggregation pipeline |
| Backup | Periodic scan of backup archives |
