diff --git a/src/plugins/markdown-report/sarif.ml b/src/plugins/markdown-report/sarif.ml index e50d9262a43d86b80a48ebdccb28b14f4bc8a12c..92fbd5de6e7aae4cdee26307045ab3c41632af77 100644 --- a/src/plugins/markdown-report/sarif.ml +++ b/src/plugins/markdown-report/sarif.ml @@ -98,10 +98,8 @@ module ArtifactLocation = struct let default = create ~uri:"" () let of_loc loc = - let open Filepath in - (* by construction, we have an absolute path here, no need for uriBase *) - let uri = ((fst loc).pos_path :> string) in - create ~uri () + let uriBaseId, uri = Filepath.(Normalized.to_base_uri (fst loc).pos_path) in + create ~uri ?uriBaseId () end module ArtifactLocationDictionary = Json_dictionary(ArtifactLocation) diff --git a/src/plugins/markdown-report/sarif_gen.ml b/src/plugins/markdown-report/sarif_gen.ml index 278073346ff33b4e1250082da7ab6c53033016af..407b4f064e11bcd4a183d05a5aaa36a895413558 100644 --- a/src/plugins/markdown-report/sarif_gen.ml +++ b/src/plugins/markdown-report/sarif_gen.ml @@ -159,7 +159,7 @@ let gen_statuses () = let gen_artifacts () = let add_src_file f = - let uri = (f:Filepath.Normalized.t :> string) in + let uri = Filepath.Normalized.to_pretty_string f in let location = ArtifactLocation.create ~uri () in let roles = [ Role.analysisTarget ] in let mimeType = "text/x-csrc" in @@ -192,7 +192,19 @@ let gen_run remarks = let taxonomies = [ToolComponent.create ~name ~rules ()] in let results = results @ user_annot_results in let artifacts = gen_artifacts () in - Run.create ~tool ~invocations ~results ~taxonomies ~artifacts () + let uriBases = ("PWD", Sys.getcwd ()) :: Filepath.all_symbolic_dirs () in + let uriBasesJson = + List.fold_left (fun acc (name, dir) -> + (name, `Assoc [("uri", `String dir)]) :: acc + ) [] uriBases + in + let originalUriBaseIds = + match ArtifactLocationDictionary.of_yojson (`Assoc uriBasesJson) with + | Ok x -> x + | Error s -> failwith s + in + Run.create ~tool ~invocations ~results ~taxonomies ~artifacts + ~originalUriBaseIds () let generate () = let remarks = get_remarks () in