From 17b9a5b7fa8fbbdd04665ac6d230c6faa1dc3485 Mon Sep 17 00:00:00 2001
From: Andre Maroneze <andre.maroneze@cea.fr>
Date: Thu, 8 Oct 2020 16:09:00 +0200
Subject: [PATCH] [Markdown-report] placate SARIF validator

---
 src/plugins/markdown-report/sarif.ml               |  4 +++-
 src/plugins/markdown-report/sarif_gen.ml           |  6 ++++--
 .../tests/sarif/oracle/with-libc.sarif.clean       | 14 +++++++++-----
 .../tests/sarif/oracle/without-libc.sarif.clean    | 14 +++++++++-----
 4 files changed, 25 insertions(+), 13 deletions(-)

diff --git a/src/plugins/markdown-report/sarif.ml b/src/plugins/markdown-report/sarif.ml
index 92fbd5de6e7..2e7dd60ca16 100644
--- a/src/plugins/markdown-report/sarif.ml
+++ b/src/plugins/markdown-report/sarif.ml
@@ -460,6 +460,7 @@ module Driver = struct
     semanticVersion: (string [@default ""]);
     fileVersion: (string [@default ""]);
     downloadUri: (string [@default ""]);
+    informationUri: (string [@default ""]);
     sarifLoggerVersion: (string [@default ""]);
     language: (string [@default "en-US"]);
     properties: (Properties.t [@default Properties.default]);
@@ -472,13 +473,14 @@ module Driver = struct
       ?(semanticVersion="")
       ?(fileVersion="")
       ?(downloadUri="")
+      ?(informationUri="")
       ?(sarifLoggerVersion="")
       ?(language="en-US")
       ?(properties=Properties.default)
       ()
     =
     { name; fullName; version; semanticVersion; fileVersion;
-      downloadUri; sarifLoggerVersion; language; properties }
+      downloadUri; informationUri; sarifLoggerVersion; language; properties }
 
   let default = create ~name:"" ()
 end
diff --git a/src/plugins/markdown-report/sarif_gen.ml b/src/plugins/markdown-report/sarif_gen.ml
index 6a8607eaf03..a68a627085d 100644
--- a/src/plugins/markdown-report/sarif_gen.ml
+++ b/src/plugins/markdown-report/sarif_gen.ml
@@ -28,8 +28,10 @@ let frama_c_sarif =
   let semanticVersion = Fc_config.version in
   let fullName = name ^ "-" ^ version in
   let downloadUri = "https://frama-c.com/download.html" in
+  let informationUri = "https://frama-c.com" in
   Tool.create
-    (Driver.create ~name ~version ~semanticVersion ~fullName ~downloadUri ())
+    (Driver.create ~name ~version ~semanticVersion ~fullName ~downloadUri
+       ~informationUri ())
 
 let get_remarks () =
   let f = Mdr_params.Remarks.get () in
@@ -226,7 +228,7 @@ let gen_run remarks =
   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
+        (name, `Assoc [("uri", `String ("file://" ^ dir ^ "/"))]) :: acc
       ) [] uriBases
   in
   let originalUriBaseIds =
diff --git a/src/plugins/markdown-report/tests/sarif/oracle/with-libc.sarif.clean b/src/plugins/markdown-report/tests/sarif/oracle/with-libc.sarif.clean
index 06c27eb99d3..5ab08127ec0 100644
--- a/src/plugins/markdown-report/tests/sarif/oracle/with-libc.sarif.clean
+++ b/src/plugins/markdown-report/tests/sarif/oracle/with-libc.sarif.clean
@@ -10,7 +10,8 @@
           "fullName": "frama-c-21.1+dev (Scandium)",
           "version": "21.1+dev (Scandium)",
           "semanticVersion": "21.1+dev",
-          "downloadUri": "https://frama-c.com/download.html"
+          "downloadUri": "https://frama-c.com/download.html",
+          "informationUri": "https://frama-c.com"
         }
       },
       "invocations": [
@@ -28,11 +29,14 @@
         }
       ],
       "originalUriBaseIds": {
-        "FRAMAC_SHARE": { "uri": "REPLACED_FOR_PTESTS_FRAMAC_SHARE" },
-        "FRAMAC_LIB": { "uri": "REPLACED_FOR_PTESTS_FRAMAC_LIB" },
-        "FRAMAC_PLUGIN": { "uri": "REPLACED_FOR_PTESTS_FRAMAC_PLUGIN" },
+        "FRAMAC_SHARE": { "uri": "file://REPLACED_FOR_PTESTS_FRAMAC_SHARE/" },
+        "FRAMAC_LIB": { "uri": "file://REPLACED_FOR_PTESTS_FRAMAC_LIB/" },
+        "FRAMAC_PLUGIN": {
+          "uri": "file://REPLACED_FOR_PTESTS_FRAMAC_PLUGIN/"
+        },
         "PWD": {
-          "uri": "REPLACED_FOR_PTESTS_PWD"
+          "uri":
+            "file://REPLACED_FOR_PTESTS_PWD/"
         }
       },
       "artifacts": [
diff --git a/src/plugins/markdown-report/tests/sarif/oracle/without-libc.sarif.clean b/src/plugins/markdown-report/tests/sarif/oracle/without-libc.sarif.clean
index ba8d4dd7921..c874741c93b 100644
--- a/src/plugins/markdown-report/tests/sarif/oracle/without-libc.sarif.clean
+++ b/src/plugins/markdown-report/tests/sarif/oracle/without-libc.sarif.clean
@@ -10,7 +10,8 @@
           "fullName": "frama-c-21.1+dev (Scandium)",
           "version": "21.1+dev (Scandium)",
           "semanticVersion": "21.1+dev",
-          "downloadUri": "https://frama-c.com/download.html"
+          "downloadUri": "https://frama-c.com/download.html",
+          "informationUri": "https://frama-c.com"
         }
       },
       "invocations": [
@@ -28,11 +29,14 @@
         }
       ],
       "originalUriBaseIds": {
-        "FRAMAC_SHARE": { "uri": "REPLACED_FOR_PTESTS_FRAMAC_SHARE" },
-        "FRAMAC_LIB": { "uri": "REPLACED_FOR_PTESTS_FRAMAC_LIB" },
-        "FRAMAC_PLUGIN": { "uri": "REPLACED_FOR_PTESTS_FRAMAC_PLUGIN" },
+        "FRAMAC_SHARE": { "uri": "file://REPLACED_FOR_PTESTS_FRAMAC_SHARE/" },
+        "FRAMAC_LIB": { "uri": "file://REPLACED_FOR_PTESTS_FRAMAC_LIB/" },
+        "FRAMAC_PLUGIN": {
+          "uri": "file://REPLACED_FOR_PTESTS_FRAMAC_PLUGIN/"
+        },
         "PWD": {
-          "uri": "REPLACED_FOR_PTESTS_PWD"
+          "uri":
+            "file://REPLACED_FOR_PTESTS_PWD/"
         }
       },
       "artifacts": [
-- 
GitLab