Documentation
¶
Overview ¶
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. * * This product includes software developed at Datadog (https://www.datadoghq.com) Copyright 2024 Datadog, Inc.
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. * * This product includes software developed at Datadog (https://www.datadoghq.com) Copyright 2024 Datadog, Inc.
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. * * This product includes software developed at Datadog (https://www.datadoghq.com) Copyright 2024 Datadog, Inc.
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. * * This product includes software developed at Datadog (https://www.datadoghq.com) Copyright 2024 Datadog, Inc.
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. * * This product includes software developed at Datadog (https://www.datadoghq.com) Copyright 2024 Datadog, Inc.
Index ¶
- func DiskSourceProvider(services []*Service) (*provider.FileSystemSourceProvider, bool)
- func GetCountTerraformResources(fileContent []byte) int
- func MemorySourceProvider(services []*Service) (*provider.MemorySourceProvider, bool)
- func PrepareDiskSources(ctx context.Context, fsp *provider.FileSystemSourceProvider, ...) error
- func PrepareMemorySources(ctx context.Context, mp *provider.MemorySourceProvider, services []*Service, ...) error
- func PrepareScanDocument(ctx context.Context, body map[string]interface{}, kind model.FileKind) map[string]interface{}
- type Content
- type Service
- func (s *Service) ClearContentInterner()
- func (s *Service) ClearParsedShares()
- func (s *Service) ClearTreeCons()
- func (s *Service) FileCount() int
- func (s *Service) GetVulnerabilities(ctx context.Context, scanID string) ([]model.Vulnerability, error)
- func (s *Service) StartScan(ctx context.Context, scanID string, errCh chan<- error, wg *sync.WaitGroup)
- type Storage
- type Tracker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DiskSourceProvider ¶ added in v1.20.0
func DiskSourceProvider(services []*Service) (*provider.FileSystemSourceProvider, bool)
DiskSourceProvider returns the disk provider when every service shares one.
func MemorySourceProvider ¶ added in v1.20.0
func MemorySourceProvider(services []*Service) (*provider.MemorySourceProvider, bool)
MemorySourceProvider returns the memory provider when every service shares one.
func PrepareDiskSources ¶ added in v1.20.0
func PrepareDiskSources(ctx context.Context, fsp *provider.FileSystemSourceProvider, services []*Service, scanID string, openAPIResolveReferences bool, maxResolverDepth int, parallel bool) error
PrepareDiskSources walks the disk once, renders each chart once, and dispatches files to parsers. It serves every disk scan. parallel (the --x-parallelparsing flag) sets the concurrency of chart rendering and file dispatch, as for memory.
func PrepareMemorySources ¶ added in v1.17.0
func PrepareMemorySources(ctx context.Context, mp *provider.MemorySourceProvider, services []*Service, scanID string, openAPIResolveReferences bool, maxResolverDepth int, parallel bool) error
PrepareMemorySources is PrepareDiskSources over the files the IDE pushed, and the path every server scan takes. A chart that fails to render escalates its directory via the missing set. parallel (the --x-parallelparsing flag) controls the concurrency of both chart rendering and file dispatch; charts render in both modes.
Types ¶
type Service ¶
type Service struct {
SourceProvider provider.SourceProvider
Storage Storage
Parser *parser.Parser
Inspector *engine.Inspector
Tracker Tracker
Resolver *resolver.Resolver
// RenderedFileFilter applies the scan's path filters to rendered Helm
// files; nil keeps them all.
RenderedFileFilter provider.FileFilter
MaxFileSize int
// Platforms is the scan's effective platform set, used to classify each
// parsed file's platform consistently with the analyzer so the engine can
// scope queries to their own platform's documents.
Platforms []string
// FilePlatform is the analyzer path → platform map, reused in the sink.
FilePlatform map[string]string
// contains filtered or unexported fields
}
Service is a struct that contains a SourceProvider to receive sources, a storage to save and retrieve scanning informations a parser to parse and provide files in format the scanner understands, an inspector that runs the scanning and a tracker to update scanning numbers
func (*Service) ClearContentInterner ¶ added in v1.16.0
func (s *Service) ClearContentInterner()
ClearContentInterner drops the interner after the prepare phase; the shared strings stay alive via FileMetadata.OriginalData.
func (*Service) ClearParsedShares ¶ added in v1.16.0
func (s *Service) ClearParsedShares()
ClearParsedShares drops the shared parse cache. Call after the prepare phase: the map pins both the content keys and the shared trees; the trees stay alive via each FileMetadata's document copy.
func (*Service) ClearTreeCons ¶ added in v1.16.0
func (s *Service) ClearTreeCons()
ClearTreeCons drops the interner bookkeeping after prepare — up to tens of MB of map overhead on large corpora. The shared trees stay alive via FileMetadata.
func (*Service) FileCount ¶ added in v1.16.0
FileCount returns the number of files this service has collected so far. Used to size scan-phase GC tuning; the mutex makes it safe to call while prepare is still running.
func (*Service) GetVulnerabilities ¶
func (s *Service) GetVulnerabilities(ctx context.Context, scanID string) ([]model.Vulnerability, error)
GetVulnerabilities returns a list of scan detected vulnerabilities
type Storage ¶
type Storage interface {
SaveFile(ctx context.Context, metadata *model.FileMetadata) error
SaveVulnerabilities(ctx context.Context, vulnerabilities []model.Vulnerability) error
GetVulnerabilities(ctx context.Context, scanID string) ([]model.Vulnerability, error)
}
Storage is the interface that wraps following basic methods: SaveFile, SaveVulnerabilities, and GetVulnerabilities SaveFile should append metadata to a file SaveVulnerabilities should append vulnerabilities list to current storage GetVulnerabilities should returns all vulnerabilities associated to a scan ID
type Tracker ¶
type Tracker interface {
TrackFileFound(path string)
TrackFileParse(path string)
TrackFileFoundCountLines(countLines int)
TrackFileParseCountLines(countLines int)
TrackFileIgnoreCountLines(countLines int)
TrackFileFoundCountResources(countResources int)
}
Tracker is the interface that wraps the basic methods: TrackFileFound and TrackFileParse TrackFileFound should increment the number of files to be scanned TrackFileParse should increment the number of files parsed successfully to be scanned TrackFileFoundCountResources should increment the number of resources to be scanned