Repository navigation
fix(discover): never index secret-bearing files by default - #2794
syaifulizhan wants to merge 2 commits into
Conversation
Tracked .env files, private keys and credential files were indexed like any source file, so their contents reached search_code and get_code_snippet and were served to AI agents. Discovery now skips them in every index mode (reason "secret-file"); templates such as .env.example stay indexable. Opt in with `config set index_secret_files true`. The key is part of the index policy, so it is validated, listed by `config list`, and carried to the index worker and daemon with the other policy values. Signed-off-by: syaifulizhan <286102471+syaifulizhan@users.noreply.github.com>
|
Thanks for opening this — it has been seen, and it is queued. This note is automated, but it is not a brush-off: it exists so you know where your PR stands instead of having to guess from silence. Current review status: working through a backlog. What that means for this PR, concretely:
Things that will genuinely speed it up whenever review does happen:
If this fixes a bug, a reproduction we can run is worth more than a description of the symptom. Thanks for contributing, and sorry in advance for the wait. |
Signed-off-by: syaifulizhan <286102471+syaifulizhan@users.noreply.github.com>
|
Thank you so much for this, @syaifulizhan, and for filing #2793 with a clear repro. Keeping credentials out of agent context is exactly the right instinct, and the policy plumbing (validation, config list, worker propagation) follows our existing index_max_files design nicely. Because this changes what gets indexed by default (DotEnv nodes, compose .env change detection, Helm secrets.yaml templates) and relates to #1079, the maintainer is deciding the default and the scope first. We will follow up here shortly with a concrete direction. |
What does this PR do?
Closes #2793.
Motivation
Tracked
.envfiles, private keys and credential files are currently indexed like anysource file. Their contents then reach the graph and are served to AI agents through
search_codeandget_code_snippet. Indexing a repository should not turn it into achannel for its own secrets.
What changes
Discovery skips secret-bearing files in every index mode (reported with reason
secret-filein the ignored-files list):.env,.env.*,*.env*.pem,*.key,*.p12,*.pfx,*.jks,*.keystoreid_rsa*,id_dsa*,id_ecdsa*,id_ed25519*.npmrc,.pypirc,.netrc,.git-credentials,.htpasswdcredentials.json,service-account.json,secrets.json,secrets.y(a)mlTemplates (
.env.example,.env.sample,.env.template,.env.dist) stay indexed:they document configuration without carrying it.
Opt-in
New config key
index_secret_files(defaultfalse):It is part of the existing index policy, so it is validated like
index_max_files, shown inconfig list, and carried to the index worker and daemon with the other policy values.Users who want
.envfiles in the graph (for example for compose${VAR}resolution, or theDotEnv grammar) can enable it explicitly.
Behaviour note
.envwas previously indexed by default; three existing tests assumed that (compose.envinterpolation, two DotEnv probes). They now opt in via the policy or assert the new default.
Tests
secret_filename_classification,discover_skips_secret_files_by_default,discover_indexes_secret_files_when_opted_in(tests/test_discover.c)index_policy_secret_files_defaults_off_and_round_trips,index_policy_secret_files_config_key_is_loaded(tests/test_index_policy.c)incremental_compose_dotenv_change_rebuilds,probe_dotenv_module_only,probe_dotenv_local_suffixDocs
docs/CONFIGURATION.md(key table) and the README config examples.Known limit: the non-git watcher's file-tree scan (
inventory_filter) does not poll secretfiles in either setting.
Checklist
git commit -s)discover,index_policy,pipeline,grammar_probe_g: 606 passed)