grype

package
v0.9.19 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeployStagedUpdate

func DeployStagedUpdate(sourceDir, targetDir string) error

deploy staged update from sourceDir into targetDir

func GetDatabaseStatus

func GetDatabaseStatus(scannerBin string, targetDir string) (string, time.Time, error)

check grype local database status, update DbState

func GetGrypeUpdate

func GetGrypeUpdate(scannerBin, targetDir string) error

check if update is required, if so download to targetDir

func GetScannerVersion

func GetScannerVersion(scannerBin string) (string, error)

check grype binary version

func GrypeExeOutput

func GrypeExeOutput[T any](cmd *exec.Cmd) (T, error)

run grype executable, parse result from json into T

func GrypeTestScan

func GrypeTestScan(scannerBin, targetDir string) error

test scanner with actual scan of sample test sbom

func GrypeUpdateRequired

func GrypeUpdateRequired(scannerBin, targetDir string) bool

check if local db in targetDir requires an update

func ScanImage

func ScanImage(task model.PharosScanTask, scanEngine *GrypeScanner, kvc *cache.PharosCache, logger *zerolog.Logger) (model.PharosScanResult, []byte, []byte, error)

execute scan with grype scanner

func TranslateMessage

func TranslateMessage(msg string) string

Types

type GrypeDbCheck

type GrypeDbCheck struct {
	UpdateAvailable bool `json:"updateAvailable"`
}

grype update check (from: grype db check -o json)

type GrypeDbStatus

type GrypeDbStatus struct {
	SchemaVersion string    `json:"schemaVersion"`
	From          string    `json:"from"`
	Built         time.Time `json:"built"`
	Path          string    `json:"path"`
	Valid         bool      `json:"valid"`
	Error         string    `json:"error"`
}

grype local database status (from: grype db status -o json)

type GrypeScanner

type GrypeScanner struct {
	Engine     string
	HomeDir    string
	DbProdDir  string // vuln db dir for production scanner
	DbStageDir string // vuln db dir for staging new updates

	ScannerBin  string
	ScanTimeout time.Duration
	// version / status
	ScannerVersion  string
	DatabaseVersion string
	DatabaseUpdated time.Time
	// contains filtered or unexported fields
}

grype vulnerability scanner

func NewGrypeScanner

func NewGrypeScanner(scanTimeout time.Duration, updateDb bool, vulnDbDir string, logger *zerolog.Logger) (*GrypeScanner, error)

create grype scanner

func (*GrypeScanner) UpdateDatabase

func (rx *GrypeScanner) UpdateDatabase() error

run grype database update (stage update first to keep scanner blocking minimal)

func (*GrypeScanner) VulnScanSbom

func (rx *GrypeScanner) VulnScanSbom(sbom []byte) (grypetype.GrypeScanType, []byte, error)

scan cyclondex sbom with grype

type GrypeVersion

type GrypeVersion struct {
	Application  string    `json:"application"`
	BuildDate    time.Time `json:"buildDate"`
	Platform     string    `json:"platform"`
	GrypeVersion string    `json:"version"`
	SyftVersion  string    `json:"syftVersion"`
}

grype version check (from: grype version -o json)

Jump to

Keyboard shortcuts

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