-
Notifications
You must be signed in to change notification settings - Fork 15
Include sonar cloud scan as part of linting #303
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
if: matrix.name == 'lint' && (hashFiles('sonar-project.properties') != '' || env.SONAR_TOKEN != '') # 'if' cannot use 'secrets' context | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
SONAR_TOKEN: ${{ secrets[format('{0}', vars.SONAR_TOKEN_SECRET_NAME)] || secrets.SONAR_TOKEN }} |
Check warning
Code scanning / CodeQL
Excessive Secrets Exposure Medium
secrets[format('{0}', vars.SONAR_TOKEN_SECRET_NAME)] || secrets.SONAR_TOKEN
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 8 days ago
To fix the issue, we need to replace the dynamic secret access with explicit references to specific secrets. This ensures that only the required secrets are passed to the workflow runner, adhering to the principle of least privilege. The best approach is to define the secret explicitly in the workflow file, using a static reference like secrets.SONAR_TOKEN
. If multiple environments or configurations are needed, separate workflows or conditional logic can be used to reference specific secrets explicitly.
Changes required:
- Replace
secrets[format('{0}', vars.SONAR_TOKEN_SECRET_NAME)]
with a static reference to the specific secret, e.g.,secrets.SONAR_TOKEN
. - Remove the fallback
|| secrets.SONAR_TOKEN
to avoid ambiguity and ensure only the required secret is used.
-
Copy modified line R242
@@ -241,3 +241,3 @@ | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
SONAR_TOKEN: ${{ secrets[format('{0}', vars.SONAR_TOKEN_SECRET_NAME)] || secrets.SONAR_TOKEN }} | ||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | ||
|
No description provided.