|
26 | 26 |
|
27 | 27 | #include <queue>
|
28 | 28 |
|
| 29 | +#include <boost/algorithm/string/predicate.hpp> |
29 | 30 | #include <boost/iostreams/filtering_stream.hpp>
|
30 | 31 | #include <boost/iostreams/filter/regex.hpp>
|
31 | 32 | #include <boost/nowide/utf/convert.hpp>
|
@@ -214,6 +215,19 @@ static void sarifEncodeMsg(PTree *pDst, const std::string& text)
|
214 | 215 | pDst->put_child("message", msg);
|
215 | 216 | }
|
216 | 217 |
|
| 218 | +static void sarifEncodeLevel(PTree *result, const std::string &event) { |
| 219 | + std::string level = "warning"; |
| 220 | + |
| 221 | + if (boost::starts_with(event, "error")) |
| 222 | + level = "error"; |
| 223 | + else if (boost::starts_with(event, "warning")) |
| 224 | + level = "warning"; |
| 225 | + else if (boost::starts_with(event, "note")) |
| 226 | + level = "note"; |
| 227 | + |
| 228 | + result->put<std::string>("level", level); |
| 229 | +} |
| 230 | + |
217 | 231 | static void sarifEncodeLoc(PTree *pLoc, const Defect &def, unsigned idx)
|
218 | 232 | {
|
219 | 233 | // location ID within the result
|
@@ -291,6 +305,9 @@ void SarifTreeEncoder::appendDef(const Defect &def)
|
291 | 305 | // update CWE map
|
292 | 306 | cweMap_[ruleId] = def.cwe;
|
293 | 307 |
|
| 308 | + // key event severity level |
| 309 | + sarifEncodeLevel(&result, keyEvt.event); |
| 310 | + |
294 | 311 | // key event location
|
295 | 312 | PTree loc;
|
296 | 313 | sarifEncodeLoc(&loc, def, def.keyEventIdx);
|
|
0 commit comments