Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions cmd/notation/internal/flag/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,18 @@ func (opts *SignerFlagOpts) ApplyFlagsToCommand(command *cobra.Command) {

// LoggingFlagOpts cmd opts for logging.
type LoggingFlagOpts struct {
Debug bool
Verbose bool
Debug bool
}

// ApplyFlags applies flags to a command flag set.
func (opts *LoggingFlagOpts) ApplyFlags(fs *pflag.FlagSet) {
fs.BoolVarP(&opts.Debug, "debug", "d", false, "debug mode")
fs.BoolVarP(&opts.Verbose, "verbose", "v", false, "verbose mode")
}

// InitializeLogger sets up the logger based on common options.
func (opts *LoggingFlagOpts) InitializeLogger(ctx context.Context) context.Context {
if opts.Debug {
ctx = trace.WithLoggerLevel(ctx, logrus.DebugLevel)
} else if opts.Verbose {
ctx = trace.WithLoggerLevel(ctx, logrus.InfoLevel)
} else {
return ctx
}
Expand Down
3 changes: 0 additions & 3 deletions specs/cmd/blob.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ Flags:
--timestamp-root-cert string filepath of timestamp authority root certificate
--timestamp-url string RFC 3161 Timestamping Authority (TSA) server URL
-m, --user-metadata stringArray {key}={value} pairs that are added to the signature payload
-v, --verbose verbose mode
```

### notation blob inspect
Expand All @@ -106,7 +105,6 @@ Usage:
Flags:
-o, --output string output format, options: 'json', 'tree' (default "tree")
-d, --debug debug mode
-v, --verbose verbose mode
-h, --help help for inspect
```

Expand Down Expand Up @@ -185,7 +183,6 @@ Flags:
--policy-name string policy name to verify against. If not provided, the global policy is used if exists
-s --signature string filepath of the signature to be verified
-m, --user-metadata stringArray user defined {key}={value} pairs that must be present in the signature for successful verification if provided
-v, --verbose verbose mode
```

## Usage
Expand Down
2 changes: 0 additions & 2 deletions specs/cmd/certificate.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ Flags:
-h, --help help for list
-s, --store string specify named store
-t, --type string specify trust store type, options: ca, signingAuthority, tsa
-v, --verbose verbose mode
```

### notation certificate show
Expand All @@ -106,7 +105,6 @@ Flags:
-h, --help help for show
-s, --store string specify named store
-t, --type string specify trust store type, options: ca, signingAuthority, tsa
-v, --verbose verbose mode
```

### notation certificate delete
Expand Down
1 change: 0 additions & 1 deletion specs/cmd/inspect.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ Flags:
-o, --output string output format, options: 'json', 'tree' (default "tree")
-p, --password string password for registry operations (default to $NOTATION_PASSWORD if not specified)
-u, --username string username for registry operations (default to $NOTATION_USERNAME if not specified)
-v, --verbose verbose mode
```

## Usage
Expand Down
3 changes: 0 additions & 3 deletions specs/cmd/key.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ Flags:
--id string key id (required if --plugin is set)
--plugin string signing plugin name
--plugin-config stringArray {key}={value} pairs that are passed as it is to a plugin, refer plugin's documentation to set appropriate values
-v, --verbose verbose mode
```

### notation key delete
Expand All @@ -53,7 +52,6 @@ Usage:
Flags:
-d, --debug debug mode
-h, --help help for delete
-v, --verbose verbose mode
```

### notation key list
Expand Down Expand Up @@ -86,7 +84,6 @@ Flags:
-d, --debug debug mode
--default mark as default
-h, --help help for update
-v, --verbose verbose mode
```

## Usage
Expand Down
1 change: 0 additions & 1 deletion specs/cmd/list.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ Flags:
--oci-layout [Experimental] list signatures stored in OCI image layout
-p, --password string password for registry operations (default to $NOTATION_PASSWORD if not specified)
-u, --username string username for registry operations (default to $NOTATION_USERNAME if not specified)
-v, --verbose verbose mode
```

## Usage
Expand Down
1 change: 0 additions & 1 deletion specs/cmd/login.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Flags:
-p, --password string password for registry operations (default to $NOTATION_PASSWORD if not specified)
--password-stdin take the password from stdin
-u, --username string username for registry operations (default to $NOTATION_USERNAME if not specified)
-v, --verbose verbose mode
```

## Usage
Expand Down
1 change: 0 additions & 1 deletion specs/cmd/logout.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ Usage:
Flags:
-d, --debug debug mode
-h, --help help for logout
-v, --verbose verbose mode
```

## Usage
Expand Down
2 changes: 0 additions & 2 deletions specs/cmd/plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ Flags:
-h, --help help for install
--sha256sum string must match SHA256 of the plugin source, required when "--url" flag is set
--url install plugin from an HTTPS URL. The plugin download timeout is 10m0s
-v, --verbose verbose mode

Aliases:
install, add
Expand All @@ -70,7 +69,6 @@ Usage:
Flags:
-d, --debug debug mode
-h, --help help for remove
-v, --verbose verbose mode
-y, --yes do not prompt for confirmation
Aliases:
uninstall, remove, rm
Expand Down
1 change: 0 additions & 1 deletion specs/cmd/sign.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ Flags:
--timestamp-url string RFC 3161 Timestamping Authority (TSA) server URL
-u, --username string username for registry operations (default to $NOTATION_USERNAME if not specified)
-m, --user-metadata stringArray {key}={value} pairs that are added to the signature payload
-v, --verbose verbose mode
```

### Set config property for OCI image manifest
Expand Down
1 change: 0 additions & 1 deletion specs/cmd/verify.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ Flags:
--scope string [Experimental] set trust policy scope for artifact verification, required and can only be used when flag "--oci-layout" is set
-u, --username string username for registry operations (default to $NOTATION_USERNAME if not specified)
-m, --user-metadata stringArray user defined {key}={value} pairs that must be present in the signature for successful verification if provided
-v, --verbose verbose mode
```

## Usage
Expand Down
4 changes: 2 additions & 2 deletions specs/error-handling-guideline.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ First and foremost, make the error messages descriptive and informative. Error m

Second, when necessary, it is highly suggested for Notation CLI contributors to provide recommendations for users how to resolve the problems based on the error messages they encountered. Showing descriptive words and straightforward prompt with executable commands as a potential solution is a good practice for error messages.

Third, for unhandled errors you didn't expect the user to run into. For that, have a way to view full traceback information as well as full debug or verbose logs output, and instructions on how to submit a bug.
Third, for unhandled errors you didn't expect the user to run into. For that, have a way to view full traceback information as well as full debug logs output, and instructions on how to submit a bug.

Fourth, signal-to-noise ratio is crucial. The more irrelevant output you produce, the longer it's going to take the user to figure out what they did wrong. If your program produces multiple errors of the same type, consider grouping them under a single explanatory header instead of printing many similar-looking lines.

Expand All @@ -31,7 +31,7 @@ Last, error logs can also be useful for post-mortem debugging and can also be wr
- Print human readable error message. If the error message is mainly from the server and varies by different servers, tell users that the error response is from server. This implies that users may need to contact server side for troubleshooting.
- Provide specific and actionable prompt message with argument suggestion or show the example usage for reference. (e.g, Instead of showing flag or argument options is missing, please provide available argument options and guide users to `--help` to view more examples).
- If the actionable prompt message is too long to show in the CLI output, consider guide users to Notation user manual or troubleshooting guide with the versioned permanent link.
- If the error message is not enough for troubleshooting, guide users to use `--verbose` to print much more detailed logs.
- If the error message is not enough for troubleshooting, guide users to use `--debug` to print much more detailed logs.
- If server returns an error without any [message or detail](https://github.com/opencontainers/distribution-spec/blob/v1.1.0-rc.3/spec.md#error-codes), consider providing customized error logs to make it clearer. The original server logs can be displayed in debug mode.
- As a security tool, `notation` SHOULD prompt users to stop upon verification errors.

Expand Down
4 changes: 2 additions & 2 deletions test/e2e/suite/command/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ var _ = Describe("notation inspect", func() {
notation.Exec("sign", "--force-referrers-tag", artifact.ReferenceWithDigest()).
MatchKeyWords(SignSuccessfully)

notation.Exec("inspect", artifact.ReferenceWithDigest(), "-v").
notation.Exec("inspect", artifact.ReferenceWithDigest(), "-d").
MatchKeyWords(inspectSuccessfully...)
})
})
Expand All @@ -126,7 +126,7 @@ var _ = Describe("notation inspect", func() {
notation.Exec("sign", "--force-referrers-tag=false", artifact.ReferenceWithDigest()).
MatchKeyWords(SignSuccessfully)

notation.Exec("inspect", artifact.ReferenceWithDigest(), "-v").
notation.Exec("inspect", artifact.ReferenceWithDigest(), "-d").
MatchKeyWords(inspectSuccessfully...)
})
})
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/suite/command/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ var _ = Describe("notation list", func() {
notation.Exec("sign", "--force-referrers-tag", artifact.ReferenceWithDigest()).
MatchKeyWords(SignSuccessfully)

notation.Exec("list", artifact.ReferenceWithDigest(), "-v").
notation.Exec("list", artifact.ReferenceWithDigest(), "-d").
MatchKeyWords(
"└── application/vnd.cncf.notary.signature",
"└── sha256:",
Expand All @@ -104,7 +104,7 @@ var _ = Describe("notation list", func() {
notation.Exec("sign", "--force-referrers-tag=false", artifact.ReferenceWithDigest()).
MatchKeyWords(SignSuccessfully)

notation.Exec("list", artifact.ReferenceWithDigest(), "-v").
notation.Exec("list", artifact.ReferenceWithDigest(), "-d").
MatchKeyWords(
"└── application/vnd.cncf.notary.signature",
"└── sha256:",
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/suite/command/sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ var _ = Describe("notation sign", func() {
MatchKeyWords(SignSuccessfully)

notation.WithDescription("verify by tag schema").
Exec("verify", artifact.ReferenceWithDigest(), "-v").
Exec("verify", artifact.ReferenceWithDigest(), "-d").
MatchKeyWords(VerifySuccessfully)
})
})
Expand All @@ -98,7 +98,7 @@ var _ = Describe("notation sign", func() {
MatchKeyWords(SignSuccessfully)

notation.WithDescription("verify by referrers api").
Exec("verify", artifact.ReferenceWithDigest(), "-v").
Exec("verify", artifact.ReferenceWithDigest(), "-d").
MatchKeyWords(VerifySuccessfully)
})
})
Expand Down Expand Up @@ -132,7 +132,7 @@ var _ = Describe("notation sign", func() {
// sleep to wait for expiry
time.Sleep(2100 * time.Millisecond)

notation.ExpectFailure().Exec("verify", artifact.ReferenceWithDigest(), "-v").
notation.ExpectFailure().Exec("verify", artifact.ReferenceWithDigest(), "-d").
MatchErrKeyWords("expiry validation failed.").
MatchErrKeyWords("signature verification failed for all the signatures")
})
Expand Down
14 changes: 7 additions & 7 deletions test/e2e/suite/command/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var _ = Describe("notation verify", func() {
notation.Exec("sign", artifact.ReferenceWithDigest()).
MatchKeyWords(SignSuccessfully)

notation.Exec("verify", artifact.ReferenceWithDigest(), "-v").
notation.Exec("verify", artifact.ReferenceWithDigest(), "-d").
MatchKeyWords(VerifySuccessfully)
})
})
Expand All @@ -39,7 +39,7 @@ var _ = Describe("notation verify", func() {
notation.Exec("sign", artifact.ReferenceWithDigest()).
MatchKeyWords(SignSuccessfully)

notation.Exec("verify", artifact.ReferenceWithTag(), "-v").
notation.Exec("verify", artifact.ReferenceWithTag(), "-d").
MatchKeyWords(VerifySuccessfully)
})
})
Expand Down Expand Up @@ -69,7 +69,7 @@ var _ = Describe("notation verify", func() {
notation.Exec("sign", "--force-referrers-tag", artifact.ReferenceWithDigest()).
MatchKeyWords(SignSuccessfully)

notation.Exec("verify", artifact.ReferenceWithDigest(), "-v").
notation.Exec("verify", artifact.ReferenceWithDigest(), "-d").
MatchKeyWords(VerifySuccessfully)
})
})
Expand All @@ -79,7 +79,7 @@ var _ = Describe("notation verify", func() {
notation.Exec("sign", "--force-referrers-tag=false", artifact.ReferenceWithDigest()).
MatchKeyWords(SignSuccessfully)

notation.Exec("verify", artifact.ReferenceWithDigest(), "-v").
notation.Exec("verify", artifact.ReferenceWithDigest(), "-d").
MatchKeyWords(VerifySuccessfully)
})
})
Expand Down Expand Up @@ -163,7 +163,7 @@ var _ = Describe("notation verify", func() {
MatchKeyWords(SignSuccessfully)

vhost.UpdateEnv(map[string]string{"NOTATION_CONFIG": "/not/exist"})
notation.ExpectFailure().Exec("verify", artifact.ReferenceWithDigest(), "-v").
notation.ExpectFailure().Exec("verify", artifact.ReferenceWithDigest(), "-d").
MatchErrKeyWords("trust policy is not present")
})
})
Expand All @@ -174,7 +174,7 @@ var _ = Describe("notation verify", func() {
MatchKeyWords(SignSuccessfully)

vhost.UpdateEnv(map[string]string{"NOTATION_CONFIG": vhost.AbsolutePath(NotationDirName)})
notation.Exec("verify", artifact.ReferenceWithDigest(), "-v").
notation.Exec("verify", artifact.ReferenceWithDigest(), "-d").
MatchKeyWords(VerifySuccessfully)
})
})
Expand All @@ -185,7 +185,7 @@ var _ = Describe("notation verify", func() {
MatchKeyWords(SignSuccessfully)

vhost.UpdateEnv(map[string]string{"NOTATION_CACHE": vhost.AbsolutePath(NotationDirName)})
notation.Exec("verify", artifact.ReferenceWithDigest(), "-v").
notation.Exec("verify", artifact.ReferenceWithDigest(), "-d").
MatchKeyWords(VerifySuccessfully)
})
})
Expand Down
12 changes: 6 additions & 6 deletions test/e2e/suite/plugin/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ var _ = Describe("notation plugin install", func() {

It("with zip bomb single file exceeds 256 MiB size limit in zip format", func() {
Host(nil, func(notation *utils.ExecOpts, _ *Artifact, vhost *utils.VirtualHost) {
notation.ExpectFailure().Exec("plugin", "install", "--file", filepath.Join(NotationE2EMaliciousPluginArchivePath, "large_file_zip.zip"), "-v").
notation.ExpectFailure().Exec("plugin", "install", "--file", filepath.Join(NotationE2EMaliciousPluginArchivePath, "large_file_zip.zip"), "-d").
MatchErrContent("Error: plugin installation failed: total file size reached the 256 MiB size limit\n")
})
})

It("with zip bomb single file exceeds 256 MiB size limit in tar.gz format", func() {
Host(nil, func(notation *utils.ExecOpts, _ *Artifact, vhost *utils.VirtualHost) {
notation.ExpectFailure().Exec("plugin", "install", "--file", filepath.Join(NotationE2EMaliciousPluginArchivePath, "large_file_tarGz.tar.gz"), "-v").
notation.ExpectFailure().Exec("plugin", "install", "--file", filepath.Join(NotationE2EMaliciousPluginArchivePath, "large_file_tarGz.tar.gz"), "-d").
MatchErrContent("Error: plugin installation failed: total file size reached the 256 MiB size limit\n")
})
})
Expand All @@ -97,21 +97,21 @@ var _ = Describe("notation plugin install", func() {
Fail(fmt.Sprintf("failed to write file %s: %v", targetPath, err))
}

notation.ExpectFailure().Exec("plugin", "install", "--file", targetPath, "-v").
notation.ExpectFailure().Exec("plugin", "install", "--file", targetPath).
MatchErrContent("Error: plugin installation failed: total file size reached the 256 MiB size limit\n")
})
})

