trivy

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package trivy provides an adapter to convert Trivy JSON output to CTIS.

Package trivy provides an adapter to convert Trivy JSON output to CTIS.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseToCTIS

func ParseToCTIS(data []byte, opts *core.ParseOptions) (*ctis.Report, error)

ParseToCTIS is a convenience function to parse Trivy JSON to CTIS format.

Types

type Adapter

type Adapter struct{}

Adapter converts Trivy JSON output to CTIS.

func NewAdapter

func NewAdapter() *Adapter

NewAdapter creates a new Trivy adapter.

func (*Adapter) CanConvert

func (a *Adapter) CanConvert(input []byte) bool

CanConvert checks if the input can be converted.

func (*Adapter) Convert

func (a *Adapter) Convert(ctx context.Context, input []byte, opts *core.AdapterOptions) (*ctis.Report, error)

Convert transforms Trivy JSON input to CTIS Report.

func (*Adapter) InputFormats

func (a *Adapter) InputFormats() []string

InputFormats returns supported input formats.

func (*Adapter) Name

func (a *Adapter) Name() string

Name returns the adapter name.

func (*Adapter) OutputFormat

func (a *Adapter) OutputFormat() string

OutputFormat returns the output format.

type TrivyCVSS

type TrivyCVSS map[string]TrivyCVSSData

TrivyCVSS maps CVSS source to score data.

type TrivyCVSSData

type TrivyCVSSData struct {
	V2Vector string  `json:"V2Vector,omitempty"`
	V3Vector string  `json:"V3Vector,omitempty"`
	V2Score  float64 `json:"V2Score,omitempty"`
	V3Score  float64 `json:"V3Score,omitempty"`
}

TrivyCVSSData contains CVSS scoring details.

type TrivyCauseMeta

type TrivyCauseMeta struct {
	Resource  string     `json:"Resource,omitempty"`
	Provider  string     `json:"Provider,omitempty"`
	Service   string     `json:"Service,omitempty"`
	StartLine int        `json:"StartLine,omitempty"`
	EndLine   int        `json:"EndLine,omitempty"`
	Code      *TrivyCode `json:"Code,omitempty"`
}

TrivyCauseMeta contains location details for misconfigurations.

type TrivyCode

type TrivyCode struct {
	Lines []TrivyCodeLine `json:"Lines,omitempty"`
}

TrivyCode contains the code snippet details.

type TrivyCodeLine

type TrivyCodeLine struct {
	Number  int    `json:"Number,omitempty"`
	Content string `json:"Content,omitempty"`
}

TrivyCodeLine is a single line of code.

type TrivyDS

type TrivyDS struct {
	ID   string `json:"ID,omitempty"`
	Name string `json:"Name,omitempty"`
	URL  string `json:"URL,omitempty"`
}

TrivyDS is a Trivy data source.

type TrivyImageConfig

type TrivyImageConfig struct {
	Architecture string `json:"architecture,omitempty"`
}

TrivyImageConfig holds container image configuration.

type TrivyMetadata

type TrivyMetadata struct {
	OS          *TrivyOS          `json:"OS,omitempty"`
	ImageID     string            `json:"ImageID,omitempty"`
	ImageConfig *TrivyImageConfig `json:"ImageConfig,omitempty"`
}

TrivyMetadata contains scan metadata.

type TrivyMisconfig

type TrivyMisconfig struct {
	Type          string          `json:"Type,omitempty"`
	ID            string          `json:"ID,omitempty"`
	AVDID         string          `json:"AVDID,omitempty"`
	Title         string          `json:"Title,omitempty"`
	Description   string          `json:"Description,omitempty"`
	Message       string          `json:"Message,omitempty"`
	Namespace     string          `json:"Namespace,omitempty"`
	Query         string          `json:"Query,omitempty"`
	Resolution    string          `json:"Resolution,omitempty"`
	Severity      string          `json:"Severity"`
	PrimaryURL    string          `json:"PrimaryURL,omitempty"`
	References    []string        `json:"References,omitempty"`
	Status        string          `json:"Status,omitempty"`
	CauseMetadata *TrivyCauseMeta `json:"CauseMetadata,omitempty"`
}

TrivyMisconfig represents a misconfiguration finding.

type TrivyOS

type TrivyOS struct {
	Family string `json:"Family,omitempty"`
	Name   string `json:"Name,omitempty"`
}

TrivyOS describes the operating system.

type TrivyReport

type TrivyReport struct {
	SchemaVersion int            `json:"SchemaVersion"`
	ArtifactName  string         `json:"ArtifactName,omitempty"`
	ArtifactType  string         `json:"ArtifactType,omitempty"`
	Metadata      *TrivyMetadata `json:"Metadata,omitempty"`
	Results       []TrivyResult  `json:"Results"`
}

TrivyReport is the root Trivy JSON document.

type TrivyResult

type TrivyResult struct {
	Target            string               `json:"Target"`
	Class             string               `json:"Class,omitempty"`
	Type              string               `json:"Type,omitempty"`
	Vulnerabilities   []TrivyVulnerability `json:"Vulnerabilities,omitempty"`
	Misconfigurations []TrivyMisconfig     `json:"Misconfigurations,omitempty"`
	Secrets           []TrivySecret        `json:"Secrets,omitempty"`
}

TrivyResult represents a scan result for a target.

type TrivySecret

type TrivySecret struct {
	RuleID    string `json:"RuleID,omitempty"`
	Category  string `json:"Category,omitempty"`
	Severity  string `json:"Severity"`
	Title     string `json:"Title,omitempty"`
	StartLine int    `json:"StartLine,omitempty"`
	EndLine   int    `json:"EndLine,omitempty"`
	Match     string `json:"Match,omitempty"`
}

TrivySecret represents a secret finding from Trivy.

type TrivyVulnerability

type TrivyVulnerability struct {
	VulnerabilityID  string    `json:"VulnerabilityID"`
	PkgName          string    `json:"PkgName"`
	PkgPath          string    `json:"PkgPath,omitempty"`
	InstalledVersion string    `json:"InstalledVersion"`
	FixedVersion     string    `json:"FixedVersion,omitempty"`
	Severity         string    `json:"Severity"`
	Title            string    `json:"Title,omitempty"`
	Description      string    `json:"Description,omitempty"`
	PrimaryURL       string    `json:"PrimaryURL,omitempty"`
	DataSource       *TrivyDS  `json:"DataSource,omitempty"`
	CVSS             TrivyCVSS `json:"CVSS,omitempty"`
	CweIDs           []string  `json:"CweIDs,omitempty"`
	References       []string  `json:"References,omitempty"`
	PublishedDate    string    `json:"PublishedDate,omitempty"`
	LastModifiedDate string    `json:"LastModifiedDate,omitempty"`
	Status           string    `json:"Status,omitempty"`
}

TrivyVulnerability represents a vulnerability finding.

Jump to

Keyboard shortcuts

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