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

Commit 9e56383

Browse files
authored
Merge pull request #134 from docker/remove-fails-on-flag
remove --fails-on flag which is always exiting with a 0 code when use…
2 parents ebe74ef + 7ccfe67 commit 9e56383

5 files changed

Lines changed: 0 additions & 71 deletions

File tree

README.md

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -261,23 +261,6 @@ Licenses: enabled
261261
Tested 200 dependencies for known issues, found 37 issues.
262262
```
263263

264-
If your image has unfixed issues, and you need to bypass the error code, you can use the `--fail-on` flag.
265-
```console
266-
$ docker scan --fail-on=upgradable docker-scan:e2e
267-
...
268-
Organization: docker-desktop-test
269-
Package manager: deb
270-
Project name: docker-image|docker-scan
271-
Docker image: docker-scan:e2e
272-
Platform: linux/amd64
273-
Licenses: enabled
274-
275-
Tested 200 dependencies for known issues, found 158 issues.
276-
277-
echo $?
278-
0
279-
```
280-
281264
### Provider Authentication
282265

283266
If you have an existing Snyk account, you can directly use your auth token

cmd/docker-scan/main.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ type options struct {
6969
showVersion bool
7070
forceOptIn bool
7171
forceOptOut bool
72-
failOn string
7372
severity string
7473
}
7574

@@ -99,7 +98,6 @@ func newScanCmd(ctx context.Context, dockerCli command.Cli) *cobra.Command {
9998
cmd.Flags().BoolVar(&flags.showVersion, "version", false, "Display version of the scan plugin")
10099
cmd.Flags().BoolVar(&flags.forceOptIn, "accept-license", false, "Accept using a third party scanning provider")
101100
cmd.Flags().BoolVar(&flags.forceOptOut, "reject-license", false, "Reject using a third party scanning provider")
102-
cmd.Flags().StringVar(&flags.failOn, "fail-on", "", "Only fail when there are vulnerabilities that can be fixed (all|upgradable|patchable)")
103101
cmd.Flags().StringVar(&flags.severity, "severity", "", "Only report vulnerabilities of provided level or higher (low|medium|high)")
104102

105103
return cmd
@@ -130,12 +128,6 @@ func configureProvider(ctx context.Context, dockerCli command.Streams, flags opt
130128
if flags.dependencyTree {
131129
opts = append(opts, provider.WithDependencyTree())
132130
}
133-
if flags.failOn != "" {
134-
if flags.failOn != "all" && flags.failOn != "upgradable" && flags.failOn != "patchable" {
135-
return nil, fmt.Errorf("--fail-on takes only 'all', 'upgradable' or 'patchable' values")
136-
}
137-
opts = append(opts, provider.WithFailOn(flags.failOn))
138-
}
139131
if flags.severity != "" {
140132
if flags.severity != "low" && flags.severity != "medium" && flags.severity != "high" {
141133
return nil, fmt.Errorf("--severity takes only 'low', 'medium' or 'high' values")

e2e/scan_test.go

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -264,42 +264,6 @@ func TestScanWithDependencies(t *testing.T) {
264264
assert.Assert(t, strings.Contains(output, "vulnerability found"))
265265
}
266266

267-
func TestScanWithFailOn(t *testing.T) {
268-
if runtime.GOOS == "windows" || runtime.GOOS == "darwin" {
269-
t.Skip("Can't run on this ci platform (windows containers or no engine installed)")
270-
}
271-
_, cleanFunction := createSnykConfFile(t, os.Getenv("E2E_TEST_AUTH_TOKEN"))
272-
defer cleanFunction()
273-
274-
cmd, configDir, cleanup := dockerCli.createTestCmd()
275-
defer cleanup()
276-
277-
createScanConfigFile(t, configDir)
278-
279-
cmd.Command = dockerCli.Command("scan", "--accept-license", "--fail-on", "upgradable", ImageWithVulnerabilities)
280-
output := icmd.RunCmd(cmd).Assert(t, icmd.Expected{ExitCode: 0}).Combined()
281-
assert.Assert(t, strings.Contains(output, "alpine:3.10.0")) // beginning of the dependency tree
282-
assert.Assert(t, cmp.Regexp("found .* issues", output))
283-
}
284-
285-
func TestScanWithFailOnBadValue(t *testing.T) {
286-
if runtime.GOOS == "windows" || runtime.GOOS == "darwin" {
287-
t.Skip("Can't run on this ci platform (windows containers or no engine installed)")
288-
}
289-
_, cleanFunction := createSnykConfFile(t, os.Getenv("E2E_TEST_AUTH_TOKEN"))
290-
defer cleanFunction()
291-
292-
cmd, configDir, cleanup := dockerCli.createTestCmd()
293-
defer cleanup()
294-
295-
createScanConfigFile(t, configDir)
296-
297-
cmd.Command = dockerCli.Command("scan", "--accept-license", "--fail-on", "unsupportedValue", ImageWithVulnerabilities)
298-
icmd.RunCmd(cmd).Assert(t, icmd.Expected{
299-
ExitCode: 1,
300-
Err: "--fail-on takes only 'all', 'upgradable' or 'patchable' values"})
301-
}
302-
303267
func TestScanWithSeverity(t *testing.T) {
304268
if runtime.GOOS == "windows" || runtime.GOOS == "darwin" {
305269
t.Skip("Can't run on this ci platform (windows containers or no engine installed)")

e2e/testdata/plugin-usage.golden

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ Options:
88
--dependency-tree Show dependency tree with scan results
99
--exclude-base Exclude base image from vulnerability scanning
1010
(requires --file)
11-
--fail-on string Only fail when there are vulnerabilities that
12-
can be fixed (all|upgradable|patchable)
1311
-f, --file string Dockerfile associated with image, provides more
1412
detailed results
1513
--json Output results in JSON format

internal/provider/snyk.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,6 @@ func WithDependencyTree() SnykProviderOps {
136136
}
137137
}
138138

139-
// WithFailOn only fail when there are vulnerabilities that can be fixed
140-
func WithFailOn(failOn string) SnykProviderOps {
141-
return func(provider *snykProvider) error {
142-
provider.flags = append(provider.flags, "--fail-on="+failOn)
143-
return nil
144-
}
145-
}
146-
147139
// WithSeverity only reports vulnerabilities of the provided level or higher
148140
func WithSeverity(severity string) SnykProviderOps {
149141
return func(provider *snykProvider) error {

0 commit comments

Comments
 (0)