report

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package report renders scan results for humans (colored terminal) and machines (JSON), and decides the process exit code for CI gating.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExitCode

func ExitCode(s *Summary, failOn analyzer.RiskLevel, failOnError bool) int

ExitCode implements CI gating: 0 below threshold, 2 at/above it, 3 when analysis errors occurred and failOnError is set.

func JSON

func JSON(w io.Writer, s *Summary, meta Meta) error

JSON writes the structured machine-readable report.

func ParseRisk

func ParseRisk(s string) (analyzer.RiskLevel, error)

ParseRisk converts a --fail-on flag value.

func SARIF

func SARIF(w io.Writer, s *Summary, meta Meta) error

SARIF writes the scan results as a SARIF 2.1.0 log.

func Terminal

func Terminal(w io.Writer, s *Summary)

Terminal prints the detailed human report for every non-clean package.

Types

type Meta

type Meta struct {
	Version string   // tool version stamp
	Targets []string // lockfiles scanned, or "cli" for check mode
	FailOn  string   // configured threshold, so consumers know the gate
}

Meta carries run-level context the CLI knows and the report layer doesn't.

type Summary

type Summary struct {
	Scanned    int               `json:"scanned"`
	Errors     int               `json:"errors"`
	Suppressed int               `json:"suppressed"`
	Elapsed    time.Duration     `json:"elapsed_ns"`
	ByRisk     map[string]int    `json:"by_risk"`
	Results    []analyzer.Result `json:"results"`
	// contains filtered or unexported fields
}

Summary aggregates a full run.

func Collect

func Collect(w io.Writer, ch <-chan analyzer.Result, quiet bool, lg *runlog.Logger) *Summary

Collect drains the results channel, streaming per-package lines to w as they arrive (quiet=false), recording every outcome to the execution log, and returning the aggregated summary.

func Rebuild

func Rebuild(results []analyzer.Result, elapsed time.Duration) *Summary

Rebuild recomputes a Summary's aggregates from its Results slice. Used after the retry pass merges fresh results over previously errored ones.

Jump to

Keyboard shortcuts

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