| name | secret-scanning |
| description | Guide for configuring and managing GitHub secret scanning, push protection,
custom patterns, and alert remediation. Use when:
- Enabling or configuring secret scanning for a repository
- Setting up push protection to block secrets before push
- Defining custom secret patterns with regular expressions
- Resolving a blocked push from the command line
- Triaging or remediating secret scanning alerts
|
Secret Scanning
Procedural guidance for configuring GitHub secret scanning — detecting leaked credentials, preventing secret pushes, defining custom patterns, and managing alerts.
Core Workflow — Enable Secret Scanning
Step 1: Enable Secret Protection
- Navigate to repository Settings → Advanced Security
- Click Enable next to "Secret Protection"
- Confirm by clicking Enable Secret Protection
For organizations, use security configurations to enable at scale.
Step 2: Enable Push Protection
Push protection blocks secrets during the push process — before they reach the repository.
- Settings → Advanced Security
- Enable "Push protection" under Secret Protection
Blocks secrets in: command line pushes, GitHub UI commits, file uploads, REST API requests.
Step 3: Configure Exclusions (Optional)
Create .github/secret_scanning.yml:
paths-ignore:
- "docs/**"
- "test/fixtures/**"
- "**/*.example"
Limits: max 1,000 entries, file must be under 1 MB. Excluded paths also skip push protection.
Step 4: Enable Additional Features (Optional)
- Non-provider patterns: Detect private keys, connection strings, generic API keys
- AI-powered generic detection: Uses Copilot to detect unstructured secrets
- Validity checks: Verify if detected secrets are still active (shows
active, inactive, unknown)
Resolving Blocked Pushes
Option A: Remove the Secret
Latest commit:
git commit --amend --all
git push
Earlier commit:
git log
git rebase -i <COMMIT-ID>~1
git add .
git commit --amend
git rebase --continue
git push
Option B: Bypass Push Protection
- Visit the URL returned in the push error
- Select bypass reason: "used in tests", "false positive", or "I'll fix it later"
- Click Allow me to push this secret
- Re-push within 3 hours
Option C: Request Bypass Privileges
If delegated bypass is enabled and you lack privileges:
- Visit the URL from the push error
- Add a comment explaining why
- Submit request and wait for approval
Custom Patterns
Define organization-specific patterns using regular expressions:
- Settings → Advanced Security → Custom patterns → New pattern
- Enter pattern name and regex
- Add test string, click Save and dry run (up to 1,000 results)
- Review for false positives
- Publish pattern
- Optionally enable push protection for the pattern
Custom patterns can be defined at repository, organization, or enterprise level.
Alert Management
Alert Types
| Type | Description |
|---|
| User alerts | Secrets found in repository — visible in Security tab |
| Push protection alerts | Secrets pushed via bypass (filter: bypassed: true) |
| Partner alerts | Secrets reported to provider (not shown in repo) |
Remediation Priority
- Rotate the credential immediately — this is the critical action
- Review the alert for context (location, commit, author)
- Check validity status:
active (urgent), inactive (lower priority)
- Remove from Git history if needed (often unnecessary after rotation)
Dismissing Alerts
Dismiss with a documented reason: False positive, Revoked, or Used in tests.
Project Context
This project follows these security rules (see .github/instructions/security.instructions.md):
- Never commit secrets, connection strings, API keys, or tokens
- Use Azure Managed Identity for all service-to-service auth
- Use Key Vault references where managed identity isn't available
.env files are gitignored — they contain local dev credentials from azd -C infra/azure env get-values