Exclude sensitive files from context packs, enforce provider network policy, add CI cleanliness check, and harden tests#1
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces security enhancements to prevent sensitive files (such as .env, keys, and certificates) from being included in context packs, and enforces network access policies for providers like Ollama. It also refactors the smoke tests to use a FileGuard helper for robust, automatic file cleanup. Feedback on the changes highlights that checking if a filename contains the substring "key" is overly broad and will lead to false positives on harmless files (e.g., keyboard.rs), suggesting a more refined matching logic instead.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| || file_name.contains("key") | ||
| || file_name.contains("credential") |
There was a problem hiding this comment.
Using file_name.contains("key") is extremely broad and will cause false positives by matching common non-sensitive filenames containing the substring "key" (e.g., keyboard.rs, key_value.rs, monkey.rs, donkey.rs, keyring.rs, keychain.rs). This would silently exclude these files from the context pack, leading to incomplete context for the LLM.
By refining the check to target specific patterns like api_key, apikey, secret, token, and exact matches for key or keys, we significantly reduce false positives while still catching actual sensitive files.
|| file_name.contains("api_key")
|| file_name.contains("apikey")
|| file_name.contains("secret")
|| file_name.contains("token")
|| file_name.contains("credential")
|| matches!(file_name, "key" | "keys")
Motivation
Description
is_sensitive_context_pathto detect filenames like.env, key/cert files, and common credential names and skip them when building a context pack.ensure_provider_network_allowedand call it forollamain bothhandle_askandhandle_proposeflows to enforceconfig.policy.allow_provider_networkand per-providernetworkflags before executing networked providers.build_context_packto exclude sensitive filename patterns and add related patterns toexcluded_filesso generated packs omit secrets and private keys.Clean treein.github/workflows/ci.ymlthat runsgit diff --exit-code && git diff --cached --exit-codeto detect dirty working trees after tests.tests/cli_smoke.rsby introducingFileGuardto preserve/restore filesystem artifacts, renaming and adjusting tests to assert network-denied behavior for Ollama, and update proposal/apply tests to use guarded temporary files and updated assertions.Testing
cargo fmt --all --check,cargo check, andcargo test, and the test suite completed successfully.tests/cli_smoke.rswhich includes the updatedask,propose,apply, andvalidatescenarios and they passed under the updated assertions.Clean treecheck which will fail if tests leave unstaged or staged modifications in the working tree.Codex Task