@@ -21,6 +21,7 @@ import (
2121 "fmt"
2222 "io/ioutil"
2323 "os"
24+ "path"
2425 "path/filepath"
2526 "runtime"
2627 "strings"
@@ -110,7 +111,7 @@ func TestScanSucceedWithDockerHub(t *testing.T) {
110111}
111112
112113func TestScanWithSnyk (t * testing.T ) {
113- if runtime .GOOS == "windows" || runtime . GOOS == "darwin " {
114+ if runtime .GOOS != "linux " {
114115 t .Skip ("Can't run on this ci platform (windows containers or no engine installed)" )
115116 }
116117 _ , cleanFunction := createSnykConfFile (t , os .Getenv ("E2E_TEST_AUTH_TOKEN" ))
@@ -164,7 +165,7 @@ func TestScanWithSnyk(t *testing.T) {
164165}
165166
166167func TestScanJsonOutput (t * testing.T ) {
167- if runtime .GOOS == "windows" || runtime . GOOS == "darwin " {
168+ if runtime .GOOS != "linux " {
168169 t .Skip ("Can't run on this ci platform (windows containers or no engine installed)" )
169170 }
170171 _ , cleanFunction := createSnykConfFile (t , os .Getenv ("E2E_TEST_AUTH_TOKEN" ))
@@ -216,7 +217,7 @@ type JSONOutput struct {
216217}
217218
218219func TestScanWithFileAndExcludeBaseImageVulns (t * testing.T ) {
219- if runtime .GOOS == "windows" || runtime . GOOS == "darwin " {
220+ if runtime .GOOS != "linux " {
220221 t .Skip ("Can't run on this ci platform (windows containers or no engine installed)" )
221222 }
222223 _ , cleanFunction := createSnykConfFile (t , os .Getenv ("E2E_TEST_AUTH_TOKEN" ))
@@ -233,7 +234,7 @@ func TestScanWithFileAndExcludeBaseImageVulns(t *testing.T) {
233234}
234235
235236func TestScanWithExcludeBaseImageVulns (t * testing.T ) {
236- if runtime .GOOS == "windows" || runtime . GOOS == "darwin " {
237+ if runtime .GOOS != "linux " {
237238 t .Skip ("Can't run on this ci platform (windows containers or no engine installed)" )
238239 }
239240 _ , cleanFunction := createSnykConfFile (t , os .Getenv ("E2E_TEST_AUTH_TOKEN" ))
@@ -251,7 +252,7 @@ func TestScanWithExcludeBaseImageVulns(t *testing.T) {
251252}
252253
253254func TestScanWithDependencies (t * testing.T ) {
254- if runtime .GOOS == "windows" || runtime . GOOS == "darwin " {
255+ if runtime .GOOS != "linux " {
255256 t .Skip ("Can't run on this ci platform (windows containers or no engine installed)" )
256257 }
257258 _ , cleanFunction := createSnykConfFile (t , os .Getenv ("E2E_TEST_AUTH_TOKEN" ))
@@ -269,7 +270,7 @@ func TestScanWithDependencies(t *testing.T) {
269270}
270271
271272func TestScanWithSeverity (t * testing.T ) {
272- if runtime .GOOS == "windows" || runtime . GOOS == "darwin " {
273+ if runtime .GOOS != "linux " {
273274 t .Skip ("Can't run on this ci platform (windows containers or no engine installed)" )
274275 }
275276 _ , cleanFunction := createSnykConfFile (t , os .Getenv ("E2E_TEST_AUTH_TOKEN" ))
@@ -288,7 +289,7 @@ func TestScanWithSeverity(t *testing.T) {
288289}
289290
290291func TestScanWithSeverityBadValue (t * testing.T ) {
291- if runtime .GOOS == "windows" || runtime . GOOS == "darwin " {
292+ if runtime .GOOS != "linux " {
292293 t .Skip ("Can't run on this ci platform (windows containers or no engine installed)" )
293294 }
294295 _ , cleanFunction := createSnykConfFile (t , os .Getenv ("E2E_TEST_AUTH_TOKEN" ))
@@ -306,7 +307,7 @@ func TestScanWithSeverityBadValue(t *testing.T) {
306307}
307308
308309func TestScanWithJsonAndGroupIssues (t * testing.T ) {
309- if runtime .GOOS == "windows" || runtime . GOOS == "darwin " {
310+ if runtime .GOOS != "linux " {
310311 t .Skip ("Can't run on this ci platform (windows containers or no engine installed)" )
311312 }
312313 _ , cleanFunction := createSnykConfFile (t , os .Getenv ("E2E_TEST_AUTH_TOKEN" ))
@@ -326,7 +327,7 @@ func TestScanWithJsonAndGroupIssues(t *testing.T) {
326327}
327328
328329func TestScanWithGroupIssues (t * testing.T ) {
329- if runtime .GOOS == "windows" || runtime . GOOS == "darwin " {
330+ if runtime .GOOS != "linux " {
330331 t .Skip ("Can't run on this ci platform (windows containers or no engine installed)" )
331332 }
332333 _ , cleanFunction := createSnykConfFile (t , os .Getenv ("E2E_TEST_AUTH_TOKEN" ))
@@ -344,7 +345,7 @@ func TestScanWithGroupIssues(t *testing.T) {
344345}
345346
346347func TestScanWithContainerizedSnyk (t * testing.T ) {
347- if runtime .GOOS == "windows" || runtime . GOOS == "darwin " {
348+ if runtime .GOOS != "linux " {
348349 t .Skip ("Can't run on this ci platform (windows containers or no engine installed)" )
349350 }
350351 homeDir , cleanFunction := createSnykConfFile (t , os .Getenv ("E2E_TEST_AUTH_TOKEN" ))
@@ -399,7 +400,7 @@ func TestScanLocalImageWithContainerizedSnyk(t *testing.T) {
399400 if runtime .GOOS != "linux" {
400401 t .Skip ("Can't run on this ci platform (windows containers or no engine installed)" )
401402 }
402- homeDir , cleanFunction := createSnykConfFile (t , os .Getenv ("E2E_TEST_AUTH_TOKEN" ))
403+ _ , cleanFunction := createSnykConfFile (t , os .Getenv ("E2E_TEST_AUTH_TOKEN" ))
403404 defer cleanFunction ()
404405
405406 cmd , configDir , cleanup := dockerCli .createTestCmd ()
@@ -408,14 +409,31 @@ func TestScanLocalImageWithContainerizedSnyk(t *testing.T) {
408409
409410 // Build a local image
410411 cmd .Command = dockerCli .Command ("build" , "-f" , "./testdata/Dockerfile" , "-t" , LocalBuildImage , "." )
411- cmd .Env = append (cmd .Env , fmt .Sprintf ("HOME=%s" , homeDir .Path ()))
412412 icmd .RunCmd (cmd ).Assert (t , icmd .Success )
413413
414414 cmd .Command = dockerCli .Command ("scan" , LocalBuildImage )
415415 output := icmd .RunCmd (cmd ).Assert (t , icmd.Expected {ExitCode : 1 }).Combined ()
416416 assert .Assert (t , strings .Contains (output , "vulnerability found" ))
417417}
418418
419+ func TestScanWithFileAndExcludeBaseImageVulnsContainerizedProvider (t * testing.T ) {
420+ if runtime .GOOS != "linux" {
421+ t .Skip ("Can't run on this ci platform (windows containers or no engine installed)" )
422+ }
423+ pwd , _ := os .Getwd ()
424+ dockerfilePath := path .Join (pwd , "/testdata/Dockerfile" )
425+ _ , cleanFunction := createSnykConfFile (t , os .Getenv ("E2E_TEST_AUTH_TOKEN" ))
426+ defer cleanFunction ()
427+
428+ cmd , configDir , cleanup := dockerCli .createTestCmd ()
429+ defer cleanup ()
430+ createScanConfigFileOptinAndPath (t , configDir , true , "" )
431+
432+ cmd .Command = dockerCli .Command ("scan" , "--file" , dockerfilePath , "--exclude-base" , ImageBaseImageVulnerabilities )
433+ output := icmd .RunCmd (cmd ).Assert (t , icmd .Success ).Combined ()
434+ assert .Assert (t , strings .Contains (output , "found 0 issues." ))
435+ }
436+
419437func createSnykConfDirectories (t * testing.T , withConfFile bool , token string ) (* fs.Dir , func ()) {
420438 content := fmt .Sprintf (`{"api" : "%s"}` , token )
421439 var confFiles []fs.PathOp
0 commit comments