detectors

package
v5.0.0-preview.1+incom... Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 13, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package detectors exposes functions to register and use container information extractors.

Package detectors exposes functions to register and use container information extractors.

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrCouldNotFindLayer is returned when we could not download or open the layer file.
	ErrCouldNotFindLayer = errors.New("could not find layer")
)

Functions

func DetectData

func DetectData(format, path string, headers map[string]string, toExtract []string, maxFileSize int64) (data map[string][]byte, err error)

DetectData finds the Data of the layer by using every registered DataDetector

func GetRequiredFilesFeatures

func GetRequiredFilesFeatures() (files []string)

GetRequiredFilesFeatures returns the list of files required for Detect for every registered FeaturesDetector, without leading /.

func GetRequiredFilesNamespace

func GetRequiredFilesNamespace() (files []string)

GetRequiredFilesNamespace returns the list of files required for DetectNamespace for every registered NamespaceDetector, without leading /.

func RegisterDataDetector

func RegisterDataDetector(name string, f DataDetector)

RegisterDataDetector provides a way to dynamically register an implementation of a DataDetector.

If RegisterDataDetector is called twice with the same name if DataDetector is nil, or if the name is blank, it panics.

func RegisterFeaturesDetector

func RegisterFeaturesDetector(name string, f FeaturesDetector)

RegisterFeaturesDetector makes a FeaturesDetector available for DetectFeatures.

func RegisterNamespaceDetector

func RegisterNamespaceDetector(name string, f NamespaceDetector)

RegisterNamespaceDetector provides a way to dynamically register an implementation of a NamespaceDetector.

If RegisterNamespaceDetector is called twice with the same name if NamespaceDetector is nil, or if the name is blank, it panics.

Types

type AppFeatureVersion

type AppFeatureVersion struct {
	scan.AppPackage
	ModuleVuls []ModuleVul
	InBase     bool
}

type DataDetector

type DataDetector interface {
	//Support check if the input path and format are supported by the underling detector
	Supported(path string, format string) bool
	// Detect detects the required data from input path
	Detect(layerReader io.ReadCloser, toExtract []string, maxFileSize int64) (data map[string][]byte, err error)
}

The DataDetector interface defines a way to detect the required data from input path

type Feature

type Feature struct {
	Name      string
	Namespace Namespace
}

type FeatureFile

type FeatureFile struct {
	Data   []byte
	InBase bool
}

type FeatureVersion

type FeatureVersion struct {
	Name       string
	Feature    Feature
	Version    common.Version
	MinVer     common.Version
	ModuleVuls []ModuleVul
	CPEs       utils.Set
	InBase     bool
}

func DetectFeatures

func DetectFeatures(namespace string, data map[string]*FeatureFile, path string) ([]FeatureVersion, error)

DetectFeatures detects a list of FeatureVersion using every registered FeaturesDetector.

type FeaturesDetector

type FeaturesDetector interface {
	// Detect detects a list of FeatureVersion from the input data.
	Detect(string, map[string]*FeatureFile, string) ([]FeatureVersion, error)
	// GetRequiredFiles returns the list of files required for Detect, without
	// leading /.
	GetRequiredFiles() []string
}

The FeaturesDetector interface defines a way to detect packages from input data.

type ModuleVul

type ModuleVul struct {
	Name   string
	Status share.ScanVulStatus
}

type Namespace

type Namespace struct {
	Name string
}

func DetectNamespace

func DetectNamespace(data map[string]*FeatureFile) *Namespace

DetectNamespace finds the OS of the layer by using every registered NamespaceDetector.

type NamespaceDetector

type NamespaceDetector interface {
	// Detect detects a Namespace and its version from input data.
	Detect(map[string]*FeatureFile) *Namespace
	// GetRequiredFiles returns the list of files required for Detect, without
	// leading /.
	GetRequiredFiles() []string
}

The NamespaceDetector interface defines a way to detect a Namespace from input data. A namespace is usually made of an Operating System name and its version.

Directories

Path Synopsis
feature
apk
rpm
namespace

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL