export

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package export builds deterministic SARIF 2.1.0 + OpenVEX documents from stored findings. Templated from data – no LLM in the report path.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalSARIF

func MarshalSARIF(findings []finding.Finding, version string, opts SARIFOptions) ([]byte, error)

MarshalSARIF renders findings as an indented SARIF 2.1.0 log – the artifact a code-scanning uploader (e.g. GitHub `codeql-action/upload-sarif`) consumes. It is deterministic and templated purely from stored findings: no clock, no LLM (golden rule 5). version is the synapse driver version recorded on the run's tool driver. opts carries optional per-finding resolvers: Manifest gives SCA findings a physical location (a repo-relative manifest path), Fix adds the remediating version, and AIGateExemption explains policy-authorized external suppression without removing the result. All are nil-safe; pass the zero SARIFOptions to enrich nothing.

Types

type SARIFArtifactLocation

type SARIFArtifactLocation struct {
	URI string `json:"uri"` // repo-relative path (GitHub matches it against the PR diff)
}

type SARIFConfig

type SARIFConfig struct {
	Level string `json:"level"`
}

type SARIFDriver

type SARIFDriver struct {
	Name           string      `json:"name"`
	Version        string      `json:"version"`
	InformationURI string      `json:"informationUri,omitempty"`
	Rules          []SARIFRule `json:"rules"`
}

type SARIFLocation

type SARIFLocation struct {
	// A first-party finding (SAST/secret/misconfig) has a source file:line -> physicalLocation, so a
	// code-scanning UI annotates the exact line. An SCA finding is about a dependency, not a source
	// line -> logicalLocation module. Exactly one is set per location.
	PhysicalLocation *SARIFPhysicalLocation `json:"physicalLocation,omitempty"`
	LogicalLocations []SARIFLogicalLocation `json:"logicalLocations,omitempty"`
}

type SARIFLog

type SARIFLog struct {
	Schema  string     `json:"$schema"`
	Version string     `json:"version"`
	Runs    []SARIFRun `json:"runs"`
}

type SARIFLogicalLocation

type SARIFLogicalLocation struct {
	Name string `json:"name"`
	Kind string `json:"kind,omitempty"`
}

type SARIFOptions

type SARIFOptions struct {
	// Manifest returns the repo-relative manifest/lockfile that declares a dependency finding's
	// component, so the result gets a physical location a code-scanning UI can annotate. "" when unknown.
	Manifest func(finding.Finding) string
	// Fix returns the version that remediates a dependency finding. "" when there is no fix or it is unknown.
	Fix func(finding.Finding) string
	// AIGateExemption returns policy metadata only when the finding's exemption has already passed the
	// server-owned authorization re-check. SARIF renders it as an external accepted suppression while
	// retaining the result. Advisory or review-required opinions must return false.
	AIGateExemption func(finding.Finding) (ports.AIGateExemption, bool)
}

SARIFOptions carries optional per-finding resolvers. Every field is nil-safe.

type SARIFPhysicalLocation

type SARIFPhysicalLocation struct {
	ArtifactLocation SARIFArtifactLocation `json:"artifactLocation"`
	Region           *SARIFRegion          `json:"region,omitempty"`
}

type SARIFRegion

type SARIFRegion struct {
	StartLine int `json:"startLine"` // 1-based; SARIF requires >= 1
}

type SARIFResult

type SARIFResult struct {
	RuleID       string             `json:"ruleId"`
	Level        string             `json:"level"`
	Message      SARIFText          `json:"message"`
	Locations    []SARIFLocation    `json:"locations,omitempty"`
	Suppressions []SARIFSuppression `json:"suppressions,omitempty"`
	Properties   map[string]any     `json:"properties,omitempty"`
}

type SARIFRule

type SARIFRule struct {
	ID                   string       `json:"id"`
	ShortDescription     SARIFText    `json:"shortDescription"`
	HelpURI              string       `json:"helpUri,omitempty"`
	DefaultConfiguration *SARIFConfig `json:"defaultConfiguration,omitempty"`
}

type SARIFRun

type SARIFRun struct {
	Tool    SARIFTool     `json:"tool"`
	Results []SARIFResult `json:"results"`
}

type SARIFSuppression added in v0.1.8

type SARIFSuppression struct {
	Kind          string `json:"kind"`
	Status        string `json:"status,omitempty"`
	Justification string `json:"justification,omitempty"`
}

type SARIFText

type SARIFText struct {
	Text string `json:"text"`
}

type SARIFTool

type SARIFTool struct {
	Driver SARIFDriver `json:"driver"`
}

type Service

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

Service renders an engagement's findings as SARIF or OpenVEX.

func NewService

func NewService(findings ports.FindingRepository, clock ports.Clock, version string) *Service

NewService wires the export use case.

func (*Service) OpenVEX

func (s *Service) OpenVEX(ctx context.Context, engagementID shared.ID) (*VEXDoc, error)

OpenVEX returns the engagement's vulnerability findings as an OpenVEX document. It reads through the publishability gate – consistent with SARIF and the report path – so an unproven exploitation finding is never asserted in a VEX statement.

func (*Service) SARIF

func (s *Service) SARIF(ctx context.Context, engagementID shared.ID) (*SARIFLog, error)

SARIF returns the engagement's findings as a SARIF 2.1.0 log. It reads through the publishability gate so an unproven exploitation finding never ships in the exported log.

func (*Service) SetAIGateExemptions added in v0.1.8

func (s *Service) SetAIGateExemptions(reader ports.AIGateExemptionReader)

SetAIGateExemptions wires the latest-scan policy projection used to annotate retained SARIF results. nil keeps legacy exports unannotated.

func (*Service) SetJudgments

func (s *Service) SetJudgments(j judgmentReader)

SetJudgments wires the reachability-judgment reader so OpenVEX picks the not_affected justification by reachability tier. nil ⇒ the default justification.

type VEXDoc

type VEXDoc struct {
	Context    string         `json:"@context"`
	ID         string         `json:"@id"`
	Author     string         `json:"author"`
	Timestamp  string         `json:"timestamp"`
	Version    int            `json:"version"`
	Tooling    string         `json:"tooling,omitempty"`
	Statements []VEXStatement `json:"statements"`
}

type VEXProduct

type VEXProduct struct {
	ID string `json:"@id"`
}

type VEXStatement

type VEXStatement struct {
	Vulnerability VEXVuln      `json:"vulnerability"`
	Products      []VEXProduct `json:"products"`
	Status        string       `json:"status"`
	Justification string       `json:"justification,omitempty"`
}

type VEXVuln

type VEXVuln struct {
	Name string `json:"name"`
}

Jump to

Keyboard shortcuts

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