ci: skip security scans gracefully when secrets are unavailable#19
Open
ivan-gudak wants to merge 1 commit into
Open
ci: skip security scans gracefully when secrets are unavailable#19ivan-gudak wants to merge 1 commit into
ivan-gudak wants to merge 1 commit into
Conversation
The Snyk and SonarCloud workflows were failing on every run for auth/config reasons, not code: - Snyk hard-failed with 401 Unauthorized because no SNYK_TOKEN secret is configured. Guard the scan on a job-level SNYK_TOKEN env so a missing token skips the scan (with a "Snyk Unavailable" notice) instead of failing the job. - SonarCloud reported misleading green checks on Dependabot PRs (which cannot access repository secrets, so the scan was silently skipped), while pushes to main failed against an unauthorized token. Skip the job entirely for Dependabot so PR checks no longer masquerade as passing; pushes to main and normal PRs still run the real scan. The scans themselves still require valid secrets to be configured (see PR description). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
|
|
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.



Summary
The Snyk and SonarCloud GitHub Actions workflows have been failing on every run. The root causes are authentication/configuration, not code:
401 Unauthorizedbecause noSNYK_TOKENsecret is configured. It has never passed.mainwithNot authorized or project not found. The "passing" runs were Dependabot PRs that silently skip the scan (Dependabot PRs don't get repository secrets), producing misleading green checks.Changes
snyk.yml: moveSNYK_TOKENto a job-level env and guard the scan withif: env.SNYK_TOKEN != '', plus a fallbackSnyk Unavailablestep. A missing token now skips the scan instead of hard-failing with a 401.sonar.yml: addif: github.actor != 'dependabot[bot]'at the job level so Dependabot PRs show as skipped rather than a misleading green check. Pushes tomainand normal contributor PRs still run the real scan.These edits stop the misleading failures, but the scans will only actually run once the following repository secrets are set (Settings → Secrets and variables → Actions):
SNYK_TOKENSnyk Unavailablestep).SONAR_TOKENdynatrace-oss_dtmgdin orgdynatrace-oss, then update the secret. Until fixed, the SonarCloud scan onmainkeeps failing.No GitHub Actions variables (vars) are required — only the two secrets above.
🤖 Generated with Claude Code