@@ -22,13 +22,20 @@ jobs:
2222 - dir : cvmassistants/keyprovider/key-provider-agent/src
2323 file : key_provider_agent.c
2424
25+ permissions :
26+ security-events : write
27+ contents : write
28+ actions : read
29+
2530 steps :
2631 - uses : actions/checkout@v4
32+ with :
33+ fetch-depth : 0
2734
28- - name : Install tools directly
35+ - name : Install cppcheck
2936 run : |
3037 sudo apt-get update
31- sudo apt-get install -y clang-format cppcheck
38+ sudo apt-get install -y cppcheck
3239
3340 - name : Check if file changed
3441 id : changed
@@ -37,13 +44,37 @@ jobs:
3744 files : ${{ matrix.provider-agent.dir }}/${{ matrix.provider-agent.file }}
3845
3946 - name : clang-format scan ${{ matrix.provider-agent.file }}
47+ if : steps.changed.outputs.any_changed == 'true' || github.event_name == 'workflow_dispatch'
48+ 49+ with :
50+ source : ${{ matrix.provider-agent.dir }}/${{ matrix.provider-agent.file }}
51+ style : llvm
52+ inplace : True
53+
54+ - uses : EndBug/add-and-commit@v9
55+ with :
56+ author_name : Clang Robot
57+ 58+ message : ' fix: action - committing clang-format changes'
59+ env :
60+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
61+
62+ - name : cppcheck scan ${{ matrix.provider-agent.file }}
4063 if : steps.changed.outputs.any_changed == 'true' || github.event_name == 'workflow_dispatch'
4164 working-directory : ${{ matrix.provider-agent.dir }}
4265 run : |
43- clang-format --dry-run -style=llvm --Werror ${{ matrix.provider-agent.file }}
66+ cppcheck --enable=all --suppress=missingIncludeSystem --xml --output-file=report.xml ${{ matrix.provider-agent.file }}
4467
45- - name : cppcheck scan ${{ matrix.provider-agent.file }}
68+ - name : Convert cppcheck XML → SARIF
4669 if : steps.changed.outputs.any_changed == 'true' || github.event_name == 'workflow_dispatch'
47- working-directory : ${{ matrix.provider-agent.dir }}
48- run : | # enable all checks and suppress missing include system since RATS-TLS dependencies are not included in the repo
49- cppcheck --enable=all --suppress=missingIncludeSystem --error-exitcode=1 ${{ matrix.provider-agent.file }}
70+ uses : Flast/cppcheck-sarif@v2
71+ with :
72+ input : ${{ matrix.provider-agent.dir }}/report.xml
73+ output : ${{ matrix.provider-agent.dir }}/report.sarif
74+
75+ - name : Upload SARIF to GitHub Code Scanning
76+ if : steps.changed.outputs.any_changed == 'true' || github.event_name == 'workflow_dispatch'
77+ uses : github/codeql-action/upload-sarif@v4
78+ with :
79+ sarif_file : ${{ matrix.provider-agent.dir }}/report.sarif
80+ category : cppcheck
0 commit comments