From 65b801107cb5e2de9842da45a7e3d1d228ff4aa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Scha=CC=88fer?= <101886095+PeterSchafer@users.noreply.github.com> Date: Wed, 12 Feb 2025 08:20:03 +0100 Subject: [PATCH] fix(code): Support single file test for golang native implementation --- cliv2/go.mod | 2 +- cliv2/go.sum | 4 ++-- .../acceptance/snyk-code/snyk-code.spec.ts | 22 ++++++++++++++++++- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/cliv2/go.mod b/cliv2/go.mod index 5822024e73..66edd4f2e0 100644 --- a/cliv2/go.mod +++ b/cliv2/go.mod @@ -15,7 +15,7 @@ require ( github.com/snyk/cli-extension-sbom v0.0.0-20241016065306-0df2be5b3b8f github.com/snyk/container-cli v0.0.0-20240821111304-7ca1c415a5d7 github.com/snyk/error-catalog-golang-public v0.0.0-20250121101159-e6a61b2bfae6 - github.com/snyk/go-application-framework v0.0.0-20250205081247-7a253efc2b0c + github.com/snyk/go-application-framework v0.0.0-20250212083751-0fa149ffbf72 github.com/snyk/go-httpauth v0.0.0-20240307114523-1f5ea3f55c65 github.com/snyk/snyk-iac-capture v0.6.5 github.com/snyk/snyk-ls v0.0.0-20250211120001-7122ee6defea diff --git a/cliv2/go.sum b/cliv2/go.sum index dad771f7ec..10e3cb953c 100644 --- a/cliv2/go.sum +++ b/cliv2/go.sum @@ -778,8 +778,8 @@ github.com/snyk/container-cli v0.0.0-20240821111304-7ca1c415a5d7 h1:Zn5BcV76oFAb github.com/snyk/container-cli v0.0.0-20240821111304-7ca1c415a5d7/go.mod h1:38w+dcAQp9eG3P5t2eNS9eG0reut10AeJjLv5lJ5lpM= github.com/snyk/error-catalog-golang-public v0.0.0-20250121101159-e6a61b2bfae6 h1:qY954YMn/7TaapgatD1bn4hfGQSmu56W6EgS2m8c++I= github.com/snyk/error-catalog-golang-public v0.0.0-20250121101159-e6a61b2bfae6/go.mod h1:Ytttq7Pw4vOCu9NtRQaOeDU2dhBYUyNBe6kX4+nIIQ4= -github.com/snyk/go-application-framework v0.0.0-20250205081247-7a253efc2b0c h1:FAZ18Wx6iqz0w5N1CfEFq4sjL5MiMbjaCQX7ogFwDfw= -github.com/snyk/go-application-framework v0.0.0-20250205081247-7a253efc2b0c/go.mod h1:ag3sCoHGCn534oDAnAXLcjZEZljW3oMOfKCzpmFX060= +github.com/snyk/go-application-framework v0.0.0-20250212083751-0fa149ffbf72 h1:r/jEVadfrBHn8wFYWrE4qq4kBAYnD9p9s3GN/MtfqUo= +github.com/snyk/go-application-framework v0.0.0-20250212083751-0fa149ffbf72/go.mod h1:ag3sCoHGCn534oDAnAXLcjZEZljW3oMOfKCzpmFX060= github.com/snyk/go-httpauth v0.0.0-20240307114523-1f5ea3f55c65 h1:CEQuYv0Go6MEyRCD3YjLYM2u3Oxkx8GpCpFBd4rUTUk= github.com/snyk/go-httpauth v0.0.0-20240307114523-1f5ea3f55c65/go.mod h1:88KbbvGYlmLgee4OcQ19yr0bNpXpOr2kciOthaSzCAg= github.com/snyk/policy-engine v0.33.0 h1:nXH4LEVrYbEuSEq4RJBObRY2fduaXiovAJt3Kni1baY= diff --git a/test/jest/acceptance/snyk-code/snyk-code.spec.ts b/test/jest/acceptance/snyk-code/snyk-code.spec.ts index 8f64205266..d96bc572a2 100644 --- a/test/jest/acceptance/snyk-code/snyk-code.spec.ts +++ b/test/jest/acceptance/snyk-code/snyk-code.spec.ts @@ -617,7 +617,7 @@ describe('snyk code test', () => { } }); - it('with --severity-threashold', async () => { + it('with --severity-threshold', async () => { const { stdout, stderr, code } = await runSnykCLI( `code test ${pathToTest} --severity-threshold=high --sarif-file-output=${sarifFile}`, { @@ -670,6 +670,26 @@ describe('snyk code test', () => { }); }, ); + + describe(`with ignored issues`, () => { + it('test a single file', async () => { + const { stderr, code } = await runSnykCLI( + `code test ${localPath}/routes/index.js --sarif-file-output=${sarifFile}`, + { + env: { + ...process.env, + ...integrationEnv, + }, + }, + ); + + expect(code).toBe(0); + expect(stderr).toBe(''); + + // Verify SARIF file + checkSarif(sarifFile, 4); + }); + }); } }); },