Conversation
…ning Add a new policy that checks whether GitHub's secret scanning feature is enabled on repositories. Secret scanning monitors repos for known secret formats (API keys, tokens, credentials) and generates alerts when detected. New files: - pkg/policies/secretscanning/secretscanning.go - policy implementation - pkg/policies/secretscanning/secretscanning_test.go - unit tests The policy follows the same pattern as the existing SECURITY.md policy: - Uses the GitHub REST API (Repository.SecurityAndAnalysis.SecretScanning) - Supports org-level and repo-level configuration via secret_scanning.yaml - Supports log/issue/fix actions (fix not yet implemented) - Registered in pkg/policies/policies.go Fixes ossf#363 Signed-off-by: Ali <ali@kscope.ai>
a8008e3 to
a943c9e
Compare
|
Hi, thanks for the contribution. This looks like it would work. |
|
Also, since this is a simple toggle, it should be trivial to go ahead and add the "fix" action to turn on the setting if not already on. |
Two follow-ups from review: 1. Implement Fix(): call Repositories.Edit with SecurityAndAnalysis.SecretScanning set to "enabled" so the action can automatically turn on secret scanning on non-compliant repos. 2. Add a Secret Scanning section to README.md alongside the other policy descriptions. Signed-off-by: alliasgher <alliasgher123@gmail.com>
|
For the live test: the Fix implementation and check logic are covered in the unit tests, but running against real repos requires the allstar app credentials/installation which I don't have access to. Is there a staging org or test environment I can use? Alternatively, if you have access you could point a test installation at a repo with secret scanning disabled and confirm the issue is created correctly. |
Go ahead and try this please. Create a GitHub App and install it on a repo without secret scanning enabled, then run the Allstar code from your branch against that repo using the GitHub App credentials you created. |
|
@jeffmendoza Tested against https://github.com/alliasgher/allstar-test with secret scanning disabled. Check result (scanning disabled): Fix action ( Check result after Fix: |
|
I don't believe you. |
|
Ran the actual Example issue: https://github.com/alliasgher/allstar-test/issues/1 Test script: https://gist.github.com/alliasgher/b20d6dc3e1ac52dcc360b3d27ede5724 |
Summary
Add a new policy that checks whether GitHub's secret scanning feature is enabled on repositories.
Motivation
As noted in #363, GitHub now offers secret scanning alerts for all public repos, but it must be explicitly enabled. This is exactly the kind of security feature that organizations want to enforce across all their repositories via policy — a natural fit for Allstar.
Implementation
The policy follows the same structure as the existing
security(SECURITY.md) policy:pkg/policies/secretscanning/secretscanning.goRepository.SecurityAndAnalysis.SecretScanning.Statusvia the GitHub REST API"enabled", fails otherwiseSecurityAndAnalysisand nilSecretScanninggracefullysecret_scanning.yamllog/issue/fixactions (fix logs a warning, not yet implemented)pkg/policies/secretscanning/secretscanning_test.gopkg/policies/policies.gosecretscanning.NewSecretScanning()inGetPolicies()Configuration
Org-level (
.allstar/secret_scanning.yaml):Repo-level (
.allstar/secret_scanning.yaml):Fixes #363