Repository navigation
feat(allowlist): protect per-environment .env files - #1279
Conversation
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 2 selected item(s). |
| envTemplate := isEnvTemplate(lowerPath) | ||
| for _, pattern := range secretPatterns { | ||
| // Template names are exempt only from the broad .env.* rule. | ||
| if envTemplate && pattern == "**/.env.*" { |
There was a problem hiding this comment.
@hyy321 There is an implicit string-based coupling between the Go code and the JSON; this implementation is prone to errors.
There was a problem hiding this comment.
I’ll remove the dependency on the literal JSON pattern and handle per-environment .env.* paths directly in the matcher. Existing secret patterns will still use the JSON-based matching path, so template exceptions won’t bypass rules such as .ssh/**.
There was a problem hiding this comment.
Updated. The .env family is now handled directly by the matcher, and the .env patterns have been removed from default_secret_patterns.json. The JSON list now only contains unconditional secret-path globs, so there is no longer a literal dependency between the Go logic and the JSON patterns. Template paths still fall through to the remaining rules, so cases such as .ssh/.env.example remain protected.
There was a problem hiding this comment.
I’ll remove the dependency on the literal JSON pattern and handle per-environment .env.* paths directly in the matcher. Existing secret patterns will still use the JSON-based matching path, so template exceptions won’t bypass rules such as .ssh/**.
| "**/.env", | ||
| "**/.env.local", | ||
| "**/.env.*.local", | ||
| "**/.env.*", |
There was a problem hiding this comment.
| "**/.env.*", | |
| "**/*.env.*", |
Use this so that doesn't omit config.env.example, which is also common.
There was a problem hiding this comment.
This is addressed by the latest change. The .env family is no longer matched through a JSON glob and is handled directly by the matcher instead, so this pattern replacement no longer applies.
|
@hyy321 CI / test (pull_request)Failing after 4m |
I traced the failure to TestCloseAll_TimeoutPreservesCollectedErrors in internal/mcp. This PR does not touch the MCP package. I also ran the same CI command locally successfully, and the failing test passes 3 consecutive runs with -race. The surrounding stress tests already account for -race timing differences, so this looks like a timing-sensitive flake. I don't appear to have permission to rerun the failed job; could you rerun it? |
* feat(allowlist): protect per-environment .env files * fix(allowlist): decouple env secret matching
…m rules The v1.12.9 merge passed build, vet and the full test suite, yet the branch-only coreFilterReason still lacked the secret-path gate upstream added in alibaba#1262/alibaba#1279. Both parity tables only knew the old cases, so they stayed green until matching secret cases were added. Record the procedure: diff upstream's source-of-truth filter and allowlist data across the tag range, add parity cases for each new branch first and check that only the copy fails, pick fixture paths that no built-in list covers, and diff the merge result against the upstream tag to catch resurrected dead code such as executePlanPhase. CONCEPTS.md: refine Exclude Reason (secret, provider-directory and too-large reasons now exist), File Filter (include cannot admit credential paths or provider directories) and Review parity (tests assert only the cases they list). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Description
This PR extends the built-in secret-path protection added in #1262 to cover common per-environment files such as
.env.production,.env.staging, and.env.development.The existing
.env.localand.env.*.localpatterns are replaced by the broader.env.*pattern..env.example,.env.sample, and.env.templateremain exempt from that rule so committed template files can still be reviewed normally.The template exception applies only to the
.env.*rule and does not bypass other secret-path protections. For example,.ssh/.env.exampleis still excluded by the existing.ssh/**rule.The existing
secret_excludeprecedence and review/scan selection behavior remain unchanged. The localized review-rules documentation has also been updated to describe the template exceptions.Type of Change
How Has This Been Tested?
make testpasses locallyAdditional validation:
go test -run TestIsSecretPath -count=1 ./internal/config/allowlistgo test ./internal/config/allowlistmake checkmake buildgit diff --cached --checkdeepseek-v4-pro: 0 findings across 2 selected itemsTests cover per-environment
.env.*paths, template exceptions, case-insensitive matching, and ensure template exceptions do not bypass other secret-path rules.Checklist
go fmt,go vet)AI/LLM Disclosure
AI/LLM tools were used during implementation and review.
Tools: Codex and OpenCodeReview.
OCR self-review model:
deepseek-v4-pro.I reviewed the final implementation, diff, and test results before submission.
Related Issues
Closes #1265
Follow-up to #1262