Skip to content

Commit 9ee0736

Browse files
Update scan workflow to use centralized reusable component (#634)
1 parent c31cdb2 commit 9ee0736

File tree

1 file changed

+13
-89
lines changed

1 file changed

+13
-89
lines changed

.github/workflows/scan.yml

Lines changed: 13 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
pull_request:
99
types: [opened, synchronize, reopened]
1010
branches-ignore:
11-
- main
11+
- "main"
1212
pull_request_target:
1313
types: [opened, synchronize, reopened]
1414
branches:
@@ -24,104 +24,28 @@ jobs:
2424
contents: read
2525

2626
sast:
27-
name: SAST scan
28-
runs-on: ubuntu-22.04
27+
name: Checkmarx
28+
uses: bitwarden/gh-actions/.github/workflows/_checkmarx.yml@main
2929
needs: check-run
30+
secrets:
31+
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
32+
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
33+
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
3034
permissions:
3135
contents: read
3236
pull-requests: write
3337
security-events: write
3438
id-token: write
3539

36-
steps:
37-
- name: Check out repo
38-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
39-
with:
40-
ref: ${{ github.event.pull_request.head.sha }}
41-
42-
- name: Log in to Azure
43-
uses: bitwarden/gh-actions/azure-login@main
44-
with:
45-
subscription_id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
46-
tenant_id: ${{ secrets.AZURE_TENANT_ID }}
47-
client_id: ${{ secrets.AZURE_CLIENT_ID }}
48-
49-
- name: Get Azure Key Vault secrets
50-
id: get-kv-secrets
51-
uses: bitwarden/gh-actions/get-keyvault-secrets@main
52-
with:
53-
keyvault: gh-org-bitwarden
54-
secrets: "CHECKMARX-TENANT,CHECKMARX-CLIENT-ID,CHECKMARX-SECRET"
55-
56-
- name: Log out from Azure
57-
uses: bitwarden/gh-actions/azure-logout@main
58-
59-
- name: Scan with Checkmarx
60-
uses: checkmarx/ast-github-action@ef93013c95adc60160bc22060875e90800d3ecfc # 2.3.19
61-
env:
62-
INCREMENTAL:
63-
"${{ contains(github.event_name, 'pull_request') && '--sast-incremental' || '' }}"
64-
with:
65-
project_name: ${{ github.repository }}
66-
cx_tenant: ${{ steps.get-kv-secrets.outputs.CHECKMARX-TENANT }}
67-
base_uri: https://ast.checkmarx.net/
68-
cx_client_id: ${{ steps.get-kv-secrets.outputs.CHECKMARX-CLIENT-ID }}
69-
cx_client_secret: ${{ steps.get-kv-secrets.outputs.CHECKMARX-SECRET }}
70-
additional_params: |
71-
--report-format sarif \
72-
--filter "state=TO_VERIFY;PROPOSED_NOT_EXPLOITABLE;CONFIRMED;URGENT" \
73-
--output-path . ${{ env.INCREMENTAL }}
74-
75-
- name: Upload Checkmarx results to GitHub
76-
uses: github/codeql-action/upload-sarif@ce28f5bb42b7a9f2c824e633a3f6ee835bab6858 # v3.29.0
77-
with:
78-
sarif_file: cx_result.sarif
79-
sha:
80-
${{ contains(github.event_name, 'pull_request') && github.event.pull_request.head.sha ||
81-
github.sha }}
82-
ref:
83-
${{ contains(github.event_name, 'pull_request') && format('refs/pull/{0}/head',
84-
github.event.pull_request.number) || github.ref }}
85-
8640
quality:
87-
name: Quality scan
88-
runs-on: ubuntu-22.04
41+
name: Sonar
42+
uses: bitwarden/gh-actions/.github/workflows/_sonar.yml@main
8943
needs: check-run
44+
secrets:
45+
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
46+
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
47+
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
9048
permissions:
9149
contents: read
9250
pull-requests: write
9351
id-token: write
94-
95-
steps:
96-
- name: Check out repo
97-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
98-
with:
99-
fetch-depth: 0
100-
ref: ${{ github.event.pull_request.head.sha }}
101-
102-
- name: Log in to Azure
103-
uses: bitwarden/gh-actions/azure-login@main
104-
with:
105-
subscription_id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
106-
tenant_id: ${{ secrets.AZURE_TENANT_ID }}
107-
client_id: ${{ secrets.AZURE_CLIENT_ID }}
108-
109-
- name: Get Azure Key Vault secrets
110-
id: get-kv-secrets
111-
uses: bitwarden/gh-actions/get-keyvault-secrets@main
112-
with:
113-
keyvault: gh-org-bitwarden
114-
secrets: "SONAR-TOKEN"
115-
116-
- name: Log out from Azure
117-
uses: bitwarden/gh-actions/azure-logout@main
118-
119-
- name: Scan with SonarCloud
120-
uses: sonarsource/sonarqube-scan-action@2500896589ef8f7247069a56136f8dc177c27ccf # v5.2.0
121-
env:
122-
SONAR_TOKEN: ${{ steps.get-kv-secrets.outputs.SONAR-TOKEN }}
123-
with:
124-
args: >
125-
-Dsonar.organization=${{ github.repository_owner }} -Dsonar.projectKey=${{
126-
github.repository_owner }}_${{ github.event.repository.name }}
127-
-Dsonar.pullrequest.key=${{ github.event.pull_request.number }}

0 commit comments

Comments
 (0)