Documentation
¶
Overview ¶
Package parser provides stateless functions for extracting metadata and vulnerability data from raw Trivy JSON reports. It is pure domain logic — it has no dependency on persistence or presentation layers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CountVulnerabilities ¶
func CountVulnerabilities(raw json.RawMessage) entities.VulnCounts
CountVulnerabilities performs a single-pass count of vulnerabilities by severity from a raw Trivy JSON report. Missing or unrecognised severities count as Unknown.
func ExtractVulnerabilities ¶
func ExtractVulnerabilities(raw json.RawMessage) []entities.Vulnerability
ExtractVulnerabilities parses all vulnerabilities from a raw Trivy JSON report into a flat slice ready for bulk database insertion. Never returns nil; returns an empty slice on parse failure or no vulnerabilities.
Types ¶
type ImageMeta ¶
ImageMeta holds the extracted image identifiers from a Trivy report.
func ExtractMeta ¶
func ExtractMeta(raw json.RawMessage) (ImageMeta, error)
ExtractMeta parses a raw Trivy JSON payload and returns extracted image metadata. Optional fields may be absent; callers can override with query params.
type TrivyMetadata ¶
type TrivyMetadata struct {
ImageID string `json:"ImageID"`
RepoDigests []string `json:"RepoDigests"`
RepoTags []string `json:"RepoTags"`
}
TrivyMetadata holds image-level metadata from a Trivy scan.
type TrivyReport ¶
type TrivyReport struct {
ArtifactName string `json:"ArtifactName"`
ArtifactType string `json:"ArtifactType"`
Metadata TrivyMetadata `json:"Metadata"`
}
TrivyReport represents the top-level structure of a Trivy JSON report.