repocheck

package
v0.4.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2026 License: Apache-2.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package repocheck holds the repository-wide consistency tests (formats page, stability table, package catalogs and names, documentation Go samples, agent skill, format conformance coverage, example platform targets); it has no API.

Privacy rules shared by the repository scan (TestNoPrivateFindings) and the release package scan (internal/pkgscan): the file names, personal paths and credential shapes the repository refuses to carry.

Index

Constants

View Source
const PrivacyExemptionsPath = "internal/repocheck/testdata/privacy-exemptions.yaml"

PrivacyExemptionsPath is the versioned list of reviewed privacy findings that are safe to keep, relative to the repository root.

Variables

This section is empty.

Functions

func ApplyPrivacyExemptions

func ApplyPrivacyExemptions(findings []Finding, x Exemptions) (kept []Finding, unused []Exemption)

ApplyPrivacyExemptions drops the exempted findings and returns the rest, with the entries that exempted nothing.

func EncodePrivacyExemptions

func EncodePrivacyExemptions(x Exemptions) ([]byte, error)

EncodePrivacyExemptions writes the document in the committed layout, so a parse and encode round trip reproduces the file.

func ScanShippedFiles

func ScanShippedFiles(fsys fs.FS, names []string) ([]Finding, Coverage, error)

ScanShippedFiles applies the rules to the named files of a package's contents, which, unlike the repository, are mostly binary. It does what ScanPrivacy does and also runs the secret rules over the printable bytes of binary files (ScanBinary) and the personal path rule over the targets of symbolic links (ScanLinkTarget), and it counts how each file was scanned.

Types

type Coverage

type Coverage struct {
	Text, Binary, Links int
}

Coverage counts how ScanShippedFiles scanned a package's files, so its caller can say what each rule saw: Text files got every rule, Binary files only the secret rules (ScanBinary), and Links only the personal path rule over their targets (ScanLinkTarget).

type Exemption

type Exemption struct {
	Path    string `yaml:"path"`
	Pattern string `yaml:"pattern,omitempty"`
	Reason  string `yaml:"reason"`
}

Exemption allows the findings in one tracked file: only those whose matched text contains Pattern, or every finding in the file when Pattern is empty.

type Exemptions

type Exemptions struct {
	Version int         `yaml:"version"`
	Entries []Exemption `yaml:"entries"`
}

Exemptions is the document stored at privacyExemptionsPath.

func ParsePrivacyExemptions

func ParsePrivacyExemptions(data []byte) (Exemptions, error)

ParsePrivacyExemptions decodes and validates an exemptions document: version 1, unknown fields refused, every entry with a clean relative path and a reason, sorted by path and pattern without duplicates.

type Finding

type Finding struct {
	Path   string
	Line   int
	Rule   string
	Match  string
	Binary bool
	Offset int
}

Finding is one rule hit in one tracked file. A hit in a binary file has no line: Binary is set and Offset is the byte offset of the match.

func ScanBinary

func ScanBinary(name string, data []byte) []Finding

ScanBinary applies the secret rules to the printable runs of a binary file, as strings(1) would list them: every byte outside printable ASCII, tab, line feed and carriage return separates runs. The personal path rule is not applied, because a compiled binary can carry build paths that are not private data, and the release builds use -trimpath so their own paths do not appear.

func ScanLinkTarget

func ScanLinkTarget(name, target string) []Finding

ScanLinkTarget applies the personal path rule to the target of the symbolic or hard link name, so a link into a build machine's home directory is reported even though the link itself is never followed.

func ScanPrivacy

func ScanPrivacy(fsys fs.FS, names []string) ([]Finding, error)

ScanPrivacy applies the file name, personal path and secret rules to the named files of fsys, as the repository scan does. Symbolic links, directories (such as submodules), missing files and binary files (any NUL byte) are skipped.

func ScanText

func ScanText(name string, text []byte) []Finding

ScanText applies the personal path and secret rules to the text of the file name.

func (Finding) String

func (f Finding) String() string

Jump to

Keyboard shortcuts

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