Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions .github/workflows/scan-provider-agents.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: scan-provider-agents

on:
pull_request:
paths:
- 'cvmassistants/secretprovider/secret-provider-agent/src/secret_provider_agent.c'
- 'cvmassistants/keyprovider/key-provider-agent/src/key_provider_agent.c'
workflow_dispatch: {}

jobs:
scan-provider-agents:

name: Scan ${{ matrix.provider-agent.file }}

runs-on: ubuntu-latest

strategy:
matrix:
provider-agent:
- dir: cvmassistants/secretprovider/secret-provider-agent/src
file: secret_provider_agent.c
- dir: cvmassistants/keyprovider/key-provider-agent/src
file: key_provider_agent.c

permissions:
security-events: write
contents: read
actions: read

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install cppcheck
run: |
sudo apt-get update
sudo apt-get install -y cppcheck

- name: Check if file changed
id: changed
uses: tj-actions/changed-files@v47
with:
files: ${{ matrix.provider-agent.dir }}/${{ matrix.provider-agent.file }}

# correct using: clang-format -style=llvm -i ${{ matrix.provider-agent.dir }}/${{ matrix.provider-agent.file }}
- name: clang-format scan ${{ matrix.provider-agent.file }}
if: steps.changed.outputs.any_changed == 'true' || github.event_name == 'workflow_dispatch'
uses: DoozyX/clang-format-lint-action@v0.18.2
with:
source: ${{ matrix.provider-agent.dir }}/${{ matrix.provider-agent.file }}
style: llvm
inplace: False

- name: cppcheck scan ${{ matrix.provider-agent.file }}
if: steps.changed.outputs.any_changed == 'true' || github.event_name == 'workflow_dispatch'
working-directory: ${{ matrix.provider-agent.dir }}
run: |
cppcheck --enable=all --suppress=missingIncludeSystem --xml --output-file=report.xml ${{ matrix.provider-agent.file }}

- name: Convert cppcheck XML → SARIF
if: steps.changed.outputs.any_changed == 'true' || github.event_name == 'workflow_dispatch'
uses: Flast/cppcheck-sarif@v2
with:
input: ${{ matrix.provider-agent.dir }}/report.xml
output: ${{ matrix.provider-agent.dir }}/report.sarif

- name: Upload SARIF to GitHub Code Scanning
if: steps.changed.outputs.any_changed == 'true' || github.event_name == 'workflow_dispatch'
uses: github/codeql-action/upload-sarif@v4
with:
sarif_file: ${{ matrix.provider-agent.dir }}/report.sarif
category: cppcheck