analyzer

package
v0.0.0-...-51f1176 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrUnknownOS occurs when unknown OS is analyzed.
	ErrUnknownOS = xerrors.New("unknown OS")
	// ErrPkgAnalysis occurs when the analysis of packages is failed.
	ErrPkgAnalysis = xerrors.New("failed to analyze packages")
	// ErrNoPkgsDetected occurs when the required files for an OS package manager are not detected
	ErrNoPkgsDetected = xerrors.New("no packages detected")
)
View Source
var (
	// TypeOSes has all OS-related analyzers
	TypeOSes = []Type{
		TypeAlpine, TypeAmazon, TypeDebian, TypePhoton, TypeCentOS,
		TypeRocky, TypeAlma, TypeFedora, TypeOracle, TypeRedHatBase, TypeSUSE, TypeUbuntu,
		TypeApk, TypeDpkg, TypeRpm,
	}

	// TypeLanguages has all language analyzers
	TypeLanguages = []Type{
		TypeBundler, TypeGemSpec, TypeCargo, TypeComposer, TypeJar, TypePom,
		TypeNpmPkgLock, TypeNodePkg, TypeYarn, TypeNuget, TypePythonPkg, TypePip, TypePipenv,
		TypePoetry, TypeGoBinary, TypeGoMod,
	}

	// TypeLockfiles has all lock file analyzers
	TypeLockfiles = []Type{
		TypeBundler, TypeNpmPkgLock, TypeYarn,
		TypePip, TypePipenv, TypePoetry, TypeGoMod, TypePom,
	}

	// TypeIndividualPkgs has all analyzers for individual packages
	TypeIndividualPkgs = []Type{TypeGemSpec, TypeNodePkg, TypePythonPkg, TypeGoBinary, TypeJar}

	// TypeConfigFiles has all config file analyzers
	TypeConfigFiles = []Type{TypeYaml, TypeJSON, TypeDockerfile, TypeTerraform, TypeCloudFormation}
)

Functions

func RegisterAnalyzer

func RegisterAnalyzer(analyzer analyzer)

func RegisterConfigAnalyzer

func RegisterConfigAnalyzer(analyzer configAnalyzer)

Types

type AnalysisInput

type AnalysisInput struct {
	Dir      string
	FilePath string
	Info     os.FileInfo
	Content  dio.ReadSeekerAt

	Options AnalysisOptions
}

type AnalysisOptions

type AnalysisOptions struct {
	Offline bool
}

type AnalysisResult

type AnalysisResult struct {
	OS                   *types.OS
	Repository           *types.Repository
	PackageInfos         []types.PackageInfo
	Applications         []types.Application
	Secrets              []types.Secret
	Licenses             []types.LicenseFile
	SystemInstalledFiles []string // A list of files installed by OS package manager

	Files map[types.HandlerType][]types.File

	// For Red Hat
	BuildInfo *types.BuildInfo

	// CustomResources hold analysis results from custom analyzers.
	// It is for extensibility and not used in OSS.
	CustomResources []types.CustomResource
	// contains filtered or unexported fields
}

func NewAnalysisResult

func NewAnalysisResult() *AnalysisResult

func (*AnalysisResult) Merge

func (r *AnalysisResult) Merge(new *AnalysisResult)

func (*AnalysisResult) Sort

func (r *AnalysisResult) Sort()

type AnalyzerGroup

type AnalyzerGroup struct {
	// contains filtered or unexported fields
}

func NewAnalyzerGroup

func NewAnalyzerGroup(groupName Group, disabledAnalyzers []Type) AnalyzerGroup

func (AnalyzerGroup) AnalyzeFile

func (ag AnalyzerGroup) AnalyzeFile(ctx context.Context, wg *sync.WaitGroup, limit *semaphore.Weighted, result *AnalysisResult,
	dir, filePath string, info os.FileInfo, opener Opener, disabled []Type, opts AnalysisOptions) error

func (AnalyzerGroup) AnalyzeImageConfig

func (ag AnalyzerGroup) AnalyzeImageConfig(targetOS types.OS, configBlob []byte) []types.Package

func (AnalyzerGroup) AnalyzerVersions

func (ag AnalyzerGroup) AnalyzerVersions() map[string]int

AnalyzerVersions returns analyzer version identifier used for cache keys.

func (AnalyzerGroup) ImageConfigAnalyzerVersions

func (ag AnalyzerGroup) ImageConfigAnalyzerVersions() map[string]int

ImageConfigAnalyzerVersions returns analyzer version identifier used for cache keys.

type CustomGroup

type CustomGroup interface {
	Group() Group
}

CustomGroup returns a group name for custom analyzers This is mainly intended to be used in Khulnasoft products.

type Group

type Group string
const GroupBuiltin Group = "builtin"

type Opener

type Opener func() (dio.ReadSeekCloserAt, error)

type Type

type Type string
const (
	// ======
	//   OS
	// ======
	TypeOSRelease  Type = "os-release"
	TypeAlpine     Type = "alpine"
	TypeAmazon     Type = "amazon"
	TypeCBLMariner Type = "cbl-mariner"
	TypeDebian     Type = "debian"
	TypePhoton     Type = "photon"
	TypeCentOS     Type = "centos"
	TypeRocky      Type = "rocky"
	TypeAlma       Type = "alma"
	TypeFedora     Type = "fedora"
	TypeOracle     Type = "oracle"
	TypeRedHatBase Type = "redhat"
	TypeSUSE       Type = "suse"
	TypeUbuntu     Type = "ubuntu"

	// OS Package
	TypeApk   Type = "apk"
	TypeDpkg  Type = "dpkg"
	TypeRpm   Type = "rpm"
	TypeRpmqa Type = "rpmqa"

	// OS Package Repository
	TypeApkRepo Type = "apk-repo"

	// Ruby
	TypeBundler Type = "bundler"
	TypeGemSpec Type = "gemspec"

	// Rust
	TypeCargo Type = "cargo"

	// PHP
	TypeComposer Type = "composer"

	// Java
	TypeJar Type = "jar"
	TypePom Type = "pom"

	// Node.js
	TypeNpmPkgLock Type = "npm"
	TypeNodePkg    Type = "node-pkg"
	TypeYarn       Type = "yarn"

	// .NET
	TypeNuget Type = "nuget"

	// Python
	TypePythonPkg Type = "python-pkg"
	TypePip       Type = "pip"
	TypePipenv    Type = "pipenv"
	TypePoetry    Type = "poetry"

	// Go
	TypeGoBinary Type = "gobinary"
	TypeGoMod    Type = "gomod"

	// ============
	// Image Config
	// ============
	TypeApkCommand Type = "apk-command"

	// =================
	// Structured Config
	// =================
	TypeYaml           Type = "yaml"
	TypeJSON           Type = "json"
	TypeDockerfile     Type = "dockerfile"
	TypeTerraform      Type = "terraform"
	TypeCloudFormation Type = "cloudFormation"
	TypeHelm           Type = "helm"

	// ========
	// Secrets
	// ========
	TypeSecret Type = "secret"

	// ========
	// Licenses
	// ========
	TypeLicense Type = "license"

	// =======
	// Red Hat
	// =======
	TypeRedHatContentManifestType = "redhat-content-manifest"
	TypeRedHatDockerfileType      = "redhat-dockerfile"
)

Jump to

Keyboard shortcuts

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