Repository navigation
SC-60373 Use WIF to authenticate SonarQube Cloud scans in build actions #363
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
Changes from all commits
5699890
74bbca3
3f6069a
0991c9f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -142,16 +142,20 @@ runs: | |
| with: | ||
| # yamllint disable rule:line-length | ||
| secrets: | | ||
| ${{ (inputs.sonar-platform != 'none' || inputs.run-shadow-scans == 'true') && 'development/kv/data/next url | NEXT_URL;' || '' }} | ||
| ${{ (inputs.sonar-platform != 'none' || inputs.run-shadow-scans == 'true') && 'development/kv/data/next token | NEXT_TOKEN;' || '' }} | ||
| ${{ (inputs.sonar-platform == 'next' || inputs.run-shadow-scans == 'true') && 'development/kv/data/next url | NEXT_URL;' || '' }} | ||
| ${{ (inputs.sonar-platform == 'next' || inputs.run-shadow-scans == 'true') && 'development/kv/data/next token | NEXT_TOKEN;' || '' }} | ||
| ${{ (inputs.sonar-platform != 'none' || inputs.run-shadow-scans == 'true') && 'development/kv/data/sonarqube-us url | SQC_US_URL;' || '' }} | ||
| ${{ (inputs.sonar-platform != 'none' || inputs.run-shadow-scans == 'true') && 'development/kv/data/sonarqube-us token | SQC_US_TOKEN;' || '' }} | ||
| ${{ (inputs.sonar-platform != 'none' || inputs.run-shadow-scans == 'true') && 'development/kv/data/sonarcloud url | SQC_EU_URL;' || '' }} | ||
|
Comment on lines
147
to
148
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| ${{ (inputs.sonar-platform != 'none' || inputs.run-shadow-scans == 'true') && 'development/kv/data/sonarcloud token | SQC_EU_TOKEN;' || '' }} | ||
| development/kv/data/sign key | SIGN_KEY; | ||
| development/kv/data/sign passphrase | PGP_PASSPHRASE; | ||
| development/kv/data/sign key_id | SIGN_KEY_ID; | ||
| # yamllint enable rule:line-length | ||
| # The SonarQube Cloud tokens expire after 30 minutes: keep this step right before the build step. | ||
| - uses: ./.actions/shared/sonar-auth | ||
| id: sonar-auth | ||
| with: | ||
| sonar-platform: ${{ inputs.sonar-platform }} | ||
| run-shadow-scans: ${{ inputs.run-shadow-scans }} | ||
|
|
||
| - name: Build, analyze and deploy | ||
| shell: bash | ||
|
|
@@ -182,9 +186,9 @@ runs: | |
| NEXT_URL: ${{ steps.secrets.outputs.vault && fromJSON(steps.secrets.outputs.vault).NEXT_URL || '' }} | ||
| NEXT_TOKEN: ${{ steps.secrets.outputs.vault && fromJSON(steps.secrets.outputs.vault).NEXT_TOKEN || '' }} | ||
| SQC_EU_URL: ${{ steps.secrets.outputs.vault && fromJSON(steps.secrets.outputs.vault).SQC_EU_URL || '' }} | ||
| SQC_EU_TOKEN: ${{ steps.secrets.outputs.vault && fromJSON(steps.secrets.outputs.vault).SQC_EU_TOKEN || '' }} | ||
| SQC_EU_TOKEN: ${{ steps.sonar-auth.outputs.sqc-eu-token }} | ||
| SQC_US_URL: ${{ steps.secrets.outputs.vault && fromJSON(steps.secrets.outputs.vault).SQC_US_URL || '' }} | ||
| SQC_US_TOKEN: ${{ steps.secrets.outputs.vault && fromJSON(steps.secrets.outputs.vault).SQC_US_TOKEN || '' }} | ||
| SQC_US_TOKEN: ${{ steps.sonar-auth.outputs.sqc-us-token }} | ||
| ORG_GRADLE_PROJECT_signingKey: ${{ steps.secrets.outputs.vault && fromJSON(steps.secrets.outputs.vault).SIGN_KEY || '' }} | ||
| ORG_GRADLE_PROJECT_signingPassword: ${{ steps.secrets.outputs.vault && fromJSON(steps.secrets.outputs.vault).PGP_PASSPHRASE || '' }} | ||
| ORG_GRADLE_PROJECT_signingKeyId: ${{ steps.secrets.outputs.vault && fromJSON(steps.secrets.outputs.vault).SIGN_KEY_ID || '' }} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -177,15 +177,19 @@ runs: | |
| with: | ||
| # yamllint disable rule:line-length | ||
| secrets: | | ||
| ${{ (inputs.sonar-platform != 'none' || inputs.run-shadow-scans == 'true') && 'development/kv/data/next url | NEXT_URL;' || '' }} | ||
| ${{ (inputs.sonar-platform != 'none' || inputs.run-shadow-scans == 'true') && 'development/kv/data/next token | NEXT_TOKEN;' || '' }} | ||
| ${{ (inputs.sonar-platform == 'next' || inputs.run-shadow-scans == 'true') && 'development/kv/data/next url | NEXT_URL;' || '' }} | ||
| ${{ (inputs.sonar-platform == 'next' || inputs.run-shadow-scans == 'true') && 'development/kv/data/next token | NEXT_TOKEN;' || '' }} | ||
| ${{ (inputs.sonar-platform != 'none' || inputs.run-shadow-scans == 'true') && 'development/kv/data/sonarqube-us url | SQC_US_URL;' || '' }} | ||
| ${{ (inputs.sonar-platform != 'none' || inputs.run-shadow-scans == 'true') && 'development/kv/data/sonarqube-us token | SQC_US_TOKEN;' || '' }} | ||
| ${{ (inputs.sonar-platform != 'none' || inputs.run-shadow-scans == 'true') && 'development/kv/data/sonarcloud url | SQC_EU_URL;' || '' }} | ||
| ${{ (inputs.sonar-platform != 'none' || inputs.run-shadow-scans == 'true') && 'development/kv/data/sonarcloud token | SQC_EU_TOKEN;' || '' }} | ||
| development/kv/data/sign key | SIGN_KEY; | ||
| development/kv/data/sign passphrase | PGP_PASSPHRASE; | ||
| # yamllint enable rule:line-length | ||
| # The SonarQube Cloud tokens expire after 30 minutes: keep this step right before the build step. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it enough for long-running builds? Is the token used at the beginning and/or at the end of the Maven build?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The token fetch happens before the maven build is started, by design. The goal of modifying this action is to be able to dogfood the public So we have two options:
I would rather adopt a specific solution for sonarqube, and let all other projects use the public
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO this is a major design flaw of those shared actions (and to be honest, of our Maven/Gradle scanners). We should have isolated the Sonar analysis from the build of the project. This is especially true if the build takes longer than 30 min, we should extract it, run tests in parallel jobs, and only run the SQ analysis in a downstream job. |
||
| - uses: ./.actions/shared/sonar-auth | ||
| id: sonar-auth | ||
| with: | ||
| sonar-platform: ${{ inputs.sonar-platform }} | ||
| run-shadow-scans: ${{ inputs.run-shadow-scans }} | ||
|
|
||
| - name: Build, analyze and deploy | ||
| shell: bash | ||
|
|
@@ -216,9 +220,9 @@ runs: | |
| NEXT_URL: ${{ steps.secrets.outputs.vault && fromJSON(steps.secrets.outputs.vault).NEXT_URL || '' }} | ||
| NEXT_TOKEN: ${{ steps.secrets.outputs.vault && fromJSON(steps.secrets.outputs.vault).NEXT_TOKEN || '' }} | ||
| SQC_EU_URL: ${{ steps.secrets.outputs.vault && fromJSON(steps.secrets.outputs.vault).SQC_EU_URL || '' }} | ||
| SQC_EU_TOKEN: ${{ steps.secrets.outputs.vault && fromJSON(steps.secrets.outputs.vault).SQC_EU_TOKEN || '' }} | ||
| SQC_EU_TOKEN: ${{ steps.sonar-auth.outputs.sqc-eu-token }} | ||
| SQC_US_URL: ${{ steps.secrets.outputs.vault && fromJSON(steps.secrets.outputs.vault).SQC_US_URL || '' }} | ||
| SQC_US_TOKEN: ${{ steps.secrets.outputs.vault && fromJSON(steps.secrets.outputs.vault).SQC_US_TOKEN || '' }} | ||
| SQC_US_TOKEN: ${{ steps.sonar-auth.outputs.sqc-us-token }} | ||
| SIGN_KEY: ${{ steps.secrets.outputs.vault && fromJSON(steps.secrets.outputs.vault).SIGN_KEY || '' }} | ||
| PGP_PASSPHRASE: ${{ steps.secrets.outputs.vault && fromJSON(steps.secrets.outputs.vault).PGP_PASSPHRASE || '' }} | ||
| working-directory: ${{ inputs.working-directory }} | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Quality: README still says build-* no longer read the SQC Vault secrets
This commit makes every
build-*action readdevelopment/kv/data/sonarcloud urlanddevelopment/kv/data/sonarqube-us urlfrom Vault again, for example inbuild-gradle/action.yml:147-148. Line 100 of the README was updated to say so. Lines 115-116 were left unchanged and still say thebuild-*actions "do not read the secretsdevelopment/kv/data/sonarcloudanddevelopment/kv/data/sonarqube-usanymore" and that onlycheck-scastill uses them. An operator who follows that paragraph could conclude that these secrets can be revoked oncecheck-scamigrates. Doing that would leaveSQC_EU_URL/SQC_US_URLempty and break every SQC scan in the build actions. Fix: reword lines 115-116 to say that only thetokenfields of those secrets are no longer read bybuild-*, and that theurlfields are still required.Clarify that only the token fields stopped being read:
Check the box to apply the fix or reply for a change | Was this helpful? React with 👍 / 👎