Documentation
¶
Index ¶
- Constants
- Variables
- func ComputeBundleDigest(data []byte) string
- func ComputeFileDigestHex(path string) (string, error)
- func ReadJSONL(path string) ([]findings.Finding, error)
- func RenderCSV(list []findings.Finding, opts ReportOptions) ([]byte, error)
- func RenderHTML(list []findings.Finding, opts ReportOptions) (string, error)
- func RenderJSON(list []findings.Finding, opts ReportOptions) ([]byte, error)
- func RenderMarkdown(list []findings.Finding, opts ReportOptions) string
- func RenderReport(inputPath, outputPath string, format ReportFormat, opts ReportOptions) error
- func RenderXML(list []findings.Finding, opts ReportOptions) ([]byte, error)
- func SendReportViaIntegration(config IntegrationConfig, list []findings.Finding, opts ReportOptions) error
- func SendToSlack(webhookURL string, list []findings.Finding, opts ReportOptions) error
- func SendToWebhook(webhookURL string, list []findings.Finding, opts ReportOptions, ...) error
- func SignArtifact(artifactPath, keyPath string) (string, error)
- func VerifyArtifact(artifactPath, signaturePath, keyPath string) error
- func WriteCSV(w io.Writer, list []findings.Finding, opts ReportOptions) error
- func WriteXML(w io.Writer, list []findings.Finding, opts ReportOptions) error
- type Bundle
- type Digest
- type IntegrationConfig
- type IntegrationType
- type JSONL
- type JSONLOption
- type PluginCount
- type ReportFormat
- type ReportOptions
- type SBOMReference
- type SlackAttachment
- type SlackBlock
- type SlackField
- type SlackPayload
- type SlackTextObject
- type Summary
- type TargetCount
- type WebhookPayload
- type XMLFinding
- type XMLMetadata
- type XMLReport
- type XMLSeverityBreakdown
- type XMLSummary
Constants ¶
const BundleSchemaVersion = "1.0"
BundleSchemaVersion identifies the JSON structure emitted by 0xgen when exporting reports.
const (
// DefaultTopTargets controls how many targets appear in summary tables.
DefaultTopTargets = 10
)
Variables ¶
var ( // DefaultFindingsPath is where 0xgend persists findings for other tools to consume. DefaultFindingsPath = filepath.Join(defaultOutputDir, findingsFilename) // DefaultReportPath is the default markdown summary written for CAP_REPORT consumers. DefaultReportPath = filepath.Join(defaultOutputDir, reportFilename) // DefaultHTMLReportPath is where the interactive HTML report is written when no --out flag is provided. DefaultHTMLReportPath = filepath.Join(defaultOutputDir, htmlReportFilename) // DefaultJSONReportPath is where the JSON bundle is written when no --out flag is provided. DefaultJSONReportPath = filepath.Join(defaultOutputDir, jsonReportFilename) )
Functions ¶
func ComputeBundleDigest ¶
ComputeBundleDigest calculates the SHA-256 digest for the provided bytes in hex form.
func ComputeFileDigestHex ¶
ComputeFileDigestHex returns the SHA-256 digest for the file at the provided path.
func ReadJSONL ¶
ReadJSONL reads findings from an arbitrary JSONL file path without creating a reporter.
func RenderCSV ¶
func RenderCSV(list []findings.Finding, opts ReportOptions) ([]byte, error)
RenderCSV generates a CSV export of findings.
func RenderHTML ¶
func RenderHTML(list []findings.Finding, opts ReportOptions) (string, error)
RenderHTML produces an interactive HTML report backed by the case bundle dataset.
func RenderJSON ¶
func RenderJSON(list []findings.Finding, opts ReportOptions) ([]byte, error)
RenderJSON converts a slice of findings into a signed bundle payload.
func RenderMarkdown ¶
func RenderMarkdown(list []findings.Finding, opts ReportOptions) string
RenderMarkdown converts a slice of findings into a markdown report.
func RenderReport ¶
func RenderReport(inputPath, outputPath string, format ReportFormat, opts ReportOptions) error
RenderReport loads findings from inputPath and writes a summary to outputPath.
func RenderXML ¶
func RenderXML(list []findings.Finding, opts ReportOptions) ([]byte, error)
RenderXML generates an XML export of findings.
func SendReportViaIntegration ¶
func SendReportViaIntegration(config IntegrationConfig, list []findings.Finding, opts ReportOptions) error
SendReportViaIntegration sends a report using the specified integration.
func SendToSlack ¶
func SendToSlack(webhookURL string, list []findings.Finding, opts ReportOptions) error
SendToSlack sends a report summary to Slack.
func SendToWebhook ¶
func SendToWebhook(webhookURL string, list []findings.Finding, opts ReportOptions, customHeaders map[string]string) error
SendToWebhook sends a report to a generic webhook.
func SignArtifact ¶
SignArtifact generates a detached cosign-compatible signature alongside the report artifact.
func VerifyArtifact ¶
VerifyArtifact validates a detached cosign-compatible signature for the provided artifact.
Types ¶
type Bundle ¶
type Bundle struct {
SchemaVersion string `json:"schema_version"`
GeneratedAt time.Time `json:"-"`
FindingsCount int `json:"findings_count"`
Summary Summary `json:"summary"`
Cases []cases.Case `json:"cases"`
Findings []findings.Finding `json:"findings"`
Telemetry exporter.Telemetry `json:"telemetry"`
SBOM *SBOMReference `json:"sbom,omitempty"`
}
Bundle aggregates the dataset required to recreate the interactive report view.
func BuildBundle ¶
BuildBundle constructs the structured dataset backing HTML and JSON reports.
func (Bundle) MarshalJSON ¶
MarshalJSON renders the bundle using the public schema while preserving UTC ordering.
type IntegrationConfig ¶
type IntegrationConfig struct {
Type IntegrationType
URL string
Headers map[string]string
Timeout time.Duration
CustomFormat bool // If true, send raw report data; else use integration-specific format
}
IntegrationConfig holds configuration for sending reports to external systems.
type IntegrationType ¶
type IntegrationType string
IntegrationType specifies the type of integration.
const ( IntegrationSlack IntegrationType = "slack" IntegrationWebhook IntegrationType = "webhook" )
type JSONL ¶
type JSONL struct {
// contains filtered or unexported fields
}
JSONL handles persisting findings to a JSON Lines file.
func NewJSONL ¶
func NewJSONL(path string, opts ...JSONLOption) *JSONL
NewJSONL creates a reporter that writes findings to the provided path.
type JSONLOption ¶
type JSONLOption func(*jsonlConfig)
JSONLOption configures optional behaviour for the writer.
func WithBufferLength ¶
func WithBufferLength(length int) JSONLOption
WithBufferLength overrides the buffer used while writing to disk.
func WithMaxBytes ¶
func WithMaxBytes(limit int64) JSONLOption
WithMaxBytes overrides the rotation threshold. A value <= 0 disables rotation.
func WithMaxFiles ¶
func WithMaxFiles(count int) JSONLOption
WithMaxFiles controls how many rotated files are retained.
type PluginCount ¶
type ReportFormat ¶
type ReportFormat string
ReportFormat identifies the type of report to generate.
const ( // FormatMarkdown renders a Markdown report. FormatMarkdown ReportFormat = "md" // FormatHTML renders an HTML report. FormatHTML ReportFormat = "html" // FormatJSON renders a machine-readable bundle. FormatJSON ReportFormat = "json" // FormatCSV renders a CSV spreadsheet. FormatCSV ReportFormat = "csv" // FormatXML renders an XML report. FormatXML ReportFormat = "xml" )
type ReportOptions ¶
type ReportOptions struct {
// Since filters findings to those detected on or after the provided timestamp.
// A zero value disables the filter.
Since *time.Time
// Now identifies the end of the reporting window. When unset, time.Now() is used.
Now time.Time
// Context provides cancellation for expensive case aggregation.
Context context.Context
// SBOMPath links the generated report to the SBOM used for dependency analysis.
SBOMPath string
}
ReportOptions customises the filtering applied when rendering a report.
type SBOMReference ¶
type SBOMReference struct {
Path string `json:"path"`
Digest Digest `json:"digest"`
SizeBytes int64 `json:"size_bytes,omitempty"`
}
SBOMReference links the report bundle to the SBOM used during analysis.
type SlackAttachment ¶
type SlackAttachment struct {
Color string `json:"color,omitempty"`
Title string `json:"title,omitempty"`
Text string `json:"text,omitempty"`
Fields []SlackField `json:"fields,omitempty"`
}
SlackAttachment represents a Slack message attachment.
type SlackBlock ¶
type SlackBlock struct {
Type string `json:"type"`
Text *SlackTextObject `json:"text,omitempty"`
Fields []SlackTextObject `json:"fields,omitempty"`
}
SlackBlock represents a Slack block element.
type SlackField ¶
type SlackField struct {
Title string `json:"title"`
Value string `json:"value"`
Short bool `json:"short"`
}
SlackField represents a field in a Slack attachment.
type SlackPayload ¶
type SlackPayload struct {
Text string `json:"text,omitempty"`
Blocks []SlackBlock `json:"blocks,omitempty"`
Attachments []SlackAttachment `json:"attachments,omitempty"`
}
SlackPayload represents a Slack message payload.
type SlackTextObject ¶
SlackTextObject represents text in a Slack message.
type Summary ¶
type Summary struct {
WindowStart *time.Time
WindowEnd time.Time
GeneratedAt time.Time
Total int
SeverityCount map[findings.Severity]int
Targets []TargetCount
Plugins []PluginCount
Recent []findings.Finding
}
Summary captures aggregate report statistics for use across renderers.
func (Summary) MarshalJSON ¶
type TargetCount ¶
type WebhookPayload ¶
type WebhookPayload struct {
Event string `json:"event"`
Timestamp string `json:"timestamp"`
Summary interface{} `json:"summary"`
Findings interface{} `json:"findings"`
}
WebhookPayload represents a generic webhook payload.
type XMLFinding ¶
type XMLFinding struct {
ID string `xml:"ID,attr"`
Severity string `xml:"Severity"`
Type string `xml:"Type"`
Message string `xml:"Message"`
Target string `xml:"Target,omitempty"`
Evidence string `xml:"Evidence,omitempty"`
Plugin string `xml:"Plugin"`
DetectedAt string `xml:"DetectedAt"`
Metadata []XMLMetadata `xml:"Metadata>Entry,omitempty"`
}
XMLFinding represents a single security finding.
type XMLMetadata ¶
XMLMetadata represents a key-value metadata pair.
type XMLReport ¶
type XMLReport struct {
XMLName xml.Name `xml:"SecurityReport"`
Version string `xml:"version,attr"`
Summary XMLSummary `xml:"Summary"`
Findings []XMLFinding `xml:"Findings>Finding"`
}
XMLReport represents the root XML structure for a security report.
type XMLSeverityBreakdown ¶
type XMLSeverityBreakdown struct {
Critical int `xml:"Critical"`
High int `xml:"High"`
Medium int `xml:"Medium"`
Low int `xml:"Low"`
Info int `xml:"Info"`
}
XMLSeverityBreakdown contains counts by severity.
type XMLSummary ¶
type XMLSummary struct {
Total int `xml:"TotalFindings"`
GeneratedAt string `xml:"GeneratedAt"`
WindowStart string `xml:"WindowStart,omitempty"`
WindowEnd string `xml:"WindowEnd"`
SeverityBreakdown XMLSeverityBreakdown `xml:"SeverityBreakdown"`
}
XMLSummary contains aggregate statistics.