fix: reduce public content credential false positives - #1700
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughThis PR expands placeholder detection in ChangesPublic content credential scanner refinements
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1700 +/- ##
==========================================
+ Coverage 74.48% 74.51% +0.03%
==========================================
Files 850 850
Lines 86703 86895 +192
==========================================
+ Hits 64583 64753 +170
- Misses 17175 17188 +13
- Partials 4945 4954 +9 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@0e095ef9488603bd3dd61a2c56c483bb8db5a13c🧩 Skill updatenpx skills add larksuite/cli#fix/public-content-python-type-annotation -y -g |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/qualitygate/publiccontent/scan.go`:
- Around line 298-314: The maskedTokenFixturePlaceholderValue exemption is too
broad and hides partially masked real tokens, so tighten it to only recognize
explicit fixture markers or stronger context instead of any alnum-plus-asterisk
value with six stars. Update maskedTokenFixturePlaceholderValue in scan.go to
stop exempting bare generic token keys like token=ab********cd, and keep the
authCredentialTokenKey() path unchanged for real auth credentials. Add a
regression test covering a bare token key to ensure partially masked secrets
still produce public_content_generic_credential findings.
- Around line 401-403: The plus-concatenation shortcut in the scan logic is too
broad and hides literal-only secrets. Update the `strings.Contains(match, "+")`
handling in the relevant `scan.go` check so it only treats concatenations as
safe when they involve identifiers or references, not string literals. Use the
existing match/parsing logic in this path to distinguish `"real-" +
"secret-value"` from variable-based expressions, and add a regression test
covering concatenated string literals to ensure they still get flagged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 2fe30a45-6b04-4fca-ac69-d209155873a2
📒 Files selected for processing (3)
internal/qualitygate/publiccontent/rules.gointernal/qualitygate/publiccontent/scan.gointernal/qualitygate/publiccontent/scan_test.go
35de911 to
2cca6c9
Compare
2cca6c9 to
0e095ef
Compare
Summary
Reduce false positives in the public-content generic credential detector by classifying source-code credential candidates with value and context evidence. This fixes Python token-kind typed state fields while preserving detection for real credential-shaped source literals, typed assignments, numeric secrets, and partially masked credentials.
Changes
internal/qualitygate/publiccontent/scan.goto treat source-code credential candidates as contextual findings, including typed RHS parsing for Python and TypeScript declarations.internal/qualitygate/publiccontent/rules.goto narrow placeholder handling for masked values and printf placeholders.internal/qualitygate/publiccontent/scan_test.gofor false-positive controls, real leak controls, typed assignments, masked credentials, and format-string boundaries.Test Plan
make unit-testnot run; scoped qualitygate verification was used for this detector-only change./opt/homebrew/bin/go test ./internal/qualitygate/publiccontent -count=1/opt/homebrew/bin/go test ./internal/qualitygate/... -count=1/opt/homebrew/bin/go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.1.6 run --new-from-rev=upstream/main ./internal/qualitygate/publiccontent/...PATH=/opt/homebrew/bin:$PATH make quality-gate QUALITY_GATE_CHANGED_FROM=upstream/mainRelated Issues
N/A
Summary by CodeRabbit
Bug Fixes
Tests