]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-22603 Manual fix of the SARIF schema
authorJulien HENRY <julien.henry@sonarsource.com>
Tue, 23 Jul 2024 16:24:27 +0000 (18:24 +0200)
committersonartech <sonartech@sonarsource.com>
Wed, 24 Jul 2024 20:02:47 +0000 (20:02 +0000)
See https://github.com/oasis-tcs/sarif-spec/issues/105

sonar-sarif/build.gradle
sonar-sarif/src/main/resources/sarif/README.md [new file with mode: 0644]
sonar-sarif/src/main/resources/sarif/sarif-schema-2.1.0.json

index befefe045c35ed42721b63b0f2bd9a56a48ff4cd..23466430d27c7ad8fb954ab108b928a99db9e9ff 100644 (file)
@@ -8,7 +8,7 @@ dependencies {
 }
 
 jsonSchema2Pojo {
-  source = files("${sourceSets.main.output.resourcesDir}/sarif")
+  source = files("${sourceSets.main.output.resourcesDir}/sarif/sarif-schema-2.1.0.json")
   generateBuilders = true
   inclusionLevel = "NON_DEFAULT"
   initializeCollections = false
diff --git a/sonar-sarif/src/main/resources/sarif/README.md b/sonar-sarif/src/main/resources/sarif/README.md
new file mode 100644 (file)
index 0000000..b6da51b
--- /dev/null
@@ -0,0 +1,3 @@
+# Diff from the official schema
+
+- Remove all `default` from the schema. This is mostly to fix [Issue #105](https://github.com/oasis-tcs/sarif-spec/issues/105)  but also to prevent all indexes and ids to have -1 as default value, while null is better in Java.
\ No newline at end of file
index 0f58372b548f60c84d20fca77687435e71b3b3a3..2d0e7f543e36c18b9b533c0d777745b71497a6a2 100644 (file)
@@ -58,9 +58,7 @@
         "absoluteAddress": {
           "description": "The address expressed as a byte offset from the start of the addressable region.",
           "type": "integer",
-          "minimum": -1,
-          "default": -1
-
+          "minimum": -1
         },
 
         "relativeAddress": {
         "index": {
           "description": "The index within run.addresses of the cached object for this address.",
           "type": "integer",
-          "default": -1,
           "minimum": -1
         },
 
         "parentIndex": {
           "description": "The index within run.addresses of the parent object.",
           "type": "integer",
-          "default": -1,
           "minimum": -1
         },
 
         "parentIndex": {
           "description": "Identifies the index of the immediate parent of the artifact, if this artifact is nested.",
           "type": "integer",
-          "default": -1,
           "minimum": -1
         },
 
         "length": {
           "description": "The length of the artifact in bytes.",
           "type": "integer",
-          "default": -1,
           "minimum": -1
         },
 
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "enum": [
               "analysisTarget",
         "index": {
           "description": "The index within the run artifacts array of the artifact object associated with the artifact location.",
           "type": "integer",
-          "default": -1,
           "minimum": -1
         },
 
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/region"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/rectangle"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/artifactLocation"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": false,
-          "default": [],
           "items": {
             "$ref": "#/definitions/exception"
           }
           "description": "An array of graph objects that will be merged with a separate run.",
           "type": "array",
           "minItems": 0,
-          "default": [],
           "uniqueItems": true,
           "items": {
             "$ref": "#/definitions/graph"
           "type": "array",
           "minItems": 0,
           "uniqueItems": false,
-          "default": [],
           "items": {
             "$ref": "#/definitions/invocation"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/logicalLocation"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/threadFlowLocation"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": false,
-          "default": [],
           "items": {
             "$ref": "#/definitions/result"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/toolComponent"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/toolComponent"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/toolComponent"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/toolComponent"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": false,
-          "default": [],
           "items": {
             "$ref": "#/definitions/address"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/webRequest"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/webResponse"
           }
         "itemCount": {
           "description": "A non-negative integer specifying the number of items contained in the external property file.",
           "type": "integer",
-          "default": -1,
           "minimum": -1
         },
 
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/externalPropertyFileReference"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/externalPropertyFileReference"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/externalPropertyFileReference"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/externalPropertyFileReference"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/externalPropertyFileReference"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/externalPropertyFileReference"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/externalPropertyFileReference"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/externalPropertyFileReference"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/externalPropertyFileReference"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/externalPropertyFileReference"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/externalPropertyFileReference"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/externalPropertyFileReference"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/externalPropertyFileReference"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/node"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/edge"
           }
         "runGraphIndex": {
           "description": "The index within the run.graphs to be associated with the result.",
           "type": "integer",
-          "default": -1,
           "minimum": -1
         },
 
         "resultGraphIndex": {
           "description": "The index within the result.graphs to be associated with the result.",
           "type": "integer",
-          "default": -1,
           "minimum": -1
         },
 
           "type": "array",
           "minItems": 0,
           "uniqueItems": false,
-          "default": [],
           "items": {
             "$ref": "#/definitions/edgeTraversal"
           }
           "description": "An array of configurationOverride objects that describe rules related runtime overrides.",
           "type": "array",
           "minItems": 0,
-          "default": [],
           "uniqueItems": true,
           "items": {
             "$ref": "#/definitions/configurationOverride"
           "description": "An array of configurationOverride objects that describe notifications related runtime overrides.",
           "type": "array",
           "minItems": 0,
-          "default": [],
           "uniqueItems": true,
           "items": {
             "$ref": "#/definitions/configurationOverride"
           "type": "array",
           "minItems": 0,
           "uniqueItems": false,
-          "default": [],
           "items": {
             "$ref": "#/definitions/notification"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": false,
-          "default": [],
           "items": {
             "$ref": "#/definitions/notification"
           }
         "id": {
           "description": "Value that distinguishes this location from all other locations within a single result object.",
           "type": "integer",
-          "minimum": -1,
-          "default": -1
+          "minimum": -1
         },
 
         "physicalLocation": {
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/logicalLocation"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/region"
           }
         "relationships": {
           "description": "An array of objects that describe relationships between this location and others.",
           "type": "array",
-          "default": [],
           "minItems": 0,
           "uniqueItems": true,
           "items": {
         "kinds": {
           "description": "A set of distinct strings that categorize the relationship. Well-known kinds include 'includes', 'isIncludedBy' and 'relevant'.",
           "type": "array",
-          "default": [ "relevant" ],
           "uniqueItems": true,
           "items": {
             "type": "string"
         "index": {
           "description": "The index within the logical locations array.",
           "type": "integer",
-          "default": -1,
           "minimum": -1
         },
 
         "parentIndex": {
           "description": "Identifies the index of the immediate parent of the construct in which the result was detected. For example, this property might point to a logical location that represents the namespace that holds a type.",
           "type": "integer",
-          "default": -1,
           "minimum": -1
         },
 
           "type": "array",
           "minItems": 0,
           "uniqueItems": false,
-          "default": [],
           "items": {
             "type": "string"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/node"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/location"
           }
 
         "level": {
           "description": "A value specifying the severity level of the notification.",
-          "default": "warning",
           "enum": [ "none", "note", "warning", "error" ],
           "type": "string"
         },
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "type": "string"
           }
         "charOffset": {
           "description": "The zero-based offset from the beginning of the artifact of the first character in the region.",
           "type": "integer",
-          "default": -1,
           "minimum": -1
         },
 
         "byteOffset": {
           "description": "The zero-based offset from the beginning of the artifact of the first byte in the region.",
           "type": "integer",
-          "default": -1,
           "minimum": -1
         },
 
         "relationships": {
           "description": "An array of objects that describe relationships between this reporting descriptor and others.",
           "type": "array",
-          "default": [],
           "minItems": 0,
           "uniqueItems": true,
           "items": {
 
         "enabled": {
           "description": "Specifies whether the report may be produced during the scan.",
-          "type": "boolean",
-          "default": true
+          "type": "boolean"
         },
 
         "level": {
           "description": "Specifies the failure level for the report.",
-          "default": "warning",
           "enum": [ "none", "note", "warning", "error" ],
           "type": "string"
         },
         "rank": {
           "description": "Specifies the relative priority of the report. Used for analysis output only.",
           "type": "number",
-          "default": -1.0,
           "minimum": -1.0,
           "maximum": 100.0
         },
         "index": {
           "description": "The index into an array of descriptors in toolComponent.ruleDescriptors, toolComponent.notificationDescriptors, or toolComponent.taxonomyDescriptors, depending on context.",
           "type": "integer",
-          "default": -1,
           "minimum": -1
         },
 
         "kinds": {
           "description": "A set of distinct strings that categorize the relationship. Well-known kinds include 'canPrecede', 'canFollow', 'willPrecede', 'willFollow', 'superset', 'subset', 'equal', 'disjoint', 'relevant', and 'incomparable'.",
           "type": "array",
-          "default": [ "relevant" ],
           "uniqueItems": true,
           "items": {
             "type": "string"
         "ruleIndex": {
           "description": "The index within the tool component rules array of the rule object associated with this result.",
           "type": "integer",
-          "default": -1,
           "minimum": -1
         },
 
 
         "kind": {
           "description": "A value that categorizes results by evaluation state.",
-          "default": "fail",
           "enum": [ "notApplicable", "pass", "fail", "review", "open", "informational" ],
           "type": "string"
         },
 
         "level": {
           "description": "A value specifying the severity level of the result.",
-          "default": "warning",
           "enum": [ "none", "note", "warning", "error" ],
           "type": "string"
         },
           "type": "array",
           "minItems": 0,
           "uniqueItems": false,
-          "default": [],
           "items": {
             "$ref": "#/definitions/location"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/stack"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": false,
-          "default": [],
           "items": {
             "$ref": "#/definitions/codeFlow"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/graph"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/graphTraversal"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/location"
           }
         "rank": {
           "description": "A number representing the priority or importance of the result.",
           "type": "number",
-          "default": -1.0,
           "minimum": -1.0,
           "maximum": 100.0
         },
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/attachment"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/fix"
           }
         "taxa": {
           "description": "An array of references to taxonomy reporting descriptors that are applicable to the result.",
           "type": "array",
-          "default": [],
           "minItems": 0,
           "uniqueItems": true,
           "items": {
         "invocationIndex": {
           "description": "The index within the run.invocations array of the invocation object which describes the tool invocation that detected the result.",
           "type": "integer",
-          "default": -1,
           "minimum": -1
         },
 
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/physicalLocation"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": false,
-          "default": [],
           "items": {
             "$ref": "#/definitions/invocation"
           }
         "language": {
           "description": "The language of the messages emitted into the log file during this run (expressed as an ISO 639-1 two-letter lowercase culture code) and an optional region (expressed as an ISO 3166-1 two-letter uppercase subculture code associated with a country or region). The casing is recommended but not required (in order for this data to conform to RFC5646).",
           "type": "string",
-          "default": "en-US",
           "pattern": "^[a-zA-Z]{2}(-[a-zA-Z]{2})?$"
         },
 
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/versionControlDetails"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/logicalLocation"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/graph"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/runAutomationDetails"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "type": "string"
           }
           "type": "array",
           "minItems": 1,
           "uniqueItems": true,
-          "default": [ "\r\n", "\n" ],
           "items": {
             "type": "string"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/threadFlowLocation"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/toolComponent"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": false,
-          "default": [],
           "items": {
             "$ref": "#/definitions/address"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/toolComponent"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/toolComponent"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/webRequest"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/webResponse"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": false,
-          "default": [],
           "items": {
-            "type": "string",
-            "default": []
+            "type": "string"
           }
         },
 
         "index": {
           "description": "The index within the run threadFlowLocations array.",
           "type": "integer",
-          "default": -1,
           "minimum": -1
         },
 
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "type": "string"
           }
         "taxa": {
           "description": "An array of references to rule or taxonomy reporting descriptors that are applicable to the thread flow location.",
           "type": "array",
-          "default": [],
           "minItems": 0,
           "uniqueItems": true,
           "items": {
         "executionOrder": {
           "description": "An integer representing the temporal order in which execution reached this location.",
           "type": "integer",
-          "default": -1,
           "minimum": -1
         },
 
         "importance": {
           "description": "Specifies the importance of this location in understanding the code flow in which it occurs. The order from most to least important is \"essential\", \"important\", \"unimportant\". Default: \"important\".",
           "enum": [ "important", "essential", "unimportant" ],
-          "default": "important",
           "type": "string"
         },
 
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/toolComponent"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/reportingDescriptor"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/reportingDescriptor"
           }
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/reportingDescriptor"
           }
           "description": "An array of the artifactLocation objects associated with the tool component.",
           "type": "array",
           "minItems": 0,
-          "default": [],
           "items": {
             "$ref": "#/definitions/artifactLocation"
           }
         "language": {
           "description": "The language of the messages emitted into the log file during this run (expressed as an ISO 639-1 two-letter lowercase language code) and an optional region (expressed as an ISO 3166-1 two-letter uppercase subculture code associated with a country or region). The casing is recommended but not required (in order for this data to conform to RFC5646).",
           "type": "string",
-          "default": "en-US",
           "pattern": "^[a-zA-Z]{2}(-[a-zA-Z]{2})?$"
         },
 
           "description": "The kinds of data contained in this object.",
           "type": "array",
           "uniqueItems": true,
-          "default": [ "localizedData", "nonLocalizedData" ],
           "items": {
             "enum": [
               "localizedData",
 
         "isComprehensive": {
           "description": "Specifies whether this object contains a complete definition of the localizable and/or non-localizable data for this component, as opposed to including only data that is relevant to the results persisted to this log file.",
-          "type": "boolean",
-          "default": false
+          "type": "boolean"
         },
 
         "localizedDataSemanticVersion": {
           "type": "array",
           "minItems": 0,
           "uniqueItems": true,
-          "default": [],
           "items": {
             "$ref": "#/definitions/toolComponentReference"
           }
         "index": {
           "description": "An index into the referenced toolComponent in tool.extensions.",
           "type": "integer",
-          "default": -1,
           "minimum": -1
         },
 
         "index": {
           "description": "The index within the run.webRequests array of the request object associated with this result.",
           "type": "integer",
-          "default": -1,
           "minimum": -1
-
         },
 
         "protocol": {
         "index": {
           "description": "The index within the run.webResponses array of the response object associated with this result.",
           "type": "integer",
-          "default": -1,
           "minimum": -1
         },
 
 
         "noResponseReceived": {
           "description": "Specifies whether a response was received from the server.",
-          "type": "boolean",
-          "default": false
+          "type": "boolean"
         },
 
         "properties": {