Commit cce26385 authored by Virgile Prevosto's avatar Virgile Prevosto
Browse files

[sarif] skeleton of sarif object generated

parent 8c1b25ab
......@@ -21,6 +21,9 @@ module Title: Parameter_sig.String
(** Value of [-mdr-stubs]. *)
module Stubs: Parameter_sig.String_list
(** version of mdr plugin itself *)
val version: string
end
module Markdown: sig
type align = Left | Center | Right
......
......@@ -70,3 +70,5 @@ module Stubs = String_list(
let arg_name = "f1,...,fn"
let help = "list of C files containing stub functions"
end)
let version = "0.1~alpha"
......@@ -20,3 +20,6 @@ module Title: Parameter_sig.String
(** Value of [-mdr-stubs]. *)
module Stubs: Parameter_sig.String_list
(** version of mdr plugin itself *)
val version: string
......@@ -329,17 +329,23 @@ module Tool = struct
properties: (Properties.t [@default Properties.default]);
}[@@deriving yojson]
let default = {
name = "";
fullName = "";
version = "";
semanticVersion = "";
fileVersion = "";
downloadUri = "";
sarifLoggerVersion = "";
language = "";
properties = Properties.default;
}
let create
~name
?(fullName="")
?(version="")
?(semanticVersion="")
?(fileVersion="")
?(downloadUri="")
?(sarifLoggerVersion="")
?(language="en-US")
?(properties=Properties.default)
()
=
{ name; fullName; version; semanticVersion; fileVersion;
downloadUri; sarifLoggerVersion; language; properties }
let default = create ~name:"" ()
end
module Invocation = struct
......@@ -721,10 +727,68 @@ module Run = struct
richMessageMimeType: (string [@default "text/markdown;variant=GFM" ]);
redactionToken: (string [@default ""]);
defaultFileEncoding: (string [@default "utf-8"]);
columnKind: (ColumnKind.t [@default UnicodeCodePoints]);
columnKind: (ColumnKind.t [@default ColumnKind.UnicodeCodePoints]);
properties: (Properties.t [@default Properties.default]);
}
[@@deriving yojson]
let create
~tool
~invocations
?(conversion=Conversion.default)
?(versionControlProvenance=[])
?(originalUriBaseIds=Additional_properties.default)
?(files=[])
?(logicalLocations=[])
?(graphs=[])
?(results=[])
?(resources=Resources.default)
?instanceGuid
?correlationGuid
?logicalId
?(description=Message.default)
?automationLogicalId
?baselineInstanceGuid
?(architecture="")
?(richMessageMimeType="text/markdown;variant=GFM")
?(redactionToken="")
?(defaultFileEncoding="utf-8")
?(columnKind=ColumnKind.UnicodeCodePoints)
?(properties=Properties.default)
()
=
let instanceGuid =
match instanceGuid with
| Some guid -> guid
| None -> failwith "use guid generation library"
in
let correlationGuid =
match correlationGuid with
| Some guid -> guid
| None -> failwith "use guid generation library"
in
let logicalId =
match logicalId with
| Some id -> id
| None -> failwith "use id generator"
in
let automationLogicalId =
match automationLogicalId with
| Some id -> id
| None -> failwith "use id generator"
in
let baselineInstanceGuid =
match baselineInstanceGuid with
| Some guid -> guid
| None -> failwith "use guid generation library"
in
{
tool; invocations; conversion; versionControlProvenance; originalUriBaseIds;
files; logicalLocations; graphs; results; resources; instanceGuid;
correlationGuid; logicalId; description; automationLogicalId;
baselineInstanceGuid; architecture; richMessageMimeType;
redactionToken; defaultFileEncoding; columnKind; properties
}
end
module Schema = struct
......@@ -733,4 +797,7 @@ module Schema = struct
version: Version.t;
runs: Run.t list
} [@@deriving yojson]
let create ?(schema=Uri.Sarif_github) ?(version=Version.V2_0_0) ~runs () =
{ schema; version; runs }
end
let generate () = Mdr_params.not_yet_implemented "Sarif_gen.generate"
open Sarif
let frama_c_sarif =
let name = "frama-c" in
let version = Config.version_and_codename in
let semanticVersion = Config.version in
let fullName = name ^ "-" ^ version in
let downloadUri = "https://frama-c.com/download.html" in
let sarifLoggerVersion = Mdr_params.version in
Tool.create
~name ~version ~semanticVersion
~fullName ~downloadUri ~sarifLoggerVersion ()
let get_remarks () =
let f = Mdr_params.Remarks.get () in
if f <> "" then Parse_remarks.get_remarks f
else Datatype.String.Map.empty
let gen_run () =
let tool = frama_c_sarif in
let invocations = [] in
Run.create ~tool ~invocations ()
let generate () =
let runs = [ gen_run () ] in
let json = Schema.create ~runs () in
let out = Mdr_params.Output.get () in
let chan =
if out = "" then stdout
else begin
try open_out out
with Sys_error s ->
Mdr_params.abort "Unable to open output file %s: %s" out s
end
in
Yojson.Safe.to_channel chan (Schema.to_yojson json)
Supports Markdown
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