Commit 726be74c authored by Virgile Prevosto's avatar Virgile Prevosto
Browse files

sample program results passes Sarif 2.1.0 validation

parent ce371426
......@@ -87,37 +87,6 @@ struct
let v2_1_0 = "2.1.0"
end
module Message = struct
type t = {
text: (string [@default ""]);
messageId: (string [@default ""]);
richText: (string [@default ""]);
richMessageId: (string [@default ""]);
arguments: (string list [@default []]);
}[@@deriving yojson]
let create
?(text="")
?(messageId="")
?(richText="")
?(richMessageId="")
?(arguments=[])
()
=
{ text; messageId; richText; richMessageId; arguments }
let plain_text ~text ?id:messageId ?arguments () =
create ~text ?messageId ?arguments ()
let markdown ~markdown ?id:richMessageId ?arguments () =
let pp fmt = Markdown.pp_elements fmt in
let richText = String.trim (Format.asprintf "@[%a@]" pp markdown)
in
create ~richText ?richMessageId ?arguments ()
let default = create ()
end
module ArtifactLocation = struct
type t = {
uri: string;
......@@ -177,6 +146,37 @@ module Properties = struct
| _ -> `Assoc (("tags", tags_to_yojson tags)::additional_properties)
end
module Message = struct
type t = {
text: (string [@default ""]);
id: (string [@default ""]);
markdown: (string [@default ""]);
arguments: (string list [@default []]);
properties: (Properties.t [@default Properties.default]);
}[@@deriving yojson]
let create
?(text="")
?(id="")
?(markdown="")
?(arguments=[])
?(properties=Properties.default)
()
=
{ text; id; markdown; arguments; properties }
let plain_text ~text ?id ?arguments () =
create ~text ?id ?arguments ()
let markdown ~markdown ?id ?arguments () =
let pp fmt = Markdown.pp_elements fmt in
let markdown = String.trim (Format.asprintf "@[%a@]" pp markdown)
in
create ~markdown ?id ?arguments ()
let default = create ()
end
module MultiformatMessageString = struct
type t = {
text: string;
......@@ -1019,7 +1019,7 @@ module Sarif_result = struct
}[@@deriving yojson]
let create
?(ruleId = "")
~ruleId
?(kind=Result_kind.pass)
?(level=Result_level.none)
?(message=Message.default)
......@@ -1420,7 +1420,7 @@ end
module Schema = struct
type t = {
schema: (Uri.t [@default Uri.sarif_github]) [@key "$schema"];
schema: Uri.t [@key "$schema"];
version: Version.t;
runs: Run.t list
} [@@deriving yojson]
......
......@@ -101,11 +101,11 @@ let make_message alarm annot remark =
| [] -> summary :: gen_remark alarm
| _ -> summary :: remark
in
let richText =
let markdown =
String.trim
(Format.asprintf "@[%a@]" (Markdown.pp_elements ~page:"") markdown)
in
Message.create ~text ~richText ()
Message.create ~text ~markdown ()
let opt_physical_location_of_loc loc =
if loc = Cil_datatype.Location.unknown then []
......@@ -142,12 +142,14 @@ let make_ip_message ip =
let text = Format.asprintf "@[%a.@]" Property.short_pretty ip in
Message.plain_text ~text ()
let user_annot_id = "user-spec"
let gen_status ip =
let status = Property_status.Feedback.get ip in
let level = level_of_status status in
let locations = opt_physical_location_of_loc (Property.location ip) in
let message = make_ip_message ip in
Sarif_result.create ~level ~locations ~message ()
Sarif_result.create ~ruleId:user_annot_id ~level ~locations ~message ()
let gen_statuses () =
let f ip content =
......@@ -184,7 +186,7 @@ let gen_run remarks =
| [] -> rules
| _ ->
Datatype.String.Map.add
"user-spec" "User-written ACSL specification" rules
user_annot_id "User-written ACSL specification" rules
in
let rules = make_taxonomies rules in
let taxonomies = [ToolComponent.create ~name ~rules ()] in
......
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