diff --git a/package-lock.json b/package-lock.json index 7b11ba85c9..23c480bb24 100644 --- a/package-lock.json +++ b/package-lock.json @@ -68,7 +68,7 @@ "semver": "^6.0.0", "snyk-config": "^5.0.0", "snyk-cpp-plugin": "2.24.0", - "snyk-docker-plugin": "6.11.1", + "snyk-docker-plugin": "6.12.0", "snyk-go-plugin": "1.23.0", "snyk-gradle-plugin": "4.1.0", "snyk-module": "3.1.0", @@ -20728,9 +20728,9 @@ "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" }, "node_modules/snyk-docker-plugin": { - "version": "6.11.1", - "resolved": "https://registry.npmjs.org/snyk-docker-plugin/-/snyk-docker-plugin-6.11.1.tgz", - "integrity": "sha512-R9Bi37+LJNs0JNJokfmwFe/I+VfWG2ajQrguvduZ/2cIrKcXl8wvx5ajUl4Q/r+PB9iT1qJyTZTOFT/cr8oVtg==", + "version": "6.12.0", + "resolved": "https://registry.npmjs.org/snyk-docker-plugin/-/snyk-docker-plugin-6.12.0.tgz", + "integrity": "sha512-DW5dKi9dSM3RDLDlOVYA5FAARo5NdZSBlS01bNccLOQRCbpndgo2TLr5/1Z9uJ4A8FLIrgKLpQzrHsT5wU7ABA==", "dependencies": { "@snyk/composer-lockfile-parser": "^1.4.1", "@snyk/dep-graph": "^2.8.1", @@ -20750,7 +20750,7 @@ "packageurl-js": "1.2.0", "semver": "^7.6.0", "shescape": "^1.7.4", - "snyk-nodejs-lockfile-parser": "^1.52.11", + "snyk-nodejs-lockfile-parser": "^1.53.0", "snyk-poetry-lockfile-parser": "^1.4.0", "tar-stream": "^2.1.0", "tmp": "^0.2.1", @@ -40403,9 +40403,9 @@ } }, "snyk-docker-plugin": { - "version": "6.11.1", - "resolved": "https://registry.npmjs.org/snyk-docker-plugin/-/snyk-docker-plugin-6.11.1.tgz", - "integrity": "sha512-R9Bi37+LJNs0JNJokfmwFe/I+VfWG2ajQrguvduZ/2cIrKcXl8wvx5ajUl4Q/r+PB9iT1qJyTZTOFT/cr8oVtg==", + "version": "6.12.0", + "resolved": "https://registry.npmjs.org/snyk-docker-plugin/-/snyk-docker-plugin-6.12.0.tgz", + "integrity": "sha512-DW5dKi9dSM3RDLDlOVYA5FAARo5NdZSBlS01bNccLOQRCbpndgo2TLr5/1Z9uJ4A8FLIrgKLpQzrHsT5wU7ABA==", "requires": { "@snyk/composer-lockfile-parser": "^1.4.1", "@snyk/dep-graph": "^2.8.1", @@ -40425,7 +40425,7 @@ "packageurl-js": "1.2.0", "semver": "^7.6.0", "shescape": "^1.7.4", - "snyk-nodejs-lockfile-parser": "^1.52.11", + "snyk-nodejs-lockfile-parser": "^1.53.0", "snyk-poetry-lockfile-parser": "^1.4.0", "tar-stream": "^2.1.0", "tmp": "^0.2.1", diff --git a/package.json b/package.json index 93773c7294..04df27d45c 100644 --- a/package.json +++ b/package.json @@ -116,7 +116,7 @@ "semver": "^6.0.0", "snyk-config": "^5.0.0", "snyk-cpp-plugin": "2.24.0", - "snyk-docker-plugin": "6.11.1", + "snyk-docker-plugin": "6.12.0", "snyk-go-plugin": "1.23.0", "snyk-gradle-plugin": "4.1.0", "snyk-module": "3.1.0", diff --git a/test/fixtures/container-projects/npm7-with-package-lock-file.tar b/test/fixtures/container-projects/npm7-with-package-lock-file.tar new file mode 100644 index 0000000000..a6cd274faa Binary files /dev/null and b/test/fixtures/container-projects/npm7-with-package-lock-file.tar differ diff --git a/test/fixtures/container-projects/npm7-without-package-and-lock-file.tar b/test/fixtures/container-projects/npm7-without-package-and-lock-file.tar new file mode 100644 index 0000000000..c9917485b2 Binary files /dev/null and b/test/fixtures/container-projects/npm7-without-package-and-lock-file.tar differ diff --git a/test/fixtures/container-projects/npm7-without-package-lock-file.tar b/test/fixtures/container-projects/npm7-without-package-lock-file.tar new file mode 100644 index 0000000000..3962b14b04 Binary files /dev/null and b/test/fixtures/container-projects/npm7-without-package-lock-file.tar differ diff --git a/test/jest/acceptance/snyk-container/container.spec.ts b/test/jest/acceptance/snyk-container/container.spec.ts index 284761d547..077392ef0c 100644 --- a/test/jest/acceptance/snyk-container/container.spec.ts +++ b/test/jest/acceptance/snyk-container/container.spec.ts @@ -117,6 +117,42 @@ describe('snyk container', () => { await expect(cli).toDisplay(`yum @ 4.9.0`, { timeout: 60 * 1000 }); }); + it('npm depGraph is generated in an npm image with lockfiles', async () => { + const { code, stdout, stderr } = await runSnykCLIWithDebug( + `container test docker-archive:test/fixtures/container-projects/npm7-with-package-lock-file.tar --print-deps`, + ); + + assertCliExitCode(code, 1, stderr); + expect(stdout).toContain('Package manager: npm'); + }); + + it('npm depGraph is generated in an npm image without package-lock.json file', async () => { + const { code, stdout, stderr } = await runSnykCLIWithDebug( + `container test docker-archive:test/fixtures/container-projects/npm7-without-package-lock-file.tar --print-deps`, + ); + + assertCliExitCode(code, 1, stderr); + expect(stdout).toContain('Package manager: npm'); + }); + + it('npm depGraph is generated in an npm image without package-lock.json and package.json file', async () => { + const { code, stdout, stderr } = await runSnykCLIWithDebug( + `container test docker-archive:test/fixtures/container-projects/npm7-without-package-and-lock-file.tar --print-deps`, + ); + + assertCliExitCode(code, 1, stderr); + expect(stdout).toContain('Package manager: npm'); + }); + + it('npm depGraph is generated in an npm image with lockfiles image', async () => { + const { code, stdout, stderr } = await runSnykCLIWithDebug( + `container test docker-archive:test/fixtures/container-projects/npm7-without-package-lock-file.tar --print-deps`, + ); + + assertCliExitCode(code, 1, stderr); + expect(stdout).toContain('Package manager: npm'); + }); + it('finds dependencies in oci image (library/ubuntu)', async () => { cli = await startSnykCLI( 'container test library/ubuntu@sha256:7a57c69fe1e9d5b97c5fe649849e79f2cfc3bf11d10bbd5218b4eb61716aebe6 --print-deps', diff --git a/test/jest/acceptance/snyk-test/app-vuln-container-project.spec.ts b/test/jest/acceptance/snyk-test/app-vuln-container-project.spec.ts index c56e846f21..9c0efb2419 100644 --- a/test/jest/acceptance/snyk-test/app-vuln-container-project.spec.ts +++ b/test/jest/acceptance/snyk-test/app-vuln-container-project.spec.ts @@ -44,12 +44,29 @@ describe('container test projects behavior with --app-vulns, --file and --exclud ); const jsonOutput = JSON.parse(stdout); expect(Array.isArray(jsonOutput)).toBeFalsy(); - expect(jsonOutput.applications).toBeUndefined(); expect(jsonOutput.ok).toEqual(false); expect(jsonOutput.uniqueCount).toBeGreaterThan(0); expect(code).toEqual(1); }, 30000); + it('should find vulns on an npm project application image without package-lock.json file', async () => { + const { code, stdout } = await runSnykCLI( + `container test docker-archive:test/fixtures/container-projects/npm7-without-package-lock-file.tar --json --app-vulns`, + ); + const jsonOutput = JSON.parse(stdout); + expect(Array.isArray(jsonOutput)).toBeFalsy(); + expect(jsonOutput.uniqueCount).toBeGreaterThan(0); + expect(code).toEqual(1); + }, 60000); + + it('should find vulns on an npm project application image without package.json and package-lock.json file', async () => { + const { code, stdout } = await runSnykCLI( + `container test docker-archive:test/fixtures/container-projects/npm7-without-package-and-lock-file.tar --print-deps --app-vulns`, + ); + expect(code).toEqual(1); + expect(stdout).toContain('Package manager: npm'); + }, 60000); + it('should show app vulns tip when available', async () => { const { stdout } = await runSnykCLI( `container test docker-archive:test/fixtures/container-projects/os-packages-and-app-vulns.tar`,