]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Add Schema to the SARIF report
authorViljar Indus <indus@adacore.com>
Fri, 11 Oct 2024 10:19:04 +0000 (13:19 +0300)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Mon, 4 Nov 2024 15:57:57 +0000 (16:57 +0100)
gcc/ada/ChangeLog:

* diagnostics-sarif_emitter.adb (Print_SARIF_Report): Add a
Schema field to the SARIF report.

gcc/ada/diagnostics-sarif_emitter.adb

index cbb423b2e1ddaaddf86c8060d745da05a60cedae..fe251f9754dbca01f58f4d7e2d8d3a2d107d9475 100644 (file)
@@ -31,6 +31,14 @@ with Sinput;                 use Sinput;
 
 package body Diagnostics.SARIF_Emitter is
 
+   --  We are currently using SARIF 2.1.0
+
+   SARIF_Version : constant String := "2.1.0";
+   pragma Style_Checks ("M100");
+   SARIF_Schema  : constant String :=
+     "https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json";
+   pragma Style_Checks ("M79");
+
    type Artifact_Change is record
       File  : String_Ptr;
       --  Name of the file
@@ -1074,7 +1082,11 @@ package body Diagnostics.SARIF_Emitter is
       Begin_Block;
       NL_And_Indent;
 
-      Write_String_Attribute ("version", "2.1.0");
+      Write_String_Attribute ("$schema", SARIF_Schema);
+      Write_Char (',');
+      NL_And_Indent;
+
+      Write_String_Attribute ("version", SARIF_Version);
       Write_Char (',');
       NL_And_Indent;