From e7387d7b21922c174f5f0659488b3df04bb79a8a Mon Sep 17 00:00:00 2001
From: Virgile Prevosto <virgile.prevosto@m4x.org>
Date: Thu, 8 Aug 2019 15:33:26 +0200
Subject: [PATCH] [sarif] more accurate command line in presence of -load

---
 src/plugins/markdown-report/sarif_gen.ml | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/plugins/markdown-report/sarif_gen.ml b/src/plugins/markdown-report/sarif_gen.ml
index df7eba96489..ea8e9bd9b01 100644
--- a/src/plugins/markdown-report/sarif_gen.ml
+++ b/src/plugins/markdown-report/sarif_gen.ml
@@ -22,9 +22,20 @@ let get_remark remarks label =
   | None -> []
   | Some l -> l
 
+let command_line () = Array.to_list Sys.argv
+
+module Analysis_cmdline =
+  State_builder.Ref(Datatype.List(Datatype.String))
+    (struct
+      let name = "Sarif_gen.Analysis_cmdline"
+      let dependencies = []
+      let default = command_line
+    end)
+
 let gen_invocation () =
-  let commandLine = Array.fold_right (fun s acc -> s ^ " " ^ acc) Sys.argv "" in
-  let arguments = List.tl (Array.to_list Sys.argv) in
+  let cl = Analysis_cmdline.get () in
+  let commandLine = String.concat " " cl in
+  let arguments = List.tl cl in
   Invocation.create ~commandLine ~arguments ()
 
 let gen_remark alarm =
-- 
GitLab