File tree Expand file tree Collapse file tree 3 files changed +41
-4
lines changed Expand file tree Collapse file tree 3 files changed +41
-4
lines changed Original file line number Diff line number Diff line change @@ -187,3 +187,38 @@ jobs:
187187 with :
188188 name : Callgrind Output
189189 path : ./callgrind.*
190+
191+ build_sarif_github :
192+ # Perform selfcheck and upload results to github using sarif format
193+ # Results are shown here: https://github.com/danmar/cppcheck/security/code-scanning
194+
195+ strategy :
196+ fail-fast : false # Prefer quick result
197+
198+ runs-on : ubuntu-24.04
199+
200+ steps :
201+ - uses : actions/checkout@v4
202+ with :
203+ persist-credentials : false
204+
205+ - name : Build Cppcheck
206+ run : |
207+ make CXXFLAGS=-O2 MATCOMPILER=yes -j$(nproc)
208+
209+ - name : Run Cppcheck
210+ run : |
211+ ./cppcheck -D__CPPCHECK__ -D__GNUC__ -DCHECK_INTERNAL -DHAVE_RULES --std=c++11 --library=cppcheck-lib --library=qt --enable=style --inconclusive --inline-suppr cli frontend gui/*.cpp lib --output-format=sarif 2> results.sarif
212+
213+ - name : Results
214+ run : |
215+ cat results.sarif
216+
217+ - uses : actions/upload-artifact@v4
218+ with :
219+ name : results
220+ path : results.sarif
221+
222+ - uses : github/codeql-action/upload-sarif@v3
223+ with :
224+ sarif_file : results.sarif
Original file line number Diff line number Diff line change @@ -115,7 +115,8 @@ namespace {
115115 // else if (finding.severity == Severity::warning)
116116 // securitySeverity = 5.1; // We see potential undefined behavior
117117 if (securitySeverity > 0.5 ) {
118- properties[" security-severity" ] = picojson::value (securitySeverity);
118+ // skipped: "security-severity" caused error when uploading to github
119+ // properties["security-severity"] = picojson::value(securitySeverity);
119120 const picojson::array tags{picojson::value (" security" )};
120121 properties[" tags" ] = picojson::value (tags);
121122 }
@@ -139,8 +140,8 @@ namespace {
139140 artifactLocation[" uri" ] = picojson::value (location.getfile (false ));
140141 physicalLocation[" artifactLocation" ] = picojson::value (artifactLocation);
141142 picojson::object region;
142- region[" startLine" ] = picojson::value (static_cast <int64_t >(location.line ));
143- region[" startColumn" ] = picojson::value (static_cast <int64_t >(location.column ));
143+ region[" startLine" ] = picojson::value (static_cast <int64_t >(location.line < 1 ? 1 : location. line ));
144+ region[" startColumn" ] = picojson::value (static_cast <int64_t >(location.column < 1 ? 1 : location. column ));
144145 region[" endLine" ] = region[" startLine" ];
145146 region[" endColumn" ] = region[" startColumn" ];
146147 physicalLocation[" region" ] = picojson::value (region);
Original file line number Diff line number Diff line change @@ -373,7 +373,8 @@ def test_sarif():
373373 assert res ['runs' ][0 ]['results' ][0 ]['ruleId' ] == 'zerodiv'
374374 assert res ['runs' ][0 ]['tool' ]['driver' ]['rules' ][0 ]['id' ] == 'zerodiv'
375375 assert res ['runs' ][0 ]['tool' ]['driver' ]['rules' ][0 ]['properties' ]['precision' ] == 'high'
376- assert res ['runs' ][0 ]['tool' ]['driver' ]['rules' ][0 ]['properties' ]['security-severity' ] > 9.5
376+ # github does not seem to handle "security-severity" well so it's not added
377+ #assert res['runs'][0]['tool']['driver']['rules'][0]['properties']['security-severity'] > 9.5
377378 assert 'security' in res ['runs' ][0 ]['tool' ]['driver' ]['rules' ][0 ]['properties' ]['tags' ]
378379 assert re .match (r'[0-9]+(.[0-9]+)+' , res ['runs' ][0 ]['tool' ]['driver' ]['semanticVersion' ])
379380 assert 'level' in res ['runs' ][0 ]['tool' ]['driver' ]['rules' ][0 ]['defaultConfiguration' ] # #13885
You can’t perform that action at this time.
0 commit comments