mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-23 07:29:00 -08:00
BREAKING: support exclude kinds/namespaces and include kinds/namespaces (#6323)
Signed-off-by: chenk <hen.keinan@gmail.com>
This commit is contained in:
@@ -934,22 +934,21 @@ func NewKubernetesCommand(globalFlags *flag.GlobalFlagGroup) *cobra.Command {
|
||||
VulnerabilityFlagGroup: flag.NewVulnerabilityFlagGroup(),
|
||||
}
|
||||
cmd := &cobra.Command{
|
||||
Use: "kubernetes [flags] { cluster | all | specific resources like kubectl. eg: pods, pod/NAME }",
|
||||
Use: "kubernetes [flags] [CONTEXT]",
|
||||
Aliases: []string{"k8s"},
|
||||
GroupID: groupScanning,
|
||||
Short: "[EXPERIMENTAL] Scan kubernetes cluster",
|
||||
Long: `Default context in kube configuration will be used unless specified`,
|
||||
Example: ` # cluster scanning
|
||||
$ trivy k8s --report summary cluster
|
||||
$ trivy k8s --report summary
|
||||
|
||||
# namespace scanning:
|
||||
$ trivy k8s -n kube-system --report summary all
|
||||
# cluster scanning with specific namespace:
|
||||
$ trivy k8s --include-namespaces kube-system --report summary
|
||||
|
||||
# resources scanning:
|
||||
$ trivy k8s --report=summary deploy
|
||||
$ trivy k8s --namespace=kube-system --report=summary deploy,configmaps
|
||||
|
||||
# resource scanning:
|
||||
$ trivy k8s deployment/orion
|
||||
# cluster with specific context:
|
||||
$ trivy k8s kind-kind --report summary
|
||||
|
||||
|
||||
`,
|
||||
PreRunE: func(cmd *cobra.Command, args []string) error {
|
||||
if err := k8sFlags.Bind(cmd); err != nil {
|
||||
@@ -1236,7 +1235,7 @@ func validateArgs(cmd *cobra.Command, args []string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
if len(args) == 0 && viper.GetString(flag.InputFlag.ConfigName) == "" {
|
||||
if len(args) == 0 && viper.GetString(flag.InputFlag.ConfigName) == "" && cmd.Name() != "kubernetes" {
|
||||
if err := cmd.Help(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user