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 ¶
- func MarshalSARIF(findings []finding.Finding, version string, opts SARIFOptions) ([]byte, error)
- type SARIFArtifactLocation
- type SARIFConfig
- type SARIFDriver
- type SARIFLocation
- type SARIFLog
- type SARIFLogicalLocation
- type SARIFOptions
- type SARIFPhysicalLocation
- type SARIFRegion
- type SARIFResult
- type SARIFRule
- type SARIFRun
- type SARIFText
- type SARIFTool
- type Service
- type VEXDoc
- type VEXProduct
- type VEXStatement
- type VEXVuln
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalSARIF ¶
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), and Fix adds the remediating version. Both 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 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 SARIFLogicalLocation ¶
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
}
SARIFOptions carries optional per-finding resolvers that enrich SCA results. Both fields are 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 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 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 ¶
NewService wires the export use case.
func (*Service) OpenVEX ¶
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 ¶
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) 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 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"`
}