trivy

package
v0.0.1-alpha.22 Latest Latest
Warning

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

Go to latest
Published: May 18, 2025 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllCommands = []struct {
	Value  Command
	TSName string
}{
	{CommandConfig, "CONFIG"},
	{CommandFilesystem, "FILESYSTEM"},
	{CommandImage, "IMAGE"},
	{CommandKubernetes, "KUBERNETES"},
	{CommandRepo, "REPOSITORY"},
	{CommandRootfs, "ROOTFS"},
	{CommandSBOM, "SBOM"},
}
View Source
var AllScanners = []struct {
	Value  Scanner
	TSName string
}{
	{ScannerVuln, "VULN"},
	{ScannerMisconfig, "MISCONFIG"},
	{ScannerSecret, "SECRET"},
	{ScannerLicense, "LICENSE"},
}

Functions

func RunTrivyScan

func RunTrivyScan(
	command Command,
	target string,

	opts ScanOptions,
) (map[string]interface{}, error)

Wraps the trivy command to run a scan TODO: convert to plugin

Types

type Args

type Args interface {
	Validate() error
	String() string
	ToArgs() []string
}

type Command

type Command string
const (
	CommandConfig     Command = "config"
	CommandFilesystem Command = "fs"
	CommandImage      Command = "image"
	CommandKubernetes Command = "kubernetes"
	CommandRepo       Command = "repository"
	CommandRootfs     Command = "rootfs"
	CommandSBOM       Command = "sbom"
)

func (Command) String

func (c Command) String() string

type Manager

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

Manager manages terminal sessions, allowing creation, attachment, and more.

func NewManager

func NewManager(log *zap.SugaredLogger) *Manager

NewManager initializes a new Manager instance, which allows managing reports and scanning.

func (*Manager) Scan

func (m *Manager) Scan(
	command Command,
	target string,
	opts ScanOptions,
) (ScanResult, error)

Scan runs a trivy scan with the given command, target, and options.

type ScanOptions

type ScanOptions struct {
	FilePatterns []string  `json:"filePatterns" yaml:"filePatterns"`
	SkipDirs     []string  `json:"skipDirs"     yaml:"skipDirs"`
	SkipFiles    []string  `json:"skipFiles"    yaml:"skipFiles"`
	Scanners     []Scanner `json:"scanners"     yaml:"scanners"`
}

func (ScanOptions) String

func (o ScanOptions) String() string

func (ScanOptions) ToArgs

func (o ScanOptions) ToArgs() []string

func (ScanOptions) Validate

func (o ScanOptions) Validate() error

type ScanResult

type ScanResult struct {
	Timestamp time.Time              `json:"timestamp"`
	Result    map[string]interface{} `json:"result"`
	ID        string                 `json:"id"`
	Command   Command                `json:"command"`
}

type Scanner

type Scanner string
const (
	ScannerVuln      Scanner = "vuln"
	ScannerMisconfig Scanner = "misconfig"
	ScannerSecret    Scanner = "secret"
	ScannerLicense   Scanner = "license"
)

func (Scanner) String

func (s Scanner) String() string

Jump to

Keyboard shortcuts

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