Skip to content

Commit 575b7b0

Browse files
committed
chore(test): update related tests for SARIF output
1 parent a9d4dbf commit 575b7b0

File tree

15 files changed

+87
-41
lines changed

15 files changed

+87
-41
lines changed

cliv2/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ require (
1818
github.com/snyk/cli-extension-sbom v0.0.0-20250801142135-ae472dafa4cd
1919
github.com/snyk/container-cli v0.0.0-20250321132345-1e2e01681dd7
2020
github.com/snyk/error-catalog-golang-public v0.0.0-20250912144134-a308b7983895
21-
github.com/snyk/go-application-framework v0.0.0-20250922075509-bb6458741916
21+
github.com/snyk/go-application-framework v0.0.0-20250923073740-f4983ce52369
2222
github.com/snyk/go-httpauth v0.0.0-20240307114523-1f5ea3f55c65
2323
github.com/snyk/snyk-iac-capture v0.6.5
2424
github.com/snyk/snyk-ls v0.0.0-20250923135355-3f907ea89fcc

cliv2/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,8 +1268,8 @@ github.com/snyk/container-cli v0.0.0-20250321132345-1e2e01681dd7 h1:/2+2piwQtB9f
12681268
github.com/snyk/container-cli v0.0.0-20250321132345-1e2e01681dd7/go.mod h1:38w+dcAQp9eG3P5t2eNS9eG0reut10AeJjLv5lJ5lpM=
12691269
github.com/snyk/error-catalog-golang-public v0.0.0-20250912144134-a308b7983895 h1:JrN/uGEMVprlres/CVMJybSKvaLuW59SfCHoT4TfvUk=
12701270
github.com/snyk/error-catalog-golang-public v0.0.0-20250912144134-a308b7983895/go.mod h1:Ytttq7Pw4vOCu9NtRQaOeDU2dhBYUyNBe6kX4+nIIQ4=
1271-
github.com/snyk/go-application-framework v0.0.0-20250922075509-bb6458741916 h1:vnaIcja//5/DTlQi8SMbx9RAGt9A295Dv5+q3IMA7FM=
1272-
github.com/snyk/go-application-framework v0.0.0-20250922075509-bb6458741916/go.mod h1:3qfDCCm6WiRb0xfX0fXlBS1sVbAbEsaCPeHEns/QVcA=
1271+
github.com/snyk/go-application-framework v0.0.0-20250923073740-f4983ce52369 h1:t86WOcUtKDIfT7UgP9Ae82Ly3cYiB9sjRlkvWFOoh2E=
1272+
github.com/snyk/go-application-framework v0.0.0-20250923073740-f4983ce52369/go.mod h1:nHVL2jzsJao6vvlJAmre0NJlK2aafOn269w3wLMoU+g=
12731273
github.com/snyk/go-httpauth v0.0.0-20240307114523-1f5ea3f55c65 h1:CEQuYv0Go6MEyRCD3YjLYM2u3Oxkx8GpCpFBd4rUTUk=
12741274
github.com/snyk/go-httpauth v0.0.0-20240307114523-1f5ea3f55c65/go.mod h1:88KbbvGYlmLgee4OcQ19yr0bNpXpOr2kciOthaSzCAg=
12751275
github.com/snyk/policy-engine v1.1.0 h1:vFbFZbs3B0Y3XuGSur5om2meo4JEcCaKfNzshZFGOUs=

test/fixtures/docker/sarif-container-result.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@
6565
}
6666
]
6767
}
68-
]
68+
],
69+
"automationDetails": {
70+
"id": "Snyk/Container/docker-image|snyk/kubernetes-monitor/2025-01-01T00:00:00.000Z"
71+
}
6972
}
7073
]
7174
}

test/fixtures/docker/sarif-with-file-container-result.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@
6565
}
6666
]
6767
}
68-
]
68+
],
69+
"automationDetails": {
70+
"id": "Snyk/Container/docker-image|snyk/kubernetes-monitor/2025-01-01T00:00:00.000Z"
71+
}
6972
}
7073
]
7174
}

