policy

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package policy implements a Debian Policy focused linter for binary packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckInfo

type CheckInfo struct {
	Code        string   `json:"code"`
	Name        string   `json:"name"`
	Severity    Severity `json:"severity"`
	Description string   `json:"description"`
	Reference   string   `json:"reference,omitempty"`
}

CheckInfo is the public description of a check.

func CheckInfos

func CheckInfos() []CheckInfo

CheckInfos returns the metadata of every registered check.

type Finding

type Finding struct {
	Code     string   `json:"code"`
	Severity Severity `json:"severity"`
	Message  string   `json:"message"`
	Path     string   `json:"path,omitempty"`
	Advice   string   `json:"advice,omitempty"`
}

Finding is one policy violation.

type Report

type Report struct {
	Artifact     string    `json:"artifact"`
	Package      string    `json:"package"`
	Version      string    `json:"version"`
	Architecture string    `json:"architecture"`
	Checks       int       `json:"checks"`
	Errors       int       `json:"errors"`
	Warnings     int       `json:"warnings"`
	Infos        int       `json:"infos"`
	Findings     []Finding `json:"findings"`
}

Report is the complete lint result for one artifact.

func Lint

func Lint(archive *deb.Archive, artifact string) Report

Lint runs every registered policy check against a package.

func (*Report) FailOn

func (r *Report) FailOn(threshold string) bool

FailOn reports whether the report meets the given threshold.

func (*Report) FormatText

func (r *Report) FormatText() string

FormatText renders a human readable report.

func (*Report) WriteJSON

func (r *Report) WriteJSON(w io.Writer) error

WriteJSON writes the report as indented JSON.

func (*Report) WriteSARIF

func (r *Report) WriteSARIF(w io.Writer, version string) error

WriteSARIF writes a SARIF 2.1.0 report usable by code scanning.

type Severity

type Severity string

Severity ranks a finding.

const (
	SeverityError   Severity = "error"
	SeverityWarning Severity = "warning"
	SeverityInfo    Severity = "info"
)

Finding severities.

func (Severity) Rank

func (s Severity) Rank() int

Rank returns a comparable weight for a severity.

Jump to

Keyboard shortcuts

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