open-code-review icon indicating copy to clipboard operation
open-code-review copied to clipboard

feat(allowlist): cover per-environment .env.* files in secret-path protection

Open hyy321 opened this issue 2 months ago • 1 comments

Problem Statement

#1240 adds built-in secret-path protection for .env, .env.local, and .env.*.local, but common per-environment files such as .env.production, .env.staging, and .env.development are still not covered.

These files are commonly used for environment-specific configuration and may contain real secrets, so they should receive the same protection as the existing .env patterns.

This was identified as a non-blocking follow-up during review of #1262.

Proposed Solution

Extend the built-in secret-path matching to cover .env.*, while keeping common committed template files reviewable.

For example:

  • Exclude .env.production
  • Exclude .env.staging
  • Exclude .env.development
  • Keep .env.example reviewable
  • Keep .env.sample reviewable
  • Keep .env.template reviewable

The existing secret-path behavior should stay the same:

  • Matches are reported as secret_exclude.
  • User include rules cannot override the protection.
  • The change remains limited to review/scan selection.
  • Agent runtime tools and content-based secret detection remain out of scope.

Alternatives Considered

Matching .env.* without exceptions would also exclude committed template files such as .env.example, .env.sample, and .env.template. Keeping the current patterns unchanged avoids those false positives but leaves common .env.<environment> files unprotected.

Affected Area

Review Rules

Additional Context

No response

hyy321 avatar Sep 15 '26 09:09 hyy321

Hi @lizhengfeng101, now that #1262 has been merged, I’d be happy to take this follow-up if the direction above looks good. My plan is to extend the built-in .env.* matching while explicitly keeping .env.example, .env.sample, and .env.template reviewable. I’ll keep the existing secret_exclude precedence and review/scan scope unchanged, and add focused tests for both protected per-environment files and the template exceptions.

hyy321 avatar Sep 15 '26 11:09 hyy321