AntFleet

Disagreement · d9ae4fa5-anthropic-6

isDotEnv regex matches paths like 'env.local' or '.environment' falsely / misses real .env files

solo Opus
repo 56f59a0d·PR #3·reviewed 4 days ago

Opus finding

isDotEnv regex matches paths like 'env.local' or '.environment' falsely / misses real .env files

mediumbughigh
  • src/ci/rules.ts:16-22
The regex /(^|\/)\.env(?:\.|$)/i requires a literal '.env' segment followed by '.' or end-of-string. This is mostly correct but it also matches '.env.example' first via the substring '.env.', which is then rescued only because isEnvExample is checked. However it MISSES common variants like '.env_local' or 'envfile' (those shouldn't match anyway), and it FAILS to match '.environment' files (those also shouldn't match — good). The real bug: '.env.example.bak' would be classified as a real dotenv because isEnvExample requires the path to END with .env.example. Backup/copy files of env examples will be flagged as 'high severity secret file' incorrectly. Conversely, '.env.production' is correctly flagged. The bigger concern is that a file literally named '.env' (no extension) matches the pattern via the '$' branch — good — but a file named 'env' (no leading dot) doesn't match — good. Overall: '.env.example~', '.env.sample.bak', or editor swap files like '.env.example.swp' would all be flagged as 'high' dotenv leaks falsely.

Recommendation

Either tighten isEnvExample to allow trailing suffixes (~, .bak, .swp) or extract the basename and match exact filenames.

Other reviewer

The other reviewer flagged nothing in this file/line range.

Why this didn't post

This finding didn't meet AntFleet's unanimous agreement threshold. Both frontier models review every PR independently; only findings they both flag with the same severity and category are posted to the PR. This one fell through.

read the methodology →