diff

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package diff compares two Draugr scan results and classifies every finding as new, fixed, or unchanged — the security delta of a change (typically a PR's head vs the base branch). It powers `draugr diff` and its differential gate ("fail only on findings this change introduces").

Inputs are SARIF reports (the results.sarif that `draugr scan -o` writes): SARIF is Draugr's complete, structured result currency, whereas the JSON summary can be trimmed by --min-priority.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Formats

func Formats() []string

Formats lists the diff output formats, sorted.

func Render

func Render(w io.Writer, format string, r Result) error

Render writes the diff in the named format. Unknown formats error.

Types

type LevelCounts

type LevelCounts struct {
	Error   int `json:"error"`
	Warning int `json:"warning"`
	Note    int `json:"note"`
}

LevelCounts tallies findings by SARIF level.

type PriorityCounts

type PriorityCounts struct {
	P1 int `json:"p1"`
	P2 int `json:"p2"`
	P3 int `json:"p3"`
	P4 int `json:"p4"`
}

PriorityCounts tallies findings by action band. Unprioritized findings are not counted here.

type Result

type Result struct {
	New       []sarif.Result // present in head, absent in base
	Fixed     []sarif.Result // present in base, absent in head
	Unchanged []sarif.Result // present in both (head copy)
}

Result is the classified delta between a base and a head report.

func Compare

func Compare(base, head sarif.Report) Result

Compare classifies every finding across the two reports by stable identity.

func (Result) GateNew

func (r Result) GateNew(failOn sarif.Level, failOnPriority string) []sarif.Result

GateNew returns the new findings that meet the differential gate: level at or above failOn (when set) OR priority at or above failOnPriority (when set). An empty threshold disables that dimension. With both empty, nothing is returned.

Jump to

Keyboard shortcuts

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