fix: reduce public content token false positives - #1718
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 (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThis PR extends public-content credential scanning with entropy-based weak token classification and file-aware placeholder handling, while broadening fixture/testdata allowances for credential URL and private IPv4 warnings. Tests were added and updated to cover the new behavior. ChangesCredential/token detection refinement
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Suggested labels: 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 #1718 +/- ##
==========================================
- Coverage 74.51% 74.50% -0.01%
==========================================
Files 852 852
Lines 87655 87755 +100
==========================================
+ Hits 65312 65379 +67
- Misses 17315 17347 +32
- Partials 5028 5029 +1 ☔ 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@8f79c5eed32cb575526b0990df994a3d80cc093c🧩 Skill updatenpx skills add larksuite/cli#fix/public-content-resource-token-placeholders -y -g |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 996-1000: The sourceOrTestFixtureFile helper only recognizes
"/fixtures/" and "/testdata/" paths, so root-level fixtures can slip through and
trigger false positives. Update sourceOrTestFixtureFile in scan.go to also treat
files that start with fixtures/ or testdata/ as fixtures, alongside the existing
sourceCodeFile checks and path containment logic. Use the existing
sourceOrTestFixtureFile function and filepath.ToSlash handling so all fixture
locations are covered consistently.
🪄 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: 0a45caaa-f5eb-4d15-be23-d1ba158919dd
📒 Files selected for processing (2)
internal/qualitygate/publiccontent/scan.gointernal/qualitygate/publiccontent/scan_test.go
2a4f0ed to
8f79c5e
Compare
Summary
Reduce false positives in public-content scanning by treating weak token-like fields, fixture credential URLs, and private IP fixtures with more precise evidence checks.
Changes
public_content_generic_credentialrejects weak token-like fields such astoken,image_token, and resource-style*_tokenfields.access_token,api_token,service_token,bot_token, andsecret_tokenrejected.Test Plan
/opt/homebrew/bin/go test ./internal/qualitygate/publiccontent ./internal/qualitygate/rules ./internal/qualitygate/cmd/quality-gate -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
Summary by CodeRabbit