-
Notifications
You must be signed in to change notification settings - Fork 16
Add support for SECRET_TYPE_FILTER environment variable to filter secret scanning alerts #77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: felickz <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not make this an input optional, just do it by default.
Instead of modifying the single query for secrets, this will require us to make two api calls.
The first query should remain as is, that will return all the default secret types (this excluedes the list the generic ones).
Then we need to make a second query with the applied filters (just hardcode this list as there is no better way).
Combine both results, there should not be duplicates CURRENTLY for this - there might be scenario in the future where the call without any filters actually does return the secret types for generics. Therefore create a combined (deduped list). If you can easilly detect duplicates, write a warning to the GitHub action output that says to notify the repo owners via an issue to report this duplicate behavior (this means we need to undo this change).
Thanks!
Co-authored-by: felickz <[email protected]>
I've redesigned the implementation per your feedback in commit 14c7226:
The hardcoded generic secret types list includes: password, http_basic_authentication_header, http_bearer_authentication_header, mongodb_connection_string, mysql_connection_string, openssh_private_key, pgp_private_key, postgres_connection_string, rsa_private_key |
Co-authored-by: felickz <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Warn if duplicates were found | ||
if duplicates_found: | ||
print( | ||
f"::warning::Duplicate secret scanning alerts detected in {repo_name}. Please report this behavior via an issue to the repository owners as the API behavior may have changed." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Future proofing this fix in case the generic secrets are eventually returned via the normal API response without any explicit filtering.
This PR adds support for filtering secret scanning alerts by specific secret types using a new
SECRET_TYPE_FILTER
environment variable, as requested in the issue.Changes Made
SECRET_TYPE_FILTER
environment variable support inmain.py
secret_type_filter
parameter:get_repo_ss_alerts()
get_org_ss_alerts()
get_enterprise_ss_alerts()
secret_type
parameter when filtering is requestedREADME.md
to describe the new environment variableUsage
Set the
SECRET_TYPE_FILTER
environment variable with a comma-separated list of secret types:This will filter secret scanning alerts to only include the specified secret types, matching the GitHub API's
secret_type
parameter behavior.Example
The implementation supports the exact filtering pattern mentioned in the issue:
SECRET_TYPE_FILTER="password,http_basic_authentication_header,http_bearer_authentication_header,mongodb_connection_string,mysql_connection_string,openssh_private_key,pgp_private_key,postgres_connection_string,rsa_private_key"
Backward Compatibility
SECRET_TYPE_FILTER
is not set, the behavior remains unchanged (all secret types included)Fixes #76.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.