-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
k8s.go
39 lines (31 loc) · 1.06 KB
/
k8s.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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}
}
// NewKubernetesScanner is the factory method for scanner
func NewKubernetesScanner() *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)
}