github.com/devseccon/trivy@v0.47.1-0.20231123133102-bd902a0bd996/pkg/k8s/k8s.go (about)

     1  package k8s
     2  
     3  import (
     4  	"context"
     5  
     6  	"github.com/google/wire"
     7  
     8  	ftypes "github.com/devseccon/trivy/pkg/fanal/types"
     9  	"github.com/devseccon/trivy/pkg/scanner"
    10  	"github.com/devseccon/trivy/pkg/scanner/local"
    11  	"github.com/devseccon/trivy/pkg/types"
    12  )
    13  
    14  // ScanSuperSet binds the dependencies for k8s
    15  var ScanSuperSet = wire.NewSet(
    16  	local.SuperSet,
    17  	wire.Bind(new(scanner.Driver), new(local.Scanner)),
    18  	NewScanKubernetes,
    19  )
    20  
    21  // ScanKubernetes implements the scanner
    22  type ScanKubernetes struct {
    23  	localScanner local.Scanner
    24  }
    25  
    26  // NewScanKubernetes is the factory method for scanner
    27  func NewScanKubernetes(s local.Scanner) *ScanKubernetes {
    28  	return &ScanKubernetes{localScanner: s}
    29  }
    30  
    31  // NewKubenetesScanner is the factory method for scanner
    32  func NewKubenetesScanner() *ScanKubernetes {
    33  	return initializeScanK8s(nil)
    34  }
    35  
    36  // // Scan scans k8s core components and return it findings
    37  func (sk ScanKubernetes) Scan(ctx context.Context, target types.ScanTarget, options types.ScanOptions) (types.Results, ftypes.OS, error) {
    38  	return sk.localScanner.ScanTarget(ctx, target, options)
    39  }