Skip to content

Commit 2dd4f9e

Browse files
authored
fix: SARIF: artifactChanges property cannot be empty (#5010)
1 parent b6f5c98 commit 2dd4f9e

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

src/lib/formatters/get-sarif-result.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,26 @@ export function getResults(testResult: TestResult): sarif.Result[] {
4141
description: {
4242
text: `Upgrade to ${vuln.upgradePath[1]}`,
4343
},
44-
artifactChanges: [],
44+
artifactChanges: [
45+
{
46+
artifactLocation: {
47+
uri: getArtifactLocationUri(
48+
testResult.displayTargetFile,
49+
testResult.path,
50+
),
51+
},
52+
replacements: [
53+
{
54+
deletedRegion: {
55+
startLine: vuln.lineNumber || 1,
56+
},
57+
insertedContent: {
58+
text: vuln.upgradePath[1] as string,
59+
},
60+
},
61+
],
62+
},
63+
],
4564
},
4665
]
4766
: undefined,

test/jest/unit/lib/formatters/__snapshots__/open-source-sarif-output.spec.ts.snap

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,23 @@ Object {
99
Object {
1010
"fixes": Array [
1111
Object {
12-
"artifactChanges": Array [],
12+
"artifactChanges": Array [
13+
Object {
14+
"artifactLocation": Object {
15+
"uri": "package.json",
16+
},
17+
"replacements": Array [
18+
Object {
19+
"deletedRegion": Object {
20+
"startLine": 1,
21+
},
22+
"insertedContent": Object {
23+
"text": "[email protected]",
24+
},
25+
},
26+
],
27+
},
28+
],
1329
"description": Object {
1430
"text": "Upgrade to [email protected]",
1531
},

0 commit comments

Comments
 (0)