audit

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package audit defines the wire types every detector emits and the shared serializer that renders them as JSON or text.

Finding is the per-smell record. Report is the top-level envelope. Severity ranks findings from CRITICAL down to LOW; Emit sorts and writes a Report to stdout.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Emit

func Emit(report *Report, format string) error

Emit serializes a report in the requested format ("json" or "text"). Findings are sorted by severity, smell ID, then location for stable output across runs.

func ResolvedTags

func ResolvedTags(tags string) []string

ResolvedTags splits a comma-separated --tags flag value into the slice that goes into the report envelope. Returns nil when no tags were supplied.

Types

type Finding

type Finding struct {
	Smell      string         `json:"smell"`
	SmellID    string         `json:"smell_id"`
	Severity   Severity       `json:"severity"`
	Location   string         `json:"location"`
	Message    string         `json:"message"`
	Evidence   map[string]any `json:"evidence,omitempty"`
	Suggestion string         `json:"suggestion,omitempty"`
}

Finding is one entry in a lagotto audit. Every detector emits zero or more findings; the JSON shape is the stable downstream contract.

Field semantics:

  • Smell: human-readable name ("Receiver Monolith")
  • SmellID: short stable ID ("G1") — use this in tooling
  • Severity: CRITICAL | HIGH | MEDIUM | LOW
  • Location: directory and (for type-level smells) the type name
  • Message: one-line summary suitable for a terminal
  • Evidence: structured per-detector data (method counts, file lists, package paths) for tooling that wants to drill in
  • Suggestion: concrete imperative remediation guidance

type Report

type Report struct {
	Root     string    `json:"root"`
	Tags     []string  `json:"tags,omitempty"`
	Findings []Finding `json:"findings"`
}

Report is the top-level audit envelope written to stdout. Root is the path the audit was run against, Tags echoes the build tags the loader used, and Findings is severity-sorted (CRITICAL first).

type Severity

type Severity string

Severity ranks findings from CRITICAL (always investigate) down to LOW (worth knowing about, low blast radius). Severity is a string so the JSON output is human-readable.

const (
	SevCritical Severity = "CRITICAL"
	SevHigh     Severity = "HIGH"
	SevMedium   Severity = "MEDIUM"
	SevLow      Severity = "LOW"
)

Severity values; ranking is CRITICAL < HIGH < MEDIUM < LOW (lower is worse), matched by sevRank.

Jump to

Keyboard shortcuts

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