Skip to content

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

Closed
katepallewarprathmesh-sketch wants to merge 1 commit into
alibaba:mainfrom
katepallewarprathmesh-sketch:feat/secret-path-allowlist
Closed

katepallewarprathmesh-sketch wants to merge 1 commit into
alibaba:mainfrom
katepallewarprathmesh-sketch:feat/secret-path-allowlist

Conversation

@katepallewarprathmesh-sketch

Copy link
Copy Markdown
Contributor

Summary

Fixes #1240.

Adds a built-in secret-path exclusion layer so common credential files are not included in review or full-scan prompts by default.

Changes

  • Add embedded patterns for .env, .ssh, SSH private key names, .netrc, .npmrc, .pypirc, and .dockercfg.
  • Apply the secret-path gate to both diff review and full repository scan selection.
  • Run the gate before user include rules so configuration cannot override it.
  • Report the exclusion as secret_exclude.
  • Keep runtime agent tools such as file_read unchanged, matching the agreed scope.

.env.example, .env.sample, and .env.template are not matched by the secret patterns; existing extension filtering remains unchanged for those files.

Validation

Focused tests pass for:

  • internal/config/allowlist
  • internal/model
  • internal/agent
  • internal/scan

The full repository test suite was not run.

Disclosure

This change was investigated and implemented with AI assistance using GitHub Copilot. The generated changes and focused test results were manually reviewed.

@CLAassistant

CLAassistant commented Sep 14, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions

github-actions Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

🔍 OpenCodeReview found 3 issue(s) in this PR.

  • ✅ Successfully posted inline: 3 comment(s)

Comment thread internal/agent/agent.go
Comment on lines +1992 to 1993
case ExcludeUserRule, ExcludeExtension, ExcludeDefaultPath, ExcludeSecretPath:
fmt.Fprintf(stdout.Writer(), "[ocr] Skipping %s — filtered by path/extension rules\n", effectivePath(dec.Diff))

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.

maintainability · medium
The log message "filtered by path/extension rules" is misleading for ExcludeSecretPath. Secret-file exclusion is a security measure, not a path/extension filter. The comment above this switch explicitly warns against silently inheriting the path/extension wording for new reasons, yet ExcludeSecretPath does exactly that.

Consider giving ExcludeSecretPath its own case with a more accurate message, e.g.:

case ExcludeSecretPath:
    fmt.Fprintf(stdout.Writer(), "[ocr] Skipping %s — matches known secret/credential path\n", effectivePath(dec.Diff))

Comment on lines +76 to +78
if allowedext.IsSecretPath(path) {
return ExcludeSecretPath
}

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.

maintainability · medium
ExcludeSecretPath is checked before the user-include gate (lines 85–87), which means an explicit user include rule cannot override this exclusion. This matches the semantics of ExcludeProviderDirectory (which is documented as unconditional), but unlike that constant, ExcludeSecretPath has no comment explaining that it is intentionally immune to user includes.

Consider adding a doc comment on the ExcludeSecretPath constant in internal/model/preview.go similar to the one on ExcludeProviderDirectory, e.g.:

// ExcludeSecretPath is an unconditional exclusion for files matching
// built-in credential-path patterns. Unlike default_path, an include
// rule cannot make the file reviewable.

Without this, a future maintainer may inadvertently move the check below the user-include gate or assume the omission was accidental.

Comment thread internal/scan/agent.go Resolved
@wu21-web

Copy link
Copy Markdown
Contributor

Your solution is not bad, nor concise, there is definitely a way to simplify it.

@katepallewarprathmesh-sketch

Copy link
Copy Markdown
Contributor Author

@wu21-web Thanks for reviewing. I’m happy to simplify the implementation if there’s a cleaner approach.

Could you point me to the specific parts you think can be simplified, or describe the approach you have in mind? I’d like to make sure the implementation stays aligned with the agreed selection-only scope while keeping the secret-path protection unconditional.

Also, if your concern is around the original issue/finding, would you be open to assigning the issue to me? I’m genuinely very interested in contributing to this repository and would be happy to take responsibility for implementing and refining the fix based on your feedback.

@wu21-web

Copy link
Copy Markdown
Contributor

That is what you gotta figure out 🤔

@katepallewarprathmesh-sketch

Copy link
Copy Markdown
Contributor Author

Got it I’ll dig into it and see if I can come up with a cleaner approach while keeping the agreed selection-only scope and the unconditional secret-path protection.

Comment thread internal/model/preview.go
ExcludeUserRule ExcludeReason = "user_exclude"
ExcludeExtension ExcludeReason = "unsupported_ext"
ExcludeDefaultPath ExcludeReason = "default_path"
ExcludeSecretPath ExcludeReason = "secret_exclude"

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.

In your own words without using LLM:
Do you consider secret excludetions as on the same level as all the others?

@katepallewarprathmesh-sketch

Copy link
Copy Markdown
Contributor Author

I don’t think they’re exactly at the same level. Secret exclusions are security-related, so I think they should have higher precedence and shouldn’t be overridden by user include rules. I see the same ExcludeReason type as mainly for representing the exclusion reason, not necessarily the priority.

@lizhengfeng101

Copy link
Copy Markdown
Contributor

@katepallewarprathmesh-sketch

Copy link
Copy Markdown
Contributor Author

CI formatting issue resolved.

Ran gofmt -s -l . successfully with no unformatted files. The affected scan regression tests also pass.

Pushed formatting-only commit 6c3d42a to this PR. No functional changes were made.

@lizhengfeng101

Copy link
Copy Markdown
Contributor

@katepallewarprathmesh-sketch merge conflict,please rebase main

@katepallewarprathmesh-sketch

Copy link
Copy Markdown
Contributor Author

The merge conflict has been resolved.

I rebased feat/secret-path-allowlist onto the latest main and force-pushed the updated branch using --force-with-lease.

The conflict in internal/config/template/scan_template.json was resolved by preserving both the latest main settings and the scan configuration changes.

Validation completed successfully:

  • gofmt -s -l .
  • git diff --check

The PR branch is now updated and ready for CI.

"BATCH_SIZE": 50,
"DEDUP_MIN_COMMENTS": 4
"PLAN_MODE_LINE_THRESHOLD": 200,
"DEDUP_MIN_COMMENTS": 4,

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.

@katepallewarprathmesh-sketch It looks like there are some problems with your merge. Please rebase onto the latest main and separate out the unrelated changes regarding plan-mode and scan thresholds—the current diff overlaps and conflicts with main, and it introduces undeclared changes to scan behavior.

style: format scan coverage test
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]>
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]>
@lizhengfeng101

Copy link
Copy Markdown
Contributor

Thank you for the implementation — it addressed the same problem as #1262 and covered the core requirements from #1240 well.

After reviewing both PRs, I chose to merge #1262 as it had a slightly more complete implementation (rename-path checking, scan-side parity, and localized doc updates).

To credit your contribution, I added you as a co-author in the merge commit:

Co-authored-by: Prathmesh Katepallewar <[email protected]>

Closing this in favor of #1262. Thanks again for the work!

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]>
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

4 participants