fix(ghas): Also query generic secret alerts#873
Open
zkdev wants to merge 2 commits into
Open
Conversation
Contributor
📝 WalkthroughWalkthroughThe PR changes GHAS secret alert collection to query default and secret-type alerts with URL-based deduplication, and moves the existing GHAS finding metadata lookup in ChangesGHAS alert processing
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 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 |
Contributor
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 `@src/ghas.py`:
- Around line 186-212: The final log message in the secret alert collection flow
is misleading because the `count` in `ghas.py`’s alert-fetching logic includes
both default and deduplicated generic alerts. Update the `logger.info` text near
the end of the function to describe the total de-duplicated alert count rather
than “default” alerts, and consider switching `seen_urls` in the same function
to a `set` so the duplicate check stays efficient while preserving the existing
`github_api_request_paginated` and `SecretAlert` behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
If not specifying secret-type filter, only default secret alerts are returned. To also fetch generic secret alerts, their secret-types have to be explicitly requested. see: https://docs.github.com/en/rest/secret-scanning/secret-scanning?apiVersion=2022-11-28#list-secret-scanning-alerts-for-an-organization > A comma-separated list of secret types to return. All default secret patterns are returned. To return generic patterns, pass the token name(s) in the parameter Signed-off-by: Philipp Heil (zkdev) <philipp.heil@sap.com>
useful for local testing, as one might not need the ODG metadata. Signed-off-by: Philipp Heil (zkdev) <philipp.heil@sap.com>
3fe3c2b to
4dddb9b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it:
Currently, the GHAS extension does only filter for "default" secret alerts.
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Release note: