Skip to content

Commit e486dee

Browse files
Update scan workflow to use centralized reusable component (#41)
1 parent fc01d51 commit e486dee

File tree

1 file changed

+14
-95
lines changed

1 file changed

+14
-95
lines changed

.github/workflows/scan.yml

Lines changed: 14 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -24,111 +24,30 @@ 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@184bf2f64f55d1c93fd6636d539edf274703e434 # 2.0.41
61-
env:
62-
INCREMENTAL: "${{ contains(github.event_name, 'pull_request') && '--sast-incremental' || '' }}"
63-
with:
64-
project_name: ${{ github.repository }}
65-
cx_tenant: ${{ steps.get-kv-secrets.outputs.CHECKMARX-TENANT }}
66-
base_uri: https://ast.checkmarx.net/
67-
cx_client_id: ${{ steps.get-kv-secrets.outputs.CHECKMARX-CLIENT-ID }}
68-
cx_client_secret: ${{ steps.get-kv-secrets.outputs.CHECKMARX-SECRET }}
69-
additional_params: |
70-
--report-format sarif \
71-
--filter "state=TO_VERIFY;PROPOSED_NOT_EXPLOITABLE;CONFIRMED;URGENT" \
72-
--output-path . ${{ env.INCREMENTAL }}
73-
74-
- name: Upload Checkmarx results to GitHub
75-
uses: github/codeql-action/upload-sarif@b6a472f63d85b9c78a3ac5e89422239fc15e9b3c # v3.28.1
76-
with:
77-
sarif_file: cx_result.sarif
78-
sha: ${{ contains(github.event_name, 'pull_request') && github.event.pull_request.head.sha || github.sha }}
79-
ref: ${{ contains(github.event_name, 'pull_request') && format('refs/pull/{0}/head', github.event.pull_request.number) || github.ref }}
80-
8140
quality:
82-
name: Quality scan
83-
runs-on: ubuntu-22.04
41+
name: Sonar
42+
uses: bitwarden/gh-actions/.github/workflows/_sonar.yml@main
8443
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 }}
8548
permissions:
8649
contents: read
8750
pull-requests: write
8851
id-token: write
89-
90-
steps:
91-
- name: Set up JDK 17
92-
uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0
93-
with:
94-
java-version: 17
95-
distribution: "zulu"
96-
97-
- name: Check out repo
98-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
99-
with:
100-
fetch-depth: 0
101-
ref: ${{ github.event.pull_request.head.sha }}
102-
103-
- name: Set up .NET
104-
uses: actions/setup-dotnet@87b7050bc53ea08284295505d98d2aa94301e852 # v4.2.0
105-
106-
- name: Install SonarCloud scanner
107-
run: dotnet tool install dotnet-sonarscanner -g
108-
109-
- name: Log in to Azure
110-
uses: bitwarden/gh-actions/azure-login@main
111-
with:
112-
subscription_id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
113-
tenant_id: ${{ secrets.AZURE_TENANT_ID }}
114-
client_id: ${{ secrets.AZURE_CLIENT_ID }}
115-
116-
- name: Get Azure Key Vault secrets
117-
id: get-kv-secrets
118-
uses: bitwarden/gh-actions/get-keyvault-secrets@main
119-
with:
120-
keyvault: gh-org-bitwarden
121-
secrets: "SONAR-TOKEN"
122-
123-
- name: Log out from Azure
124-
uses: bitwarden/gh-actions/azure-logout@main
125-
126-
- name: Scan with SonarCloud
127-
env:
128-
SONAR_TOKEN: ${{ steps.get-kv-secrets.outputs.SONAR-TOKEN }}
129-
run: |
130-
dotnet-sonarscanner begin /k:"${{ github.repository_owner }}_${{ github.event.repository.name }}" \
131-
/o:"${{ github.repository_owner }}" /d:sonar.token="${{ steps.get-kv-secrets.outputs.SONAR-TOKEN }}" \
132-
/d:sonar.host.url="https://sonarcloud.io" ${{ contains(github.event_name, 'pull_request') && format('/d:sonar.pullrequest.key={0}', github.event.pull_request.number) || '' }}
133-
dotnet build
134-
dotnet-sonarscanner end /d:sonar.token="${{ steps.get-kv-secrets.outputs.SONAR-TOKEN }}"
52+
with:
53+
sonar-config: "dotnet"

0 commit comments

Comments
 (0)