-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: scan vulns on k8s core component apps
Signed-off-by: chenk <[email protected]>
- Loading branch information
1 parent
01c98d1
commit a2b725a
Showing
9 changed files
with
453 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//go:build wireinject | ||
// +build wireinject | ||
|
||
package k8s | ||
|
||
import ( | ||
"github.com/google/wire" | ||
|
||
"github.com/aquasecurity/trivy/pkg/fanal/cache" | ||
) | ||
|
||
func initializeScanK8s(localArtifactCache cache.LocalArtifactCache) *ScanKubernetes { | ||
wire.Build(ScanSuperSet) | ||
return &ScanKubernetes{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package k8s | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/google/wire" | ||
|
||
ftypes "github.com/aquasecurity/trivy/pkg/fanal/types" | ||
"github.com/aquasecurity/trivy/pkg/scanner" | ||
"github.com/aquasecurity/trivy/pkg/scanner/local" | ||
"github.com/aquasecurity/trivy/pkg/types" | ||
) | ||
|
||
// ScanSuperSet binds the dependencies for k8s | ||
var ScanSuperSet = wire.NewSet( | ||
local.SuperSet, | ||
wire.Bind(new(scanner.Driver), new(local.Scanner)), | ||
NewScanKubernetes, | ||
) | ||
|
||
// ScanKubernetes implements the scanner | ||
type ScanKubernetes struct { | ||
localScanner local.Scanner | ||
} | ||
|
||
// NewScanKubernetes is the factory method for scanner | ||
func NewScanKubernetes(s local.Scanner) *ScanKubernetes { | ||
return &ScanKubernetes{localScanner: s} | ||
} | ||
|
||
// NewKubenetesScanner is the factory method for scanner | ||
func NewKubenetesScanner() *ScanKubernetes { | ||
return initializeScanK8s(nil) | ||
} | ||
|
||
// // Scan scans k8s core components and return it findings | ||
func (sk ScanKubernetes) Scan(ctx context.Context, target types.ScanTarget, options types.ScanOptions) (types.Results, ftypes.OS, error) { | ||
return sk.localScanner.ScanTarget(ctx, target, options) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.