Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit de4c2c6

Browse files
glourschris-crone
andauthored
fix issue when scanning a local image with the snyk containerized pro… (#152)
* fix issue when scanning a local image with the Snyk containerized provider * Update e2e/scan_test.go Co-authored-by: Chris Crone <christopher.crone@docker.com> Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
1 parent 14be450 commit de4c2c6

3 files changed

Lines changed: 27 additions & 5 deletions

File tree

e2e/scan_test.go

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const (
4141
ImageWithoutVulnerabilities = "hello-world"
4242
InvalidImage = "dockerscanci/scratch:1.0" // FROM scratch
4343
ImageBaseImageVulnerabilities = "dockerscanci/base-image-vulns:1.0" // FROM alpine:3.10.0
44+
LocalBuildImage = "local:build"
4445
)
4546

4647
func TestScanFailsNoAuthentication(t *testing.T) {
@@ -369,7 +370,7 @@ func TestScanWithContainerizedSnyk(t *testing.T) {
369370
name: "invalid-docker-archive",
370371
image: InvalidImage,
371372
exitCode: 1,
372-
contains: "Invalid Docker archive",
373+
contains: "(HTTP code 500) server error - empty export - not implemented",
373374
},
374375
{
375376
name: "image-with-vulnerabilities",
@@ -394,6 +395,27 @@ func TestScanWithContainerizedSnyk(t *testing.T) {
394395
}
395396
}
396397

398+
func TestScanLocalImageWithContainerizedSnyk(t *testing.T) {
399+
if runtime.GOOS != "linux" {
400+
t.Skip("Can't run on this ci platform (windows containers or no engine installed)")
401+
}
402+
homeDir, cleanFunction := createSnykConfFile(t, os.Getenv("E2E_TEST_AUTH_TOKEN"))
403+
defer cleanFunction()
404+
405+
cmd, configDir, cleanup := dockerCli.createTestCmd()
406+
defer cleanup()
407+
createScanConfigFileOptinAndPath(t, configDir, true, "")
408+
409+
// Build a local image
410+
cmd.Command = dockerCli.Command("build", "-f", "./testdata/Dockerfile", "-t", LocalBuildImage, ".")
411+
cmd.Env = append(cmd.Env, fmt.Sprintf("HOME=%s", homeDir.Path()))
412+
icmd.RunCmd(cmd).Assert(t, icmd.Success)
413+
414+
cmd.Command = dockerCli.Command("scan", LocalBuildImage)
415+
output := icmd.RunCmd(cmd).Assert(t, icmd.Expected{ExitCode: 1}).Combined()
416+
assert.Assert(t, strings.Contains(output, "vulnerability found"))
417+
}
418+
397419
func createSnykConfDirectories(t *testing.T, withConfFile bool, token string) (*fs.Dir, func()) {
398420
content := fmt.Sprintf(`{"api" : "%s"}`, token)
399421
var confFiles []fs.PathOp

e2e/version_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func TestVersionWithoutSnykOrConfig(t *testing.T) {
105105
expected := fmt.Sprintf(`Version: %s
106106
Git commit: %s
107107
Provider: %s
108-
`, internal.Version, internal.GitCommit, "Snyk (1.461.0 (standalone))")
108+
`, internal.Version, internal.GitCommit, getProviderVersion("SNYK_DESKTOP_VERSION"))
109109
res.Assert(t, icmd.Expected{
110110
ExitCode: 0,
111111
Out: expected,

vars.mk

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Pinned Versions
2-
SNYK_DESKTOP_VERSION=1.461.0
2+
SNYK_DESKTOP_VERSION=1.563.0
33
SNYK_USER_VERSION=1.460.0
44
SNYK_OLD_VERSION=1.382.1
5-
# Digest of the 1.461.0 snyk/snyk:alpine image
6-
SNYK_IMAGE_DIGEST=sha256:b0353b1e0530a10c854f0ddeb871749490301c57c17ff1229fab3cd0b96cff23
5+
# Digest of the 1.563.0 snyk/snyk:docker image
6+
SNYK_IMAGE_DIGEST=sha256:defb5ba5517a29a78736d919d3dc0568f555980a43daefe1ac8a1e7fc0924f25
77
GO_VERSION=1.15.0
88
CLI_VERSION=19.03.9
99
ALPINE_VERSION=3.12.0

0 commit comments

Comments
 (0)