Commit beb92eac authored by Andre Maroneze's avatar Andre Maroneze 💬 Committed by Virgile Prevosto
Browse files

[Filepath/MdR] fix issues with PWD in to_base_uri and SARIF reports

parent 32a822dd
......@@ -277,22 +277,19 @@ module Normalized = struct
with _ -> false
let to_base_uri name =
if is_relative name then None, skip_dot name
else begin
let p = insert cwd name in
let buf = Buffer.create 80 in
let res = add_uri_path buf p in
let uri =
Buffer.contents buf in
let uri =
try
if String.get uri 0 = '/' then
String.sub uri 1 (String.length uri - 1)
else uri
with Invalid_argument _ -> uri
in
res, uri
end
let p = insert cwd name in
let buf = Buffer.create 80 in
let res = add_uri_path buf p in
let uri =
Buffer.contents buf in
let uri =
try
if String.get uri 0 = '/' then
String.sub uri 1 (String.length uri - 1)
else uri
with Invalid_argument _ -> uri
in
res, uri
end
type position =
......
......@@ -196,8 +196,8 @@ let gen_statuses () =
let gen_artifacts () =
let add_src_file f =
let uri = Filepath.Normalized.to_pretty_string f in
let location = ArtifactLocation.create ~uri () in
let uriBaseId, uri = Filepath.Normalized.to_base_uri f in
let location = ArtifactLocation.create ~uri ?uriBaseId () in
let roles = [ Role.analysisTarget ] in
let mimeType = "text/x-csrc" in
Artifact.create ~location ~roles ~mimeType ()
......
......@@ -36,7 +36,7 @@
},
"artifacts": [
{
"location": { "uri": "tests/sarif/libc.c" },
"location": { "uri": "tests/sarif/libc.c", "uriBaseId": "PWD" },
"roles": [ "analysisTarget" ],
"mimeType": "text/x-csrc"
}
......@@ -8680,8 +8680,8 @@
{
"physicalLocation": {
"artifactLocation": {
"uri":
"/home/andr/git/frama-c-2/src/plugins/markdown-report/tests/sarif/libc.c"
"uri": "tests/sarif/libc.c",
"uriBaseId": "PWD"
},
"region": {
"startLine": 13,
......
......@@ -36,7 +36,7 @@
},
"artifacts": [
{
"location": { "uri": "tests/sarif/libc.c" },
"location": { "uri": "tests/sarif/libc.c", "uriBaseId": "PWD" },
"roles": [ "analysisTarget" ],
"mimeType": "text/x-csrc"
}
......@@ -53,8 +53,8 @@
{
"physicalLocation": {
"artifactLocation": {
"uri":
"/home/andr/git/frama-c-2/src/plugins/markdown-report/tests/sarif/libc.c"
"uri": "tests/sarif/libc.c",
"uriBaseId": "PWD"
},
"region": {
"startLine": 13,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment