feat(indexing,security): add exclude_patterns + built-in secret denylist#226
Merged
feat(indexing,security): add exclude_patterns + built-in secret denylist#226
Conversation
…ist (#225) Files matching supported_extensions inside auto-discovered memory_dirs were indexed without filtering, including credential files in well-known AI tool directories and tool-generated metadata. Add a two-tier exclude system: - _BUILTIN_SECRET_PATTERNS and _BUILTIN_NOISE_PATTERNS (module constants, always applied; user negation cannot override). - IndexingConfig.exclude_patterns (user-configurable, gitignore syntax via pathspec, evaluated as a separate PathSpec so built-in invariants hold regardless of user config). Case-insensitive matching via lowercase on both pattern and candidate. Directory-level denylist extended with .aws, .ssh, .gnupg. mm purge --matching-excluded scans storage for already-indexed files matching the current exclude set; dry-run default, --apply to delete. Registered via MUTABLE_FIELDS + FIELD_CONSTRAINTS so CLI/MCP/future Web UI share one validation path. Closes #225 (Web UI editor is a follow-up). Generated with Claude Code. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements PR (a) of #225. Adds a two-tier exclude system for indexing:
_BUILTIN_SECRET_PATTERNS(oauth_creds.json,credentials*,id_rsa*,*.pem,*.key,.ssh/**) and_BUILTIN_NOISE_PATTERNS(.claude/**/*.meta.json) are always applied;user config cannot disable or negate them.
IndexingConfig.exclude_patterns: list[str](gitignore syntax via
pathspec). Registered inMUTABLE_FIELDS+FIELD_CONSTRAINTSso CLI (mm config set), MCP (mem_config), and thefuture Web UI share one validation path.
PathSpecinstances — a user!negationonly affects the user spec, so security invariants holdregardless of user config.
_EXCLUDED_DIRSextended with.aws,.ssh,.gnupgfor directory-level secret stores.
New CLI
Scans
storage.get_all_source_files()against the current exclude set(built-in + user) and deletes matching chunks via
delete_by_source.Needed because the denylist applies retroactively only to new indexing
runs — existing chunks for secret files would otherwise remain.
Scope notes
mm mem purge, but theexisting CLI is flat (
mm add,mm recall,mm reset, ...) with nomemsubgroup. Registered asmm purgeto match conventions.Functionally identical.
settings-config.js,.gitignorefile discovery.Test plan
uv run ruff check packages/memtomem/src packages/memtomem/testsuv run ruff format --check packages/memtomem/src packages/memtomem/testsuv run pytest -m "not ollama"— 1575 passed, 46 deselected!**/oauth_creds.jsoncannot unsetbuilt-in secret patterns
.aws/.ssh/.gnupgexcludedmm purge --matching-excludeddry-run does not delete;--applycallsdelete_by_sourcemm purge --matching-excludedagainst a dev DB with existingClaude Code subagent meta chunks — verify sample output and
--applyremoval.
Migration note (in CHANGELOG)
Existing users with auto-discovered AI tool directories in
memory_dirsshould run
mm purge --matching-excludedto clean up chunks that predatethis change. Without it, credential chunks already stored remain
searchable and exportable.
Closes #225 (PR (a)).