Skip to content

Commit

Permalink
writer-json-sarif: propagate the "imp" flag as level
Browse files Browse the repository at this point in the history
If the "imp" flag is set on a finding, set the SARIF level to "error",
which means "Important".

Related: https://issues.redhat.com/browse/OSH-565
Closes: #173
  • Loading branch information
kdudka committed Apr 23, 2024
1 parent f05aa13 commit cd5d2e5
Show file tree
Hide file tree
Showing 5 changed files with 114,363 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/lib/writer-json-sarif.cc
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,12 @@ void SarifTreeEncoder::appendDef(const Defect &def)
// update tool for this rule
d->ruleMap[ruleId].tool = def.tool;

// key event severity level
sarifEncodeLevel(&result, keyEvt.event);
if (0 < def.imp)
// if the "imp" flag is set, promote this finding to "Important"
result.emplace("level", "error");
else
// key event severity level
sarifEncodeLevel(&result, keyEvt.event);

// key event location
object loc;
Expand Down
1 change: 1 addition & 0 deletions tests/csgrep/0124-sarif-writer-imp-args.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--mode=sarif
Loading

0 comments on commit cd5d2e5

Please sign in to comment.