ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
sarif.h
Go to the documentation of this file.
1#ifndef CPROVER_GOTO_SYMEX_SARIF_H
2#define CPROVER_GOTO_SYMEX_SARIF_H
3
8#include <vector>
9
10#include <string>
11
12// Writes the violation reported in `goto_trace`, plus any dead-store advisories
13// (CWE-563), to a SARIF 2.1.0 document at the path given by
14// `options["sarif-output"]`. Writes to stdout when the option value is "-".
15// Violations are emitted as `result.level = "error"`; advisories as
16// `result.level = "note"`. Includes the matching CWE ids (per
17// util/base/cwe_mapping.h) as both per-rule tags and per-result taxa references
18// into a "CWE" taxonomy pinned to CWE 4.20.
19//
20// `goto_trace` may be empty (e.g. on VERIFICATION SUCCESSFUL) so that a run
21// with only advisories still produces a document.
23 const optionst &options,
24 const namespacet &ns,
25 const goto_tracet &goto_trace,
26 const std::vector<dead_store_advisoryt> &advisories = {});
27
28// One provably-dead statement/branch found by --dead-code-check.
30{
31 std::string message; // human-readable description (e.g. the branch guard)
32 std::string file;
33 unsigned line = 0; // 0 means "unknown", omitted from SARIF
34};
35
36// Writes the dead-code advisory `findings`, plus any dead-store advisories
37// (CWE-563), to the SARIF 2.1.0 document at `options["sarif-output"]` (stdout
38// when "-"). Findings are emitted with `result.level = "note"` (advisory, not
39// an error) and taxa referencing CWE-561 in the same "CWE" taxonomy used by
40// sarif_goto_trace. Does nothing when no SARIF output path is configured; when
41// a path is set but `findings` is empty it still writes a well-formed document
42// with an empty `results` array, so a clean run yields a valid report rather
43// than a missing file.
44//
45// `advisories` must be passed whenever --dead-store-check is also active: both
46// advisory sets share the one output path, so they have to land in the same
47// document (issue #4495).
49 const optionst &options,
50 const std::vector<dead_code_finding_t> &findings,
51 const std::vector<dead_store_advisoryt> &advisories = {});
52
53#endif
Definition goto_trace.h:93
Definition namespace.h:10
Definition options.h:11
void sarif_goto_trace(const optionst &options, const namespacet &ns, const goto_tracet &goto_trace, const std::vector< dead_store_advisoryt > &advisories={})
Definition sarif.cpp:250
void sarif_dead_code(const optionst &options, const std::vector< dead_code_finding_t > &findings, const std::vector< dead_store_advisoryt > &advisories={})
Definition sarif.cpp:286
Definition sarif.h:30
std::string message
Definition sarif.h:31
unsigned line
Definition sarif.h:33
std::string file
Definition sarif.h:32