Sub topic 9
Working through secret scanning alerts
This chapter assumes you know basic Git, can open a repository's settings on GitHub, and understand what API keys and tokens are. It also assumes that secret scanning is already enabled on the repository. You will learn how to read an alert, decide what to do first, and close it with an accurate reason.
What an alert tells you
Secret scanning creates one alert for each distinct secret it finds. If the same token appears in ten files, you still get one alert with several locations. Open the Security tab and choose Secret scanning to see the list.
Each alert shows:
- The secret type, such as a cloud provider key or a payment token.
- The locations where the secret was found: commits, files, issues, pull requests or wikis.
- Whether the secret was detected after a push-protection bypass.
- A validity status, when GitHub can check one for that secret type.
An alert is not a verdict that someone did something wrong. It means a credential is exposed to everyone who can read that content. Triage decides how urgent it is.
A triage order that works
Work through open alerts in this order:
- Alerts marked active by validity checks. These credentials still work.
- Alerts that were created after a push-protection bypass. Someone chose to push the secret.
- Alerts in public repositories or in content many people can read.
- Alerts of unknown validity, then alerts marked inactive.
Revoke first, then close the alert. Closing an alert does not make a credential safe.
Choosing a resolution reason
When you close an alert, GitHub asks for a reason. The reason is a record that other people rely on, so pick the one that is true.
| Resolution | Use it when |
|---|---|
| Revoked | The credential was revoked at its provider. |
| False positive | The match is not a credential. |
| Used in tests | The value is a dummy used for testing. |
| Won't fix | You accept the risk and will not act. |
Choosing Revoked before you actually revoke the credential is the most common mistake. Anyone who reads the closed alert later will assume the exposure is over.
Listing and resolving alerts with the CLI
You can do the same work from a terminal. This command lists open alerts and prints the fields you need for triage:
gh api 'repos/OWNER/REPO/secret-scanning/alerts?state=open' \
--jq '.[] | {number, secret_type_display_name, validity, push_protection_bypassed}'After you have revoked the credential for alert 42, close it:
gh api --method PATCH repos/OWNER/REPO/secret-scanning/alerts/42 \
-f state=resolved \
-f resolution=revokedReplace OWNER/REPO with your repository. You need permission to manage secret scanning alerts on it.
Common errors
- Closing as revoked too early. Revoke at the provider first.
- Ignoring alerts with unknown validity. Not every secret type supports validity checks, so "unknown" does not mean "safe".
- Treating one alert as one location. Check every location listed, because the same secret may live in old branches or in an issue comment.
- Resolving noise one alert at a time. If dummy values keep triggering alerts, exclude the paths instead. A later chapter covers this.
Exercise
Alert 17 shows an active AWS key found in a file on a private repository. A teammate suggests closing it as "revoked" now and rotating the key tomorrow. What should you do instead, and why?
Show answer
Revoke the key at the provider first, then rotate it and update everything that uses it, and only then close the alert as revoked. The key is active, so it can still be used. Closing the alert early records a false statement and hides an open exposure from other reviewers.