It("with zip slip", func() {
Host(nil, func(notation *utils.ExecOpts, _ *Artifact, vhost *utils.VirtualHost) {
notation.ExpectFailure().Exec("plugin", "install", "--file", filepath.Join(NotationE2EMaliciousPluginArchivePath, "zip_slip.zip"), "-v").
notation.ExpectFailure().Exec("plugin", "install", "--file", filepath.Join(NotationE2EMaliciousPluginArchivePath, "zip_slip.zip"), "-d").
MatchErrContent("Error: plugin installation failed: file name in zip cannot contain '..', but found \"../../../../../../../../tmp/evil.txt\"\n")
})
})

It("with valid plugin file path", func() {
Host(nil, func(notation *utils.ExecOpts, _ *Artifact, vhost *utils.VirtualHost) {
notation.Exec("plugin", "install", "--file", NotationE2EPluginTarGzPath, "-v").
notation.Exec("plugin", "install", "--file", NotationE2EPluginTarGzPath, "-d").
MatchContent("Successfully installed plugin e2e-plugin, version 1.0.0\n")
})
})
Expand All @@ -135,7 +135,7 @@ var _ = Describe("notation plugin install", func() {

It("with plugin already installed but force install", func() {
Host(nil, func(notation *utils.ExecOpts, _ *Artifact, vhost *utils.VirtualHost) {
notation.Exec("plugin", "install", "--file", NotationE2EPluginTarGzPath, "-v").
notation.Exec("plugin", "install", "--file", NotationE2EPluginTarGzPath, "-d").
MatchContent("Successfully installed plugin e2e-plugin, version 1.0.0\n")

notation.Exec("plugin", "install", "--file", NotationE2EPluginTarGzPath, "--force").
Expand Down
Loading
Loading