mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-22 23:26:39 -08:00
BREAKING: remove root command (#1579)
This commit is contained in:
@@ -19,7 +19,7 @@ jobs:
|
|||||||
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin
|
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin
|
||||||
- run:
|
- run:
|
||||||
name: Scan the local image with trivy
|
name: Scan the local image with trivy
|
||||||
command: trivy --exit-code 0 --no-progress trivy-ci-test:${CIRCLE_SHA1}
|
command: trivy image --exit-code 0 --no-progress trivy-ci-test:${CIRCLE_SHA1}
|
||||||
workflows:
|
workflows:
|
||||||
version: 2
|
version: 2
|
||||||
release:
|
release:
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ before_install:
|
|||||||
- wget https://github.com/aquasecurity/trivy/releases/download/v${VERSION}/trivy_${VERSION}_Linux-64bit.tar.gz
|
- wget https://github.com/aquasecurity/trivy/releases/download/v${VERSION}/trivy_${VERSION}_Linux-64bit.tar.gz
|
||||||
- tar zxvf trivy_${VERSION}_Linux-64bit.tar.gz
|
- tar zxvf trivy_${VERSION}_Linux-64bit.tar.gz
|
||||||
script:
|
script:
|
||||||
- ./trivy --exit-code 0 --severity HIGH --no-progress trivy-ci-test:${COMMIT}
|
- ./trivy image --exit-code 0 --severity HIGH --no-progress trivy-ci-test:${COMMIT}
|
||||||
- ./trivy --exit-code 1 --severity CRITICAL --no-progress trivy-ci-test:${COMMIT}
|
- ./trivy image --exit-code 1 --severity CRITICAL --no-progress trivy-ci-test:${COMMIT}
|
||||||
cache:
|
cache:
|
||||||
directories:
|
directories:
|
||||||
- $HOME/.cache/trivy
|
- $HOME/.cache/trivy
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import (
|
|||||||
"github.com/aquasecurity/trivy/pkg/commands/client"
|
"github.com/aquasecurity/trivy/pkg/commands/client"
|
||||||
"github.com/aquasecurity/trivy/pkg/commands/plugin"
|
"github.com/aquasecurity/trivy/pkg/commands/plugin"
|
||||||
"github.com/aquasecurity/trivy/pkg/commands/server"
|
"github.com/aquasecurity/trivy/pkg/commands/server"
|
||||||
"github.com/aquasecurity/trivy/pkg/log"
|
|
||||||
"github.com/aquasecurity/trivy/pkg/result"
|
"github.com/aquasecurity/trivy/pkg/result"
|
||||||
"github.com/aquasecurity/trivy/pkg/types"
|
"github.com/aquasecurity/trivy/pkg/types"
|
||||||
"github.com/aquasecurity/trivy/pkg/utils"
|
"github.com/aquasecurity/trivy/pkg/utils"
|
||||||
@@ -292,33 +291,6 @@ var (
|
|||||||
&debugFlag,
|
&debugFlag,
|
||||||
&cacheDirFlag,
|
&cacheDirFlag,
|
||||||
}
|
}
|
||||||
|
|
||||||
imageFlags = []cli.Flag{
|
|
||||||
&templateFlag,
|
|
||||||
&formatFlag,
|
|
||||||
&inputFlag,
|
|
||||||
&severityFlag,
|
|
||||||
&outputFlag,
|
|
||||||
&exitCodeFlag,
|
|
||||||
&skipDBUpdateFlag,
|
|
||||||
&downloadDBOnlyFlag,
|
|
||||||
&resetFlag,
|
|
||||||
&clearCacheFlag,
|
|
||||||
&noProgressFlag,
|
|
||||||
&ignoreUnfixedFlag,
|
|
||||||
&removedPkgsFlag,
|
|
||||||
&vulnTypeFlag,
|
|
||||||
&securityChecksFlag,
|
|
||||||
&ignoreFileFlag,
|
|
||||||
&timeoutFlag,
|
|
||||||
&lightFlag,
|
|
||||||
&ignorePolicy,
|
|
||||||
&listAllPackages,
|
|
||||||
&cacheBackendFlag,
|
|
||||||
&offlineScan,
|
|
||||||
stringSliceFlag(skipFiles),
|
|
||||||
stringSliceFlag(skipDirs),
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewApp is the factory method to return Trivy CLI
|
// NewApp is the factory method to return Trivy CLI
|
||||||
@@ -333,10 +305,7 @@ func NewApp(version string) *cli.App {
|
|||||||
app.ArgsUsage = "target"
|
app.ArgsUsage = "target"
|
||||||
app.Usage = "A simple and comprehensive vulnerability scanner for containers"
|
app.Usage = "A simple and comprehensive vulnerability scanner for containers"
|
||||||
app.EnableBashCompletion = true
|
app.EnableBashCompletion = true
|
||||||
|
app.Flags = globalFlags
|
||||||
flags := append(globalFlags, setHidden(imageFlags, true)...)
|
|
||||||
|
|
||||||
app.Flags = flags
|
|
||||||
|
|
||||||
if runAsPlugin := os.Getenv("TRIVY_RUN_AS_PLUGIN"); runAsPlugin != "" {
|
if runAsPlugin := os.Getenv("TRIVY_RUN_AS_PLUGIN"); runAsPlugin != "" {
|
||||||
app.Action = func(ctx *cli.Context) error {
|
app.Action = func(ctx *cli.Context) error {
|
||||||
@@ -352,11 +321,6 @@ func NewApp(version string) *cli.App {
|
|||||||
return app
|
return app
|
||||||
}
|
}
|
||||||
|
|
||||||
app.Action = func(ctx *cli.Context) error {
|
|
||||||
log.Logger.Warn("The root command will be removed. Please migrate to 'trivy image' command. See https://github.com/aquasecurity/trivy/discussions/1515")
|
|
||||||
return artifact.ImageRun(ctx)
|
|
||||||
}
|
|
||||||
|
|
||||||
app.Commands = []*cli.Command{
|
app.Commands = []*cli.Command{
|
||||||
NewImageCommand(),
|
NewImageCommand(),
|
||||||
NewFilesystemCommand(),
|
NewFilesystemCommand(),
|
||||||
@@ -372,37 +336,6 @@ func NewApp(version string) *cli.App {
|
|||||||
return app
|
return app
|
||||||
}
|
}
|
||||||
|
|
||||||
func setHidden(flags []cli.Flag, hidden bool) []cli.Flag {
|
|
||||||
var newFlags []cli.Flag
|
|
||||||
for _, flag := range flags {
|
|
||||||
var f cli.Flag
|
|
||||||
switch pf := flag.(type) {
|
|
||||||
case *cli.StringFlag:
|
|
||||||
stringFlag := *pf
|
|
||||||
stringFlag.Hidden = hidden
|
|
||||||
f = &stringFlag
|
|
||||||
case *cli.StringSliceFlag:
|
|
||||||
stringSliceFlag := *pf
|
|
||||||
stringSliceFlag.Hidden = hidden
|
|
||||||
f = &stringSliceFlag
|
|
||||||
case *cli.BoolFlag:
|
|
||||||
boolFlag := *pf
|
|
||||||
boolFlag.Hidden = hidden
|
|
||||||
f = &boolFlag
|
|
||||||
case *cli.IntFlag:
|
|
||||||
intFlag := *pf
|
|
||||||
intFlag.Hidden = hidden
|
|
||||||
f = &intFlag
|
|
||||||
case *cli.DurationFlag:
|
|
||||||
durationFlag := *pf
|
|
||||||
durationFlag.Hidden = hidden
|
|
||||||
f = &durationFlag
|
|
||||||
}
|
|
||||||
newFlags = append(newFlags, f)
|
|
||||||
}
|
|
||||||
return newFlags
|
|
||||||
}
|
|
||||||
|
|
||||||
func showVersion(cacheDir, outputFormat, version string, outputWriter io.Writer) {
|
func showVersion(cacheDir, outputFormat, version string, outputWriter io.Writer) {
|
||||||
var dbMeta *metadata.Metadata
|
var dbMeta *metadata.Metadata
|
||||||
|
|
||||||
@@ -446,7 +379,32 @@ func NewImageCommand() *cli.Command {
|
|||||||
ArgsUsage: "image_name",
|
ArgsUsage: "image_name",
|
||||||
Usage: "scan an image",
|
Usage: "scan an image",
|
||||||
Action: artifact.ImageRun,
|
Action: artifact.ImageRun,
|
||||||
Flags: imageFlags,
|
Flags: []cli.Flag{
|
||||||
|
&templateFlag,
|
||||||
|
&formatFlag,
|
||||||
|
&inputFlag,
|
||||||
|
&severityFlag,
|
||||||
|
&outputFlag,
|
||||||
|
&exitCodeFlag,
|
||||||
|
&skipDBUpdateFlag,
|
||||||
|
&downloadDBOnlyFlag,
|
||||||
|
&resetFlag,
|
||||||
|
&clearCacheFlag,
|
||||||
|
&noProgressFlag,
|
||||||
|
&ignoreUnfixedFlag,
|
||||||
|
&removedPkgsFlag,
|
||||||
|
&vulnTypeFlag,
|
||||||
|
&securityChecksFlag,
|
||||||
|
&ignoreFileFlag,
|
||||||
|
&timeoutFlag,
|
||||||
|
&lightFlag,
|
||||||
|
&ignorePolicy,
|
||||||
|
&listAllPackages,
|
||||||
|
&cacheBackendFlag,
|
||||||
|
&offlineScan,
|
||||||
|
stringSliceFlag(skipFiles),
|
||||||
|
stringSliceFlag(skipDirs),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user