|
| 1 | +name: Scan |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - "main" |
| 8 | + pull_request: |
| 9 | + types: [opened, synchronize, reopened] |
| 10 | + branches-ignore: |
| 11 | + - "main" |
| 12 | + pull_request_target: |
| 13 | + types: [opened, synchronize, reopened] |
| 14 | + branches: |
| 15 | + - "main" |
| 16 | + |
| 17 | +# TODO: see https://bitwarden.atlassian.net/l/cp/SLtTZJ90 for configuration tips |
| 18 | +jobs: |
| 19 | + check-run: |
| 20 | + name: Check PR run |
| 21 | + uses: bitwarden/gh-actions/.github/workflows/check-run.yml@main |
| 22 | + |
| 23 | + sast: |
| 24 | + name: SAST scan |
| 25 | + runs-on: ubuntu-22.04 |
| 26 | + needs: check-run |
| 27 | + permissions: |
| 28 | + contents: read |
| 29 | + pull-requests: write |
| 30 | + security-events: write |
| 31 | + |
| 32 | + steps: |
| 33 | + - name: Check out repo |
| 34 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 35 | + with: |
| 36 | + ref: ${{ github.event.pull_request.head.sha }} |
| 37 | + |
| 38 | + - name: Scan with Checkmarx |
| 39 | + uses: checkmarx/ast-github-action@ef93013c95adc60160bc22060875e90800d3ecfc # 2.3.19 |
| 40 | + env: |
| 41 | + INCREMENTAL: "${{ contains(github.event_name, 'pull_request') && '--sast-incremental' || '' }}" |
| 42 | + with: |
| 43 | + project_name: ${{ github.repository }} |
| 44 | + cx_tenant: ${{ secrets.CHECKMARX_TENANT }} |
| 45 | + base_uri: https://ast.checkmarx.net/ |
| 46 | + cx_client_id: ${{ secrets.CHECKMARX_CLIENT_ID }} |
| 47 | + cx_client_secret: ${{ secrets.CHECKMARX_SECRET }} |
| 48 | + additional_params: | |
| 49 | + --report-format sarif \ |
| 50 | + --filter "state=TO_VERIFY;PROPOSED_NOT_EXPLOITABLE;CONFIRMED;URGENT" \ |
| 51 | + --output-path . ${{ env.INCREMENTAL }} |
| 52 | +
|
| 53 | + - name: Upload Checkmarx results to GitHub |
| 54 | + uses: github/codeql-action/upload-sarif@45775bd8235c68ba998cffa5171334d58593da47 # v3.28.15 |
| 55 | + with: |
| 56 | + sarif_file: cx_result.sarif |
| 57 | + sha: ${{ contains(github.event_name, 'pull_request') && github.event.pull_request.head.sha || github.sha }} |
| 58 | + ref: ${{ contains(github.event_name, 'pull_request') && format('refs/pull/{0}/head', github.event.pull_request.number) || github.ref }} |
| 59 | + |
| 60 | + quality: |
| 61 | + name: Quality scan |
| 62 | + runs-on: ubuntu-22.04 |
| 63 | + needs: check-run |
| 64 | + permissions: |
| 65 | + contents: read |
| 66 | + pull-requests: write |
| 67 | + |
| 68 | + steps: |
| 69 | + - name: Check out repo |
| 70 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 71 | + with: |
| 72 | + fetch-depth: 0 |
| 73 | + ref: ${{ github.event.pull_request.head.sha }} |
| 74 | + |
| 75 | + - name: Scan with SonarCloud |
| 76 | + uses: sonarsource/sonarqube-scan-action@aa494459d7c39c106cc77b166de8b4250a32bb97 # v5.1.0 |
| 77 | + env: |
| 78 | + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
| 79 | + with: |
| 80 | + args: > |
| 81 | + -Dsonar.organization=${{ github.repository_owner }} |
| 82 | + -Dsonar.projectKey=${{ github.repository_owner }}_${{ github.event.repository.name }} |
| 83 | + -Dsonar.pullrequest.key=${{ github.event.pull_request.number }} |
0 commit comments