test/fixtures/sast/sample-analyze-folders-response.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1698,6 +1698,9 @@
16981698
]
16991699
}
17001700
],
1701+
"automationDetails": {
1702+
"id": "Snyk/Code/2025-01-01T00:00:00.000Z"
1703+
},
17011704
"properties": {
17021705
"coverage": [
17031706
{

test/fixtures/sast/sample-sarif.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,6 +1225,9 @@
12251225
]
12261226
}
12271227
],
1228+
"automationDetails": {
1229+
"id": "Snyk/Code/2025-01-01T00:00:00.000Z"
1230+
},
12281231
"properties": {
12291232
"coverage": [
12301233
{

test/jest/unit/cli/commands/test/iac/v2/index.spec.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
import { pathToFileURL } from 'url';
1616

1717
jest.setTimeout(1000 * 10);
18+
jest.useFakeTimers().setSystemTime(new Date('2025-01-01T00:00:00.000Z'));
1819

1920
const projectRoot = path.resolve(
2021
__dirname,
@@ -143,7 +144,7 @@ describe('test', () => {
143144
'[\n {\n "ok": false,\n "code": 2114,\n "error": "",\n "path": "invalid_file.txt"\n }\n]',
144145
sarifStringifiedResults: `{\n "$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",\n "version": "2.1.0",\n "runs": [\n {\n "originalUriBaseIds": {\n "PROJECTROOT": {\n "uri": "${
145146
pathToFileURL(path.join(process.cwd(), '/')).href
146-
}",\n "description": {\n "text": "The root directory for all project files."\n }\n }\n },\n "tool": {\n "driver": {\n "name": "Snyk IaC",\n "fullName": "Snyk Infrastructure as Code",\n "version": "1.0.0-monorepo",\n "informationUri": "https://docs.snyk.io/products/snyk-infrastructure-as-code",\n "rules": []\n }\n },\n "automationDetails": {\n "id": "snyk-iac"\n },\n "results": []\n }\n ]\n}`,
147+
}",\n "description": {\n "text": "The root directory for all project files."\n }\n }\n },\n "tool": {\n "driver": {\n "name": "Snyk IaC",\n "fullName": "Snyk Infrastructure as Code",\n "version": "1.0.0-monorepo",\n "informationUri": "https://docs.snyk.io/products/snyk-infrastructure-as-code",\n "rules": []\n }\n },\n "automationDetails": {\n "id": "Snyk/IaC/2025-01-01T00:00:00.000Z"\n },\n "results": []\n }\n ]\n}`,
147148
fields: {
148149
path: 'invalid_file.txt',
149150
},
@@ -258,7 +259,7 @@ describe('test', () => {
258259
'[\n {\n "ok": false,\n "code": 2114,\n "error": "",\n "path": "invalid_file.txt"\n }\n]',
259260
sarifStringifiedResults: `{\n "$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",\n "version": "2.1.0",\n "runs": [\n {\n "originalUriBaseIds": {\n "PROJECTROOT": {\n "uri": "${
260261
pathToFileURL(path.join(process.cwd(), '/')).href
261-
}",\n "description": {\n "text": "The root directory for all project files."\n }\n }\n },\n "tool": {\n "driver": {\n "name": "Snyk IaC",\n "fullName": "Snyk Infrastructure as Code",\n "version": "1.0.0-monorepo",\n "informationUri": "https://docs.snyk.io/products/snyk-infrastructure-as-code",\n "rules": []\n }\n },\n "automationDetails": {\n "id": "snyk-iac"\n },\n "results": []\n }\n ]\n}`,
262+
}",\n "description": {\n "text": "The root directory for all project files."\n }\n }\n },\n "tool": {\n "driver": {\n "name": "Snyk IaC",\n "fullName": "Snyk Infrastructure as Code",\n "version": "1.0.0-monorepo",\n "informationUri": "https://docs.snyk.io/products/snyk-infrastructure-as-code",\n "rules": []\n }\n },\n "automationDetails": {\n "id": "Snyk/IaC/2025-01-01T00:00:00.000Z"\n },\n "results": []\n }\n ]\n}`,
262263
fields: {
263264
path: 'invalid_file.txt',
264265
},
@@ -363,18 +364,18 @@ describe('test', () => {
363364
innerError: undefined,
364365
userMessage: `{\n "$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",\n "version": "2.1.0",\n "runs": [\n {\n "originalUriBaseIds": {\n "PROJECTROOT": {\n "uri": "${
365366
pathToFileURL(path.join(process.cwd(), '/')).href
366-
}",\n "description": {\n "text": "The root directory for all project files."\n }\n }\n },\n "tool": {\n "driver": {\n "name": "Snyk IaC",\n "fullName": "Snyk Infrastructure as Code",\n "version": "1.0.0-monorepo",\n "informationUri": "https://docs.snyk.io/products/snyk-infrastructure-as-code",\n "rules": []\n }\n },\n "automationDetails": {\n "id": "snyk-iac"\n },\n "results": []\n }\n ]\n}`,
367+
}",\n "description": {\n "text": "The root directory for all project files."\n }\n }\n },\n "tool": {\n "driver": {\n "name": "Snyk IaC",\n "fullName": "Snyk Infrastructure as Code",\n "version": "1.0.0-monorepo",\n "informationUri": "https://docs.snyk.io/products/snyk-infrastructure-as-code",\n "rules": []\n }\n },\n "automationDetails": {\n "id": "Snyk/IaC/2025-01-01T00:00:00.000Z"\n },\n "results": []\n }\n ]\n}`,
367368
formattedUserMessage: `{\n "$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",\n "version": "2.1.0",\n "runs": [\n {\n "originalUriBaseIds": {\n "PROJECTROOT": {\n "uri": "${
368369
pathToFileURL(path.join(process.cwd(), '/')).href
369-
}",\n "description": {\n "text": "The root directory for all project files."\n }\n }\n },\n "tool": {\n "driver": {\n "name": "Snyk IaC",\n "fullName": "Snyk Infrastructure as Code",\n "version": "1.0.0-monorepo",\n "informationUri": "https://docs.snyk.io/products/snyk-infrastructure-as-code",\n "rules": []\n }\n },\n "automationDetails": {\n "id": "snyk-iac"\n },\n "results": []\n }\n ]\n}`,
370+
}",\n "description": {\n "text": "The root directory for all project files."\n }\n }\n },\n "tool": {\n "driver": {\n "name": "Snyk IaC",\n "fullName": "Snyk Infrastructure as Code",\n "version": "1.0.0-monorepo",\n "informationUri": "https://docs.snyk.io/products/snyk-infrastructure-as-code",\n "rules": []\n }\n },\n "automationDetails": {\n "id": "Snyk/IaC/2025-01-01T00:00:00.000Z"\n },\n "results": []\n }\n ]\n}`,
370371
json: `{\n "$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",\n "version": "2.1.0",\n "runs": [\n {\n "originalUriBaseIds": {\n "PROJECTROOT": {\n "uri": "${
371372
pathToFileURL(path.join(process.cwd(), '/')).href
372-
}",\n "description": {\n "text": "The root directory for all project files."\n }\n }\n },\n "tool": {\n "driver": {\n "name": "Snyk IaC",\n "fullName": "Snyk Infrastructure as Code",\n "version": "1.0.0-monorepo",\n "informationUri": "https://docs.snyk.io/products/snyk-infrastructure-as-code",\n "rules": []\n }\n },\n "automationDetails": {\n "id": "snyk-iac"\n },\n "results": []\n }\n ]\n}`,
373+
}",\n "description": {\n "text": "The root directory for all project files."\n }\n }\n },\n "tool": {\n "driver": {\n "name": "Snyk IaC",\n "fullName": "Snyk Infrastructure as Code",\n "version": "1.0.0-monorepo",\n "informationUri": "https://docs.snyk.io/products/snyk-infrastructure-as-code",\n "rules": []\n }\n },\n "automationDetails": {\n "id": "Snyk/IaC/2025-01-01T00:00:00.000Z"\n },\n "results": []\n }\n ]\n}`,
373374
jsonStringifiedResults:
374375
'[\n {\n "ok": false,\n "code": 2114,\n "error": "",\n "path": "invalid_file.txt"\n }\n]',
375376
sarifStringifiedResults: `{\n "$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",\n "version": "2.1.0",\n "runs": [\n {\n "originalUriBaseIds": {\n "PROJECTROOT": {\n "uri": "${
376377
pathToFileURL(path.join(process.cwd(), '/')).href
377-
}",\n "description": {\n "text": "The root directory for all project files."\n }\n }\n },\n "tool": {\n "driver": {\n "name": "Snyk IaC",\n "fullName": "Snyk Infrastructure as Code",\n "version": "1.0.0-monorepo",\n "informationUri": "https://docs.snyk.io/products/snyk-infrastructure-as-code",\n "rules": []\n }\n },\n "automationDetails": {\n "id": "snyk-iac"\n },\n "results": []\n }\n ]\n}`,
378+
}",\n "description": {\n "text": "The root directory for all project files."\n }\n }\n },\n "tool": {\n "driver": {\n "name": "Snyk IaC",\n "fullName": "Snyk Infrastructure as Code",\n "version": "1.0.0-monorepo",\n "informationUri": "https://docs.snyk.io/products/snyk-infrastructure-as-code",\n "rules": []\n }\n },\n "automationDetails": {\n "id": "Snyk/IaC/2025-01-01T00:00:00.000Z"\n },\n "results": []\n }\n ]\n}`,
378379
fields: {
379380
path: 'invalid_file.txt',
380381
},

test/jest/unit/iac/process-results/fixtures/integrated-sarif-output.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
}
7575
},
7676
"automationDetails": {
77-
"id": "snyk-iac"
77+
"id": "Snyk/IaC/input-files-for-json-v2/2025-01-01T00:00:00.000Z"
7878
},
7979
"results": [
8080
{

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ exports[`createSarifOutputForOpenSource general 1`] = `
55
"$schema": "https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json",
66
"runs": [
77
{
8+
"automationDetails": {
9+
"id": "Snyk/Open Source/PROJECT_NAME/2025-01-01T00:00:00.000Z",
10+
},
811
"results": [
912
{
1013
"fixes": [

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ exports[`createSarifOutputForContainers general with critical severity issue wit
55
"$schema": "https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json",
66
"runs": [
77
{
8+
"automationDetails": {
9+
"id": "Snyk/Container/PROJECT_NAME/2025-01-01T00:00:00.000Z",
10+
},
811
"results": [
912
{
1013
"fixes": undefined,
@@ -99,6 +102,9 @@ exports[`createSarifOutputForContainers general with critical severity issue wit
99102
"$schema": "https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json",
100103
"runs": [
101104
{
105+
"automationDetails": {
106+
"id": "Snyk/Container/PROJECT_NAME/2025-01-01T00:00:00.000Z",
107+
},
102108
"results": [
103109
{
104110
"fixes": undefined,
@@ -192,6 +198,9 @@ exports[`createSarifOutputForContainers general with high severity issue 1`] = `
192198
"$schema": "https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json",
193199
"runs": [
194200
{
201+
"automationDetails": {
202+
"id": "Snyk/Container/PROJECT_NAME/2025-01-01T00:00:00.000Z",
203+
},
195204
"results": [
196205
{
197206
"fixes": undefined,

0 commit comments

Comments
 (0)