Skip to content

Commit b5df1f6

Browse files
committed
writer-json-sarif: encode per-warning CWE property
... so that the data is processed by DefectDojo Fixes: #125 Closes: #126
1 parent b2eae0a commit b5df1f6

File tree

4 files changed

+954
-1
lines changed

4 files changed

+954
-1
lines changed

src/lib/writer-json-sarif.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,15 @@ void SarifTreeEncoder::appendDef(const Defect &def)
276276
shellCheckMap_[ruleId] = sm[2];
277277
}
278278

279-
if (def.cwe)
279+
if (def.cwe) {
280280
// update CWE map
281281
cweMap_[ruleId] = def.cwe;
282282

283+
// encode per-warning CWE property
284+
object cweProp = {{ "cwe", "CWE-" + std::to_string(def.cwe) }};
285+
result["properties"] = std::move(cweProp);
286+
}
287+
283288
// key event severity level
284289
sarifEncodeLevel(&result, keyEvt.event);
285290

0 commit comments

Comments
 (0)