Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions infer/src/integration/SarifReport.ml
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,8 @@ let pp_results_header fmt =

let loc_trace_to_sarifbug_record trace_list =
let file_loc filename =
let absolute_source_name = Config.project_root ^/ filename in
let file_path = "file:" ^ filename in
{Sarifbug_j.uri= file_path; Sarifbug_j.uriBaseId= absolute_source_name}
let absolute_project_root = "file:" ^ Config.project_root in
{Sarifbug_j.uri= filename; Sarifbug_j.uriBaseId= absolute_project_root}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, uriBaseId can be set to the constant "%srcroot%" as described here. This helps when scanning repositories where we typically want the SARIF report to be the same (for the same commit) regardless of where the local checkout appears on the filesystem.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep indeed, that's one of the options I explored which also worked!

in
let message description = {Sarifbug_j.text= description} in
let region line_number column_number =
Expand Down Expand Up @@ -102,9 +101,8 @@ let pp_jsonbug fmt
in
let level = String.lowercase severity in
let ruleId = bug_type in
let absolute_source_name = Config.project_root ^/ file in
let file_path = "file:" ^ file in
let file_loc = {Sarifbug_j.uri= file_path; uriBaseId= absolute_source_name} in
let absolute_project_root = "file:" ^ Config.project_root in
let file_loc = {Sarifbug_j.uri= file; uriBaseId= absolute_project_root} in
let region =
match column with
| -1 ->
Expand Down