From 2ab4e9ead92e6f6a64152424303b0d7f0feffe8a Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Tue, 23 Jul 2024 18:24:27 +0200 Subject: [PATCH] SONAR-22603 Manual fix of the SARIF schema See https://github.com/oasis-tcs/sarif-spec/issues/105 --- sonar-sarif/build.gradle | 2 +- .../src/main/resources/sarif/README.md | 3 + .../resources/sarif/sarif-schema-2.1.0.json | 130 +----------------- 3 files changed, 10 insertions(+), 125 deletions(-) create mode 100644 sonar-sarif/src/main/resources/sarif/README.md diff --git a/sonar-sarif/build.gradle b/sonar-sarif/build.gradle index befefe045c3..23466430d27 100644 --- a/sonar-sarif/build.gradle +++ b/sonar-sarif/build.gradle @@ -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 index 00000000000..b6da51b0ef7 --- /dev/null +++ b/sonar-sarif/src/main/resources/sarif/README.md @@ -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 diff --git a/sonar-sarif/src/main/resources/sarif/sarif-schema-2.1.0.json b/sonar-sarif/src/main/resources/sarif/sarif-schema-2.1.0.json index 0f58372b548..2d0e7f543e3 100644 --- a/sonar-sarif/src/main/resources/sarif/sarif-schema-2.1.0.json +++ b/sonar-sarif/src/main/resources/sarif/sarif-schema-2.1.0.json @@ -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": { @@ -97,14 +95,12 @@ "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 }, @@ -134,7 +130,6 @@ "parentIndex": { "description": "Identifies the index of the immediate parent of the artifact, if this artifact is nested.", "type": "integer", - "default": -1, "minimum": -1 }, @@ -147,7 +142,6 @@ "length": { "description": "The length of the artifact in bytes.", "type": "integer", - "default": -1, "minimum": -1 }, @@ -156,7 +150,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "enum": [ "analysisTarget", @@ -308,7 +301,6 @@ "index": { "description": "The index within the run artifacts array of the artifact object associated with the artifact location.", "type": "integer", - "default": -1, "minimum": -1 }, @@ -345,7 +337,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/region" } @@ -356,7 +347,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/rectangle" } @@ -446,7 +436,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/artifactLocation" } @@ -562,7 +551,6 @@ "type": "array", "minItems": 0, "uniqueItems": false, - "default": [], "items": { "$ref": "#/definitions/exception" } @@ -614,7 +602,6 @@ "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" @@ -641,7 +628,6 @@ "type": "array", "minItems": 0, "uniqueItems": false, - "default": [], "items": { "$ref": "#/definitions/invocation" } @@ -652,7 +638,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/logicalLocation" } @@ -663,7 +648,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/threadFlowLocation" } @@ -674,7 +658,6 @@ "type": "array", "minItems": 0, "uniqueItems": false, - "default": [], "items": { "$ref": "#/definitions/result" } @@ -685,7 +668,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/toolComponent" } @@ -701,7 +683,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/toolComponent" } @@ -712,7 +693,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/toolComponent" } @@ -723,7 +703,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/toolComponent" } @@ -734,7 +713,6 @@ "type": "array", "minItems": 0, "uniqueItems": false, - "default": [], "items": { "$ref": "#/definitions/address" } @@ -745,7 +723,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/webRequest" } @@ -756,7 +733,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/webResponse" } @@ -789,7 +765,6 @@ "itemCount": { "description": "A non-negative integer specifying the number of items contained in the external property file.", "type": "integer", - "default": -1, "minimum": -1 }, @@ -820,7 +795,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/externalPropertyFileReference" } @@ -836,7 +810,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/externalPropertyFileReference" } @@ -847,7 +820,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/externalPropertyFileReference" } @@ -858,7 +830,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/externalPropertyFileReference" } @@ -869,7 +840,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/externalPropertyFileReference" } @@ -880,7 +850,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/externalPropertyFileReference" } @@ -891,7 +860,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/externalPropertyFileReference" } @@ -902,7 +870,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/externalPropertyFileReference" } @@ -918,7 +885,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/externalPropertyFileReference" } @@ -929,7 +895,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/externalPropertyFileReference" } @@ -940,7 +905,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/externalPropertyFileReference" } @@ -951,7 +915,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/externalPropertyFileReference" } @@ -962,7 +925,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/externalPropertyFileReference" } @@ -1020,7 +982,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/node" } @@ -1031,7 +992,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/edge" } @@ -1053,14 +1013,12 @@ "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 }, @@ -1090,7 +1048,6 @@ "type": "array", "minItems": 0, "uniqueItems": false, - "default": [], "items": { "$ref": "#/definitions/edgeTraversal" } @@ -1159,7 +1116,6 @@ "description": "An array of configurationOverride objects that describe rules related runtime overrides.", "type": "array", "minItems": 0, - "default": [], "uniqueItems": true, "items": { "$ref": "#/definitions/configurationOverride" @@ -1170,7 +1126,6 @@ "description": "An array of configurationOverride objects that describe notifications related runtime overrides.", "type": "array", "minItems": 0, - "default": [], "uniqueItems": true, "items": { "$ref": "#/definitions/configurationOverride" @@ -1182,7 +1137,6 @@ "type": "array", "minItems": 0, "uniqueItems": false, - "default": [], "items": { "$ref": "#/definitions/notification" } @@ -1193,7 +1147,6 @@ "type": "array", "minItems": 0, "uniqueItems": false, - "default": [], "items": { "$ref": "#/definitions/notification" } @@ -1294,8 +1247,7 @@ "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": { @@ -1308,7 +1260,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/logicalLocation" } @@ -1324,7 +1275,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/region" } @@ -1333,7 +1283,6 @@ "relationships": { "description": "An array of objects that describe relationships between this location and others.", "type": "array", - "default": [], "minItems": 0, "uniqueItems": true, "items": { @@ -1363,7 +1312,6 @@ "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" @@ -1397,7 +1345,6 @@ "index": { "description": "The index within the logical locations array.", "type": "integer", - "default": -1, "minimum": -1 }, @@ -1414,7 +1361,6 @@ "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 }, @@ -1457,7 +1403,6 @@ "type": "array", "minItems": 0, "uniqueItems": false, - "default": [], "items": { "type": "string" } @@ -1526,7 +1471,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/node" } @@ -1552,7 +1496,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/location" } @@ -1565,7 +1508,6 @@ "level": { "description": "A value specifying the severity level of the notification.", - "default": "warning", "enum": [ "none", "note", "warning", "error" ], "type": "string" }, @@ -1658,7 +1600,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "type": "string" } @@ -1737,7 +1678,6 @@ "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 }, @@ -1750,7 +1690,6 @@ "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 }, @@ -1903,7 +1842,6 @@ "relationships": { "description": "An array of objects that describe relationships between this reporting descriptor and others.", "type": "array", - "default": [], "minItems": 0, "uniqueItems": true, "items": { @@ -1927,13 +1865,11 @@ "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" }, @@ -1941,7 +1877,6 @@ "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 }, @@ -1972,7 +1907,6 @@ "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 }, @@ -2013,7 +1947,6 @@ "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" @@ -2047,7 +1980,6 @@ "ruleIndex": { "description": "The index within the tool component rules array of the rule object associated with this result.", "type": "integer", - "default": -1, "minimum": -1 }, @@ -2058,14 +1990,12 @@ "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" }, @@ -2085,7 +2015,6 @@ "type": "array", "minItems": 0, "uniqueItems": false, - "default": [], "items": { "$ref": "#/definitions/location" } @@ -2130,7 +2059,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/stack" } @@ -2141,7 +2069,6 @@ "type": "array", "minItems": 0, "uniqueItems": false, - "default": [], "items": { "$ref": "#/definitions/codeFlow" } @@ -2152,7 +2079,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/graph" } @@ -2163,7 +2089,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/graphTraversal" } @@ -2174,7 +2099,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/location" } @@ -2204,7 +2128,6 @@ "rank": { "description": "A number representing the priority or importance of the result.", "type": "number", - "default": -1.0, "minimum": -1.0, "maximum": 100.0 }, @@ -2214,7 +2137,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/attachment" } @@ -2247,7 +2169,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/fix" } @@ -2256,7 +2177,6 @@ "taxa": { "description": "An array of references to taxonomy reporting descriptors that are applicable to the result.", "type": "array", - "default": [], "minItems": 0, "uniqueItems": true, "items": { @@ -2315,7 +2235,6 @@ "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 }, @@ -2324,7 +2243,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/physicalLocation" } @@ -2353,7 +2271,6 @@ "type": "array", "minItems": 0, "uniqueItems": false, - "default": [], "items": { "$ref": "#/definitions/invocation" } @@ -2367,7 +2284,6 @@ "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})?$" }, @@ -2376,7 +2292,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/versionControlDetails" } @@ -2405,7 +2320,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/logicalLocation" } @@ -2416,7 +2330,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/graph" } @@ -2442,7 +2355,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/runAutomationDetails" } @@ -2459,7 +2371,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "type": "string" } @@ -2480,7 +2391,6 @@ "type": "array", "minItems": 1, "uniqueItems": true, - "default": [ "\r\n", "\n" ], "items": { "type": "string" } @@ -2502,7 +2412,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/threadFlowLocation" } @@ -2513,7 +2422,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/toolComponent" } @@ -2524,7 +2432,6 @@ "type": "array", "minItems": 0, "uniqueItems": false, - "default": [], "items": { "$ref": "#/definitions/address" } @@ -2535,7 +2442,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/toolComponent" } @@ -2546,7 +2452,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/toolComponent" } @@ -2557,7 +2462,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/webRequest" } @@ -2568,7 +2472,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/webResponse" } @@ -2696,10 +2599,8 @@ "type": "array", "minItems": 0, "uniqueItems": false, - "default": [], "items": { - "type": "string", - "default": [] + "type": "string" } }, @@ -2820,7 +2721,6 @@ "index": { "description": "The index within the run threadFlowLocations array.", "type": "integer", - "default": -1, "minimum": -1 }, @@ -2839,7 +2739,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "type": "string" } @@ -2848,7 +2747,6 @@ "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": { @@ -2878,7 +2776,6 @@ "executionOrder": { "description": "An integer representing the temporal order in which execution reached this location.", "type": "integer", - "default": -1, "minimum": -1 }, @@ -2891,7 +2788,6 @@ "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" }, @@ -2928,7 +2824,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/toolComponent" } @@ -3036,7 +2931,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/reportingDescriptor" } @@ -3047,7 +2941,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/reportingDescriptor" } @@ -3058,7 +2951,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/reportingDescriptor" } @@ -3068,7 +2960,6 @@ "description": "An array of the artifactLocation objects associated with the tool component.", "type": "array", "minItems": 0, - "default": [], "items": { "$ref": "#/definitions/artifactLocation" } @@ -3077,7 +2968,6 @@ "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})?$" }, @@ -3085,7 +2975,6 @@ "description": "The kinds of data contained in this object.", "type": "array", "uniqueItems": true, - "default": [ "localizedData", "nonLocalizedData" ], "items": { "enum": [ "localizedData", @@ -3097,8 +2986,7 @@ "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": { @@ -3126,7 +3014,6 @@ "type": "array", "minItems": 0, "uniqueItems": true, - "default": [], "items": { "$ref": "#/definitions/toolComponentReference" } @@ -3155,7 +3042,6 @@ "index": { "description": "An index into the referenced toolComponent in tool.extensions.", "type": "integer", - "default": -1, "minimum": -1 }, @@ -3274,9 +3160,7 @@ "index": { "description": "The index within the run.webRequests array of the request object associated with this result.", "type": "integer", - "default": -1, "minimum": -1 - }, "protocol": { @@ -3336,7 +3220,6 @@ "index": { "description": "The index within the run.webResponses array of the response object associated with this result.", "type": "integer", - "default": -1, "minimum": -1 }, @@ -3375,8 +3258,7 @@ "noResponseReceived": { "description": "Specifies whether a response was received from the server.", - "type": "boolean", - "default": false + "type": "boolean" }, "properties": { -- 2.39.5