mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-21 23:00:42 -08:00
feat: support --skip-images scanning flag (#6334)
Signed-off-by: chenk <hen.keinan@gmail.com>
This commit is contained in:
@@ -96,6 +96,7 @@ trivy kubernetes [flags] [CONTEXT]
|
|||||||
--skip-db-update skip updating vulnerability database
|
--skip-db-update skip updating vulnerability database
|
||||||
--skip-dirs strings specify the directories or glob patterns to skip
|
--skip-dirs strings specify the directories or glob patterns to skip
|
||||||
--skip-files strings specify the files or glob patterns to skip
|
--skip-files strings specify the files or glob patterns to skip
|
||||||
|
--skip-images skip the downloading and scanning of images (vulnerabilities and secrets) in the cluster resources
|
||||||
--skip-java-db-update skip updating Java index database
|
--skip-java-db-update skip updating Java index database
|
||||||
--skip-policy-update skip fetching rego policy updates
|
--skip-policy-update skip fetching rego policy updates
|
||||||
-t, --template string output template
|
-t, --template string output template
|
||||||
|
|||||||
@@ -47,6 +47,11 @@ var (
|
|||||||
ConfigName: "kubernetes.exclude.owned",
|
ConfigName: "kubernetes.exclude.owned",
|
||||||
Usage: "exclude resources that have an owner reference",
|
Usage: "exclude resources that have an owner reference",
|
||||||
}
|
}
|
||||||
|
SkipImages = Flag[bool]{
|
||||||
|
Name: "skip-images",
|
||||||
|
ConfigName: "kubernetes.skipImages",
|
||||||
|
Usage: "skip the downloading and scanning of images (vulnerabilities and secrets) in the cluster resources",
|
||||||
|
}
|
||||||
ExcludeNodes = Flag[[]string]{
|
ExcludeNodes = Flag[[]string]{
|
||||||
Name: "exclude-nodes",
|
Name: "exclude-nodes",
|
||||||
ConfigName: "kubernetes.exclude.nodes",
|
ConfigName: "kubernetes.exclude.nodes",
|
||||||
@@ -95,6 +100,7 @@ type K8sFlagGroup struct {
|
|||||||
NodeCollectorImageRef *Flag[string]
|
NodeCollectorImageRef *Flag[string]
|
||||||
NodeCollectorNamespace *Flag[string]
|
NodeCollectorNamespace *Flag[string]
|
||||||
ExcludeOwned *Flag[bool]
|
ExcludeOwned *Flag[bool]
|
||||||
|
SkipImages *Flag[bool]
|
||||||
ExcludeNodes *Flag[[]string]
|
ExcludeNodes *Flag[[]string]
|
||||||
ExcludeKinds *Flag[[]string]
|
ExcludeKinds *Flag[[]string]
|
||||||
IncludeKinds *Flag[[]string]
|
IncludeKinds *Flag[[]string]
|
||||||
@@ -118,6 +124,7 @@ type K8sOptions struct {
|
|||||||
ExcludeNamespaces []string
|
ExcludeNamespaces []string
|
||||||
IncludeNamespaces []string
|
IncludeNamespaces []string
|
||||||
QPS float32
|
QPS float32
|
||||||
|
SkipImages bool
|
||||||
Burst int
|
Burst int
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,6 +143,7 @@ func NewK8sFlagGroup() *K8sFlagGroup {
|
|||||||
IncludeNamespaces: IncludeNamespaces.Clone(),
|
IncludeNamespaces: IncludeNamespaces.Clone(),
|
||||||
NodeCollectorImageRef: NodeCollectorImageRef.Clone(),
|
NodeCollectorImageRef: NodeCollectorImageRef.Clone(),
|
||||||
QPS: QPS.Clone(),
|
QPS: QPS.Clone(),
|
||||||
|
SkipImages: SkipImages.Clone(),
|
||||||
Burst: Burst.Clone(),
|
Burst: Burst.Clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -159,6 +167,7 @@ func (f *K8sFlagGroup) Flags() []Flagger {
|
|||||||
f.ExcludeNamespaces,
|
f.ExcludeNamespaces,
|
||||||
f.IncludeNamespaces,
|
f.IncludeNamespaces,
|
||||||
f.QPS,
|
f.QPS,
|
||||||
|
f.SkipImages,
|
||||||
f.Burst,
|
f.Burst,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -199,6 +208,7 @@ func (f *K8sFlagGroup) ToOptions() (K8sOptions, error) {
|
|||||||
ExcludeNodes: exludeNodeLabels,
|
ExcludeNodes: exludeNodeLabels,
|
||||||
NodeCollectorImageRef: f.NodeCollectorImageRef.Value(),
|
NodeCollectorImageRef: f.NodeCollectorImageRef.Value(),
|
||||||
QPS: float32(f.QPS.Value()),
|
QPS: float32(f.QPS.Value()),
|
||||||
|
SkipImages: f.SkipImages.Value(),
|
||||||
ExcludeKinds: f.ExcludeKinds.Value(),
|
ExcludeKinds: f.ExcludeKinds.Value(),
|
||||||
IncludeKinds: f.IncludeKinds.Value(),
|
IncludeKinds: f.IncludeKinds.Value(),
|
||||||
ExcludeNamespaces: f.ExcludeNamespaces.Value(),
|
ExcludeNamespaces: f.ExcludeNamespaces.Value(),
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ func (s *Scanner) Scan(ctx context.Context, artifactsData []*artifacts.Artifact)
|
|||||||
|
|
||||||
onItem := func(ctx context.Context, artifact *artifacts.Artifact) (scanResult, error) {
|
onItem := func(ctx context.Context, artifact *artifacts.Artifact) (scanResult, error) {
|
||||||
scanResults := scanResult{}
|
scanResults := scanResult{}
|
||||||
if s.opts.Scanners.AnyEnabled(types.VulnerabilityScanner, types.SecretScanner) {
|
if s.opts.Scanners.AnyEnabled(types.VulnerabilityScanner, types.SecretScanner) && !s.opts.SkipImages {
|
||||||
opts := s.opts
|
opts := s.opts
|
||||||
opts.Credentials = make([]ftypes.Credential, len(s.opts.Credentials))
|
opts.Credentials = make([]ftypes.Credential, len(s.opts.Credentials))
|
||||||
copy(opts.Credentials, s.opts.Credentials)
|
copy(opts.Credentials, s.opts.Credentials)
|
||||||
|
|||||||
Reference in New Issue
Block a user