Skip to content

Commit e36eb03

Browse files
Update scan workflow to use centralized reusable component (#98)
1 parent 15158b8 commit e36eb03

File tree

1 file changed

+19
-85
lines changed

1 file changed

+19
-85
lines changed

.github/workflows/scan.yml

Lines changed: 19 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,17 @@ on:
55
push:
66
branches:
77
- "main"
8+
pull_request:
9+
types: [opened, synchronize, reopened]
10+
branches-ignore:
11+
- "main"
812
pull_request_target:
9-
types: [opened, synchronize]
13+
types: [opened, synchronize, reopened]
1014
branches:
1115
- "main"
1216

13-
# TODO: see https://bitwarden.atlassian.net/l/cp/SLtTZJ90 for configuration tips
17+
permissions: {}
18+
1419
jobs:
1520
check-run:
1621
name: Check PR run
@@ -19,99 +24,28 @@ jobs:
1924
contents: read
2025

2126
sast:
22-
name: SAST scan
23-
runs-on: ubuntu-22.04
27+
name: Checkmarx
28+
uses: bitwarden/gh-actions/.github/workflows/_checkmarx.yml@main
2429
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 }}
2534
permissions:
2635
contents: read
2736
pull-requests: write
2837
security-events: write
2938
id-token: write
3039

31-
steps:
32-
- name: Check out repo
33-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
34-
with:
35-
ref: ${{ github.event.pull_request.head.sha }}
36-
37-
- name: Log in to Azure
38-
uses: bitwarden/gh-actions/azure-login@main
39-
with:
40-
subscription_id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
41-
tenant_id: ${{ secrets.AZURE_TENANT_ID }}
42-
client_id: ${{ secrets.AZURE_CLIENT_ID }}
43-
44-
- name: Get Azure Key Vault secrets
45-
id: get-kv-secrets
46-
uses: bitwarden/gh-actions/get-keyvault-secrets@main
47-
with:
48-
keyvault: gh-org-bitwarden
49-
secrets: "CHECKMARX-TENANT,CHECKMARX-CLIENT-ID,CHECKMARX-SECRET"
50-
51-
- name: Log out from Azure
52-
uses: bitwarden/gh-actions/azure-logout@main
53-
54-
- name: Scan with Checkmarx
55-
uses: checkmarx/ast-github-action@9fda4ab4c1b67c35de380552a972a82997d97731 # 2.0.42
56-
env:
57-
INCREMENTAL: "${{ contains(github.event_name, 'pull_request') && '--sast-incremental' || '' }}"
58-
with:
59-
project_name: ${{ github.repository }}
60-
cx_tenant: ${{ steps.get-kv-secrets.outputs.CHECKMARX-TENANT }}
61-
base_uri: https://ast.checkmarx.net/
62-
cx_client_id: ${{ steps.get-kv-secrets.outputs.CHECKMARX-CLIENT-ID }}
63-
cx_client_secret: ${{ steps.get-kv-secrets.outputs.CHECKMARX-SECRET }}
64-
additional_params: |
65-
--report-format sarif \
66-
--filter "state=TO_VERIFY;PROPOSED_NOT_EXPLOITABLE;CONFIRMED;URGENT" \
67-
--output-path . ${{ env.INCREMENTAL }}
68-
69-
- name: Upload Checkmarx results to GitHub
70-
uses: github/codeql-action/upload-sarif@17a820bf2e43b47be2c72b39cc905417bc1ab6d0 # v3.28.6
71-
with:
72-
sarif_file: cx_result.sarif
73-
sha: ${{ contains(github.event_name, 'pull_request') && github.event.pull_request.head.sha || github.sha }}
74-
ref: ${{ contains(github.event_name, 'pull_request') && format('refs/pull/{0}/head', github.event.pull_request.number) || github.ref }}
75-
7640
quality:
77-
name: Quality scan
78-
runs-on: ubuntu-22.04
41+
name: Sonar
42+
uses: bitwarden/gh-actions/.github/workflows/_sonar.yml@main
7943
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 }}
8048
permissions:
8149
contents: read
8250
pull-requests: write
8351
id-token: write
84-
85-
steps:
86-
- name: Check out repo
87-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
88-
with:
89-
fetch-depth: 0
90-
ref: ${{ github.event.pull_request.head.sha }}
91-
92-
- name: Log in to Azure
93-
uses: bitwarden/gh-actions/azure-login@main
94-
with:
95-
subscription_id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
96-
tenant_id: ${{ secrets.AZURE_TENANT_ID }}
97-
client_id: ${{ secrets.AZURE_CLIENT_ID }}
98-
99-
- name: Get Azure Key Vault secrets
100-
id: get-kv-secrets
101-
uses: bitwarden/gh-actions/get-keyvault-secrets@main
102-
with:
103-
keyvault: gh-org-bitwarden
104-
secrets: "SONAR-TOKEN"
105-
106-
- name: Log out from Azure
107-
uses: bitwarden/gh-actions/azure-logout@main
108-
109-
- name: Scan with SonarCloud
110-
uses: sonarsource/sonarqube-scan-action@aa494459d7c39c106cc77b166de8b4250a32bb97 # v5.1.0
111-
env:
112-
SONAR_TOKEN: ${{ steps.get-kv-secrets.outputs.SONAR-TOKEN }}
113-
with:
114-
args: >
115-
-Dsonar.organization=${{ github.repository_owner }}
116-
-Dsonar.projectKey=${{ github.repository_owner }}_${{ github.event.repository.name }}
117-
-Dsonar.pullrequest.key=${{ github.event.pull_request.number }}

0 commit comments

Comments
 (0)