Skip to content

fix(core): enforce secret scanning before team memory sync#115

Merged
BunsDev merged 1 commit into
mainfrom
fix/enforce-secret-scan-team-memory
Jun 24, 2026
Merged

fix(core): enforce secret scanning before team memory sync#115
BunsDev merged 1 commit into
mainfrom
fix/enforce-secret-scan-team-memory

Conversation

@BunsDev

@BunsDev BunsDev commented Jun 24, 2026

Copy link
Copy Markdown
Member

Summary

Closes part of #102. The repo already had a scan_for_secrets function, but it was only exercised in tests — it was not enforced on the upload path, so a team-memory .md file containing an API key, token, or private key could be packed and synced to the shared store.

This wires scan_for_secrets into scan_local_files — the single choke point every entry passes through before push/upload_batch. A file with any detected secret is now blocked from sync entirely.

What changed

  • scan_local_files scans each .md file's content; if scan_for_secrets returns any match, the file is skipped (never packed for upload).
  • On a block, only the pattern labels and file path are logged via tracing::warn — never the matched text — so the log itself cannot leak the credential.

Acceptance criteria (#102, team-memory-upload slice)

  • scan_for_secrets is called before team memory upload
  • Secret-like content blocks the memory write
  • Logs do not include matched secret values (only labels + path)

Tests

Added two scan_local_files tests; full module suite green (25 passed, 0 failed):

  • test_scan_local_files_blocks_file_with_secret — a secret-bearing file is excluded while a clean sibling still uploads.
  • test_scan_local_files_blocks_all_when_every_file_has_secret — an all-secrets dir yields zero upload entries.

Scope / notes

  • This covers the team-memory sync boundary only. The other boundaries in Enforce secret scanning before memory write or sync #102 (session-memory persistence in hosted mode, settings/user-memory sync, redaction-required candidates) are intentionally left for follow-ups so this stays a small, reviewable change.
  • Developed in an isolated worktree off origin/main; no rebase of other in-flight branches.

🤖 Generated with Claude Code

Wire the existing `scan_for_secrets` into `scan_local_files`, the choke
point every entry passes through before a team-memory push. A file with
any detected secret is now blocked from sync entirely, and only the
matched pattern labels and the file path are logged (via tracing::warn) —
never the matched text — so the log cannot leak the credential.

Implements the team-memory-upload acceptance criteria of #102:
- scan_for_secrets is called before team memory upload
- secret-like content blocks the memory write
- logs do not include matched secret values

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 24, 2026 20:41
@vercel

vercel Bot commented Jun 24, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview Jun 24, 2026 8:41pm

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enforces secret scanning on the team-memory sync upload path by invoking scan_for_secrets during TeamMemorySync::scan_local_files, blocking any .md file that matches a secret pattern from being packed/uploaded. This closes the gap where secret scanning previously existed but was only exercised in tests, not enforced on the upload boundary.

Changes:

  • Add secret scanning enforcement to scan_local_files, skipping secret-bearing files and emitting a warning that includes only labels + path.
  • Add integration-style tests ensuring secret-bearing files are excluded from scan results while clean files still upload.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +365 to +381
// Enforce secret scanning before a file can ever be packed
// for upload. A file with detected secrets is blocked from
// sync entirely. Only the pattern labels and path are
// logged — never the matched text — so the log itself does
// not leak the credential.
let secrets = scan_for_secrets(&content);
if !secrets.is_empty() {
let labels: Vec<&str> =
secrets.iter().map(|m| m.label.as_str()).collect();
warn!(
"Blocking team memory file {:?} from sync: detected {} \
({} secret pattern(s))",
key,
labels.join(", "),
labels.len(),
);
continue;
@BunsDev BunsDev merged commit e2f20a5 into main Jun 24, 2026
2 checks passed
@BunsDev BunsDev deleted the fix/enforce-secret-scan-team-memory branch June 24, 2026 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants