Skip to content

Commit b8336bf

Browse files
committed
Turn invalid helpUri attribute into a warning
1 parent c101242 commit b8336bf

File tree

7 files changed

+45
-30
lines changed

7 files changed

+45
-30
lines changed

lib/upload-lib.js

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/upload-lib.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/upload-lib.test.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/upload-lib.test.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/testdata/with-invalid-uri.sarif

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,42 @@
88
"name": "LGTM.com",
99
"organization": "Semmle",
1010
"version": "1.24.0-SNAPSHOT",
11-
"rules": []
11+
"rules": [
12+
{
13+
"id": "js/unused-local-variable",
14+
"shortDescription": {
15+
"text": "Unused local variable"
16+
},
17+
"helpUri": "not a valid URI"
18+
}
19+
]
1220
}
1321
},
14-
"results" : [ {
15-
"ruleId" : "js/unused-local-variable",
16-
"ruleIndex" : 0,
17-
"message" : {
18-
"text" : "Unused variable foo."
19-
},
20-
"locations" : [ {
21-
"physicalLocation" : {
22-
"artifactLocation" : {
23-
"uri" : "not a valid URI",
24-
"uriBaseId" : "%SRCROOT%",
25-
"index" : 0
26-
},
27-
"region" : {
28-
"startLine" : 2,
29-
"startColumn" : 7,
30-
"endColumn" : 10
22+
"results": [
23+
{
24+
"ruleId": "js/unused-local-variable",
25+
"ruleIndex": 0,
26+
"message": {
27+
"text": "Unused variable foo."
28+
},
29+
"locations": [
30+
{
31+
"physicalLocation": {
32+
"artifactLocation": {
33+
"uri": "not a valid URI",
34+
"uriBaseId": "%SRCROOT%",
35+
"index": 0
36+
},
37+
"region": {
38+
"startLine": 2,
39+
"startColumn": 7,
40+
"endColumn": 10
41+
}
42+
}
3143
}
32-
}
33-
} ]
34-
} ],
44+
]
45+
}
46+
],
3547
"columnKind": "utf16CodeUnits",
3648
"properties": {
3749
"semmle.formatSpecifier": "2.1.0",

src/upload-lib.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,9 +317,10 @@ test("accept results with invalid artifactLocation.uri value", (t) => {
317317
const sarifFile = `${__dirname}/../src/testdata/with-invalid-uri.sarif`;
318318
uploadLib.validateSarifFileSchema(sarifFile, mockLogger);
319319

320-
t.deepEqual(loggedMessages.length, 2);
320+
t.deepEqual(loggedMessages.length, 3);
321321
t.deepEqual(
322322
loggedMessages[1],
323+
"Warning: 'not a valid URI' is not a valid URI in 'instance.runs[0].tool.driver.rules[0].helpUri'.",
323324
"Warning: 'not a valid URI' is not a valid URI in 'instance.runs[0].results[0].locations[0].physicalLocation.artifactLocation.uri'.",
324325
);
325326
});

src/upload-lib.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,11 +449,12 @@ export function validateSarifFileSchema(sarifFilePath: string, logger: Logger) {
449449
const result = new jsonschema.Validator().validate(sarif, schema);
450450
// Filter errors related to invalid URIs in the artifactLocation field as this
451451
// is a breaking change. See https://github.com/github/codeql-action/issues/1703
452+
const warningAttributes = ["uri-reference", "uri"];
452453
const errors = (result.errors || []).filter(
453-
(err) => err.argument !== "uri-reference",
454+
(err) => !(err.name === "format" && warningAttributes.includes(err.argument)),
454455
);
455456
const warnings = (result.errors || []).filter(
456-
(err) => err.argument === "uri-reference",
457+
(err) => err.name === "format" && warningAttributes.includes(err.argument),
457458
);
458459

459460
for (const warning of warnings) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy