diff --git a/src/plugins/markdown-report/sarif.ml b/src/plugins/markdown-report/sarif.ml index e6c489fd59bf6ddb372e665572260fec26da292f..6d64ba13288348529cc0f575951c9401a1d7107b 100644 --- a/src/plugins/markdown-report/sarif.ml +++ b/src/plugins/markdown-report/sarif.ml @@ -644,6 +644,25 @@ module File = struct lastModifiedTime: (string [@default ""]); properties: (Properties.t [@default Properties.default]); }[@@deriving yojson] + + let create + ?(fileLocation = FileLocation.default) + ?(parentKey = "") + ?(offset = 0) + ?(length = 0) + ?(roles = []) + ?(mimeType = "") + ?(contents = FileContent.default) + ?(encoding = "") + ?(hashes = []) + ?(lastModifiedTime = "") + ?(properties = Properties.default) + () + = + { + fileLocation; parentKey; offset; length; roles; mimeType; contents; + encoding; hashes; lastModifiedTime; properties + } end module FileChange = struct diff --git a/src/plugins/markdown-report/sarif_gen.ml b/src/plugins/markdown-report/sarif_gen.ml index 2309c2ff85c5345b05bb6e12d102fb1658d7e5c4..72ae96507c295256b5230c08875eae76b9154059 100644 --- a/src/plugins/markdown-report/sarif_gen.ml +++ b/src/plugins/markdown-report/sarif_gen.ml @@ -50,11 +50,22 @@ let gen_results remarks = let _, content = Alarms.fold treat_alarm (0, []) in List.rev content +let gen_files () = + let add_src_file f = + let key = Filename.chop_extension (Filename.basename f) in + let fileLocation = FileLocation.create ~uri:(Filepath.normalize f) () in + let roles = [ Role.analysisTarget ] in + let mimeType = "text/x-csrc" in + key, File.create ~fileLocation ~roles ~mimeType () + in + List.map add_src_file (Kernel.Files.get ()) + let gen_run remarks = let tool = frama_c_sarif in let invocations = [gen_invocation ()] in let results = gen_results remarks in - Run.create ~tool ~invocations ~results () + let files = gen_files () in + Run.create ~tool ~invocations ~results ~files () let generate () = let remarks = get_remarks () in