Skip to content

Latest commit

 

History

History
97 lines (66 loc) · 3.88 KB

File metadata and controls

97 lines (66 loc) · 3.88 KB

Redaction

Drev redacts common secrets from session JSONLs before sharing. The redaction system is documented in ARCHITECTURE.md §8 and implemented in src/core/redaction.ts.

Default patterns

Every share runs the JSONL through these regex patterns in order. Matches are replaced with <REDACTED:<type>> and counted in meta.yaml.redactions.

Type Pattern Notes
anthropic_key sk-ant-[A-Za-z0-9_-]{40,}
openai_key sk-(?:proj-)?[A-Za-z0-9_-]{40,} Includes project keys
aws_access_key AKIA[0-9A-Z]{16}
aws_secret_key (?<![A-Za-z0-9])[A-Za-z0-9/+=]{40}(?![A-Za-z0-9]) Aggressive, false-positive prone (any 40-char base64 run with non-alnum boundaries). Accepted because false-negatives leak real credentials.
github_pat ghp_[A-Za-z0-9]{36}
github_oauth gho_[A-Za-z0-9]{36}
github_app (?:ghu|ghs)_[A-Za-z0-9]{36} User and server app tokens
slack_token xox[baprs]-[A-Za-z0-9-]{10,}
private_key -----BEGIN [A-Z ]+PRIVATE KEY-----[\s\S]+?-----END [A-Z ]+PRIVATE KEY----- RSA, EC, OpenSSH, etc.
jwt eyJ[A-Za-z0-9_-]+\.eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+
google_api_key AIza[0-9A-Za-z_-]{35}
stripe_key (?:sk|pk|rk)_(?:test|live)_[A-Za-z0-9]{24,} Test, live, and restricted keys

All patterns are applied with the g (global) flag. The first matching pattern wins for any given character span.

Adding patterns

Two extension points, both compiled at runtime:

Per-team (.drev/config.yaml)

schema_version: 1
team_name: forever-town-team
redaction_extensions:
  - "ACME_INTERNAL_[A-Z0-9]+"
  - "ACME-SECRET-[a-f0-9]{32}"

These apply to every share into this repo. Useful for team-specific token prefixes.

Per-user (~/.drev/config.yaml)

schema_version: 1
ignore_patterns:
  - "MY_PERSONAL_TOKEN_[A-Z]+"

Apply only to your shares.

The complete pattern list at runtime is DEFAULT_PATTERNS ++ repo.redaction_extensions ++ user.ignore_patterns. Invalid regex sources throw a ValidationError at share time, so test new patterns with node -e "new RegExp('your-pattern', 'g')" before committing them.

What gets redacted

Redaction runs over the raw JSONL string, line by line, before write. It catches:

  • Tool call inputs and outputs
  • Assistant text
  • Embedded stderr in tool results
  • Anything else that lives inside the JSONL

It does NOT redact metadata (meta.yaml), but meta.yaml is generated by Drev from controlled sources (git config, file paths, counts), so secrets shouldn't end up there.

First-share confirmation

The first time you share to a given repo, Drev shows a redaction summary and asks before pushing:

This is your first share to <repo-name>.

Drev will redact common secrets before pushing. Found in this session:
  - 0 anthropic_key
  - 1 github_pat
  - 0 aws_access_key
  ...

Continue? [Y/n]

Subsequent shares are silent unless redactions occurred (in which case a one-line summary is printed).

Emergency removal

If redaction missed something and the secret made it to the remote, run:

drev scrub <name-or-id> --confirm

This rewrites Git history via git-filter-repo (which must be installed separately, see the project page) and force-pushes. Other engineers must re-clone the repo afterward to discard their copies.

If a secret hits remote, also rotate it. Scrub removes the file from history but anyone who cloned before the scrub still has it.

Trust model

Drev's trust model matches Git's: anyone with write access to the repo can act as anyone else, and anyone with read access can read every shared session. Sessions are stored unencrypted (per ARCHITECTURE.md §3.2). For higher-sensitivity content, gate access at the Git host (private repo, restricted org membership) rather than relying on Drev to encrypt.