Skip to content

feat(allowlist): exclude secret paths from review - #1262

Merged
lizhengfeng101 merged 2 commits into
alibaba:mainfrom
hyy321:fix/secret-path-selection
Sep 15, 2026
Merged

lizhengfeng101 merged 2 commits into
alibaba:mainfrom
hyy321:fix/secret-path-selection

Conversation

@hyy321

@hyy321 hyy321 commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR adds built-in path-based protection for common secret files such as .env, SSH private keys, .netrc, .npmrc, .pypirc, and .dockercfg.

The secret-path patterns are kept separate from the existing default exclude patterns because they have different precedence: default excludes can be overridden by an include rule, while secret paths cannot.

Both review and scan apply the secret-path check before user include/exclude rules and report matches as secret_exclude. For review diffs, both OldPath and NewPath are checked so a rename from a protected path to an allowed path cannot expose content from the protected source path.

Agent runtime tools are intentionally left unchanged, following the scope discussed in #1240.

Known limitation: This PR keeps the secret patterns scoped to #1240, so files such as .env.production, .env.staging, and .env.development are not covered yet. Broader .env.* coverage is tracked in #1265.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Refactoring (no functional changes)
  • Documentation update
  • CI / Build / Tooling

How Has This Been Tested?

  • make test passes locally
  • Manual testing (describe below)

Additional validation:

  • make check
  • make build
  • git diff --check upstream/main...HEAD
  • Local OCR self-review with deepseek-v4-pro: 0 findings across 7 selected items

Tests cover secret-path matching, include/exclude precedence, rename handling, logging, and review/scan selection behavior.

Checklist

  • My code follows the project's coding style (go fmt, go vet)
  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or my feature works
  • New and existing unit tests pass locally with my changes
  • I have updated the documentation accordingly (if applicable)
  • I have signed the CLA

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 changes and test results before submission.

Related Issues

Closes #1240

Follow-up: #1265

@github-actions

Copy link
Copy Markdown
Contributor

✅ OpenCodeReview: Review complete: 0 finding(s) across 7 selected item(s).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have all these workarounds here, because in my solution these are just no allowed (not even supported), so they are excluded at first.
This is my way of solving this problem. Just asking, thanks!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for asking. I followed the design in #1240 here. I kept the secret-path check separate from the extension allowlist so files like Dockerfile and Makefile keep their current behavior.
Secret paths are different because include rules shouldn't be able to make them reviewable again, and they need their own secret_exclude reason. #1240 also discussed handling dotfiles through the extension path, but that would change the existing extensionless-file behavior.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I didn't read the issue. My bad. I will speak to the maintainer.

@lizhengfeng101

lizhengfeng101 commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

@hyy321 Thanks — the implementation is clean and the rename/OldPath handling and dedicated log wording are nice touches. Two non-blocking points before merge:

1. .env.production / .env.staging blind spot (most important)

The patterns cover .env, .env.local, and .env.*.local, but not per-environment files like .env.production or .env.development — which are just as common and just as likely to hold real secrets. This is a faithful, conservative reading of the issue (avoiding false positives on .env.example), so it need not block this PR, but it is the largest real-world gap. Suggested:

  • Call out the limitation explicitly in the PR / merge notes.
  • Open a follow-up that switches to a denylist approach: match .env.* while excluding .example / .sample / .template, so .env.<env> is covered.

2. Missing documentation

pages/src/content/docs/*/review-rules.md does not mention secret_exclude at all — users who see that reason in --preview have no way to know what it means. Please add at least a line explaining it is a built-in protection that include cannot override.

  • Note: this PR touches no .md. If you add docs, put them in review-rules.md for each locale — do not touch README, or you will trigger the multi-language README sync requirement in CLAUDE.md. docs/i18n/README.* stays out of scope.

@hyy321

hyy321 commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

@hyy321 Thanks — the implementation is clean and the rename/OldPath handling and dedicated log wording are nice touches. Two non-blocking points before merge:

1. .env.production / .env.staging blind spot (most important)

The patterns cover .env, .env.local, and .env.*.local, but not per-environment files like .env.production or .env.development — which are just as common and just as likely to hold real secrets. This is a faithful, conservative reading of the issue (avoiding false positives on .env.example), so it need not block this PR, but it is the largest real-world gap. Suggested:

  • Call out the limitation explicitly in the PR / merge notes.
  • Open a follow-up that switches to a denylist approach: match .env.* while excluding .example / .sample / .template, so .env.<env> is covered.

2. Missing documentation

pages/src/content/docs/*/review-rules.md does not mention secret_exclude at all — users who see that reason in --preview have no way to know what it means. Please add at least a line explaining it is a built-in protection that include cannot override.

  • Note: this PR touches no .md. If you add docs, put them in review-rules.md for each locale — do not touch README, or you will trigger the multi-language README sync requirement in CLAUDE.md. docs/i18n/README.* stays out of scope.

Thanks, that makes sense. I’ll keep the current secret patterns scoped to #1240, note the .env. limitation in the PR, and open a follow-up issue for broader .env.* coverage. I’ll also add an explanation of secret_exclude to the localized review-rules.md files.

@lizhengfeng101

Copy link
Copy Markdown
Contributor

Thanks, that makes sense. I’ll keep the current secret patterns scoped to #1240, note the .env. limitation in the PR, and open a follow-up issue for broader .env.* coverage. I’ll also add an explanation of secret_exclude to the localized review-rules.md files.

@hyy321 Will you add an explanation regarding secret_exclude to the current PR?

@hyy321

hyy321 commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, that makes sense. I’ll keep the current secret patterns scoped to #1240, note the .env. limitation in the PR, and open a follow-up issue for broader .env.* coverage. I’ll also add an explanation of secret_exclude to the localized review-rules.md files.

@hyy321 Will you add an explanation regarding secret_exclude to the current PR?

Yes, I’ll include that in the current PR. I’m updating the localized review-rules.md files to explain secret_exclude and that include cannot override it.

@hyy321

hyy321 commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

I’ve added it to the current PR. The localized review-rules.md files now explain secret_exclude, including that it is a built-in protection that include cannot override.

@lizhengfeng101 lizhengfeng101 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lizhengfeng101
lizhengfeng101 merged commit 7086729 into alibaba:main Sep 15, 2026
21 of 24 checks passed
lizhengfeng101 pushed a commit that referenced this pull request Sep 15, 2026
* feat(allowlist): exclude secret paths from review

* docs(review-rules): document secret exclusions

Built on the security finding by @wu21-web and the initial implementation in #1244 by @katepallewarprathmesh-sketch.

Co-authored-by: Prathmesh Katepallewar <[email protected]>
Co-authored-by: Tao Xin <[email protected]>
@hyy321
hyy321 deleted the fix/secret-path-selection branch September 16, 2026 07:55
Githab-capibara added a commit to Githab-capibara/open-code-review that referenced this pull request Sep 17, 2026
* feat(allowlist): exclude secret paths from review

* docs(review-rules): document secret exclusions

Built on the security finding by @wu21-web and the initial implementation in alibaba#1244 by @katepallewarprathmesh-sketch.

Co-authored-by: Prathmesh Katepallewar <[email protected]>
Co-authored-by: Tao Xin <[email protected]>
kall added a commit to kall/open-code-review that referenced this pull request Sep 28, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(allowlist): exclude extensionless and dotfile secrets (.env, id_rsa, .netrc) from review by default

3 participants