|
| 1 | +name: scan-provider-agents |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + paths: |
| 6 | + - 'cvmassistants/secretprovider/secret-provider-agent/src/secret_provider_agent.c' |
| 7 | + - 'cvmassistants/keyprovider/key-provider-agent/src/key_provider_agent.c' |
| 8 | + workflow_dispatch: {} |
| 9 | + |
| 10 | +jobs: |
| 11 | + scan-provider-agents: |
| 12 | + |
| 13 | + name: Scan ${{ matrix.provider-agent.file }} |
| 14 | + |
| 15 | + runs-on: ubuntu-latest |
| 16 | + |
| 17 | + strategy: |
| 18 | + matrix: |
| 19 | + provider-agent: |
| 20 | + - dir: cvmassistants/secretprovider/secret-provider-agent/src |
| 21 | + file: secret_provider_agent.c |
| 22 | + - dir: cvmassistants/keyprovider/key-provider-agent/src |
| 23 | + file: key_provider_agent.c |
| 24 | + |
| 25 | + permissions: |
| 26 | + security-events: write |
| 27 | + contents: read |
| 28 | + actions: read |
| 29 | + |
| 30 | + steps: |
| 31 | + - uses: actions/checkout@v4 |
| 32 | + with: |
| 33 | + fetch-depth: 0 |
| 34 | + |
| 35 | + - name: Install cppcheck |
| 36 | + run: | |
| 37 | + sudo apt-get update |
| 38 | + sudo apt-get install -y cppcheck |
| 39 | +
|
| 40 | + - name: Check if file changed |
| 41 | + id: changed |
| 42 | + uses: tj-actions/changed-files@v47 |
| 43 | + with: |
| 44 | + files: ${{ matrix.provider-agent.dir }}/${{ matrix.provider-agent.file }} |
| 45 | + |
| 46 | + # correct using: clang-format -style=llvm -i ${{ matrix.provider-agent.dir }}/${{ matrix.provider-agent.file }} |
| 47 | + - name: clang-format scan ${{ matrix.provider-agent.file }} |
| 48 | + if: steps.changed.outputs.any_changed == 'true' || github.event_name == 'workflow_dispatch' |
| 49 | + |
| 50 | + with: |
| 51 | + source: ${{ matrix.provider-agent.dir }}/${{ matrix.provider-agent.file }} |
| 52 | + style: llvm |
| 53 | + inplace: False |
| 54 | + |
| 55 | + - name: cppcheck scan ${{ matrix.provider-agent.file }} |
| 56 | + if: steps.changed.outputs.any_changed == 'true' || github.event_name == 'workflow_dispatch' |
| 57 | + working-directory: ${{ matrix.provider-agent.dir }} |
| 58 | + run: | |
| 59 | + cppcheck --enable=all --suppress=missingIncludeSystem --xml --output-file=report.xml ${{ matrix.provider-agent.file }} |
| 60 | +
|
| 61 | + - name: Convert cppcheck XML → SARIF |
| 62 | + if: steps.changed.outputs.any_changed == 'true' || github.event_name == 'workflow_dispatch' |
| 63 | + uses: Flast/cppcheck-sarif@v2 |
| 64 | + with: |
| 65 | + input: ${{ matrix.provider-agent.dir }}/report.xml |
| 66 | + output: ${{ matrix.provider-agent.dir }}/report.sarif |
| 67 | + |
| 68 | + - name: Upload SARIF to GitHub Code Scanning |
| 69 | + if: steps.changed.outputs.any_changed == 'true' || github.event_name == 'workflow_dispatch' |
| 70 | + uses: github/codeql-action/upload-sarif@v4 |
| 71 | + with: |
| 72 | + sarif_file: ${{ matrix.provider-agent.dir }}/report.sarif |
| 73 | + category: cppcheck |
0 commit comments