guard

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const PathPrefix = ".commitbrief/"

PathPrefix is the trigger condition: any diff file whose path starts with this string (i.e., lives under the .commitbrief/ directory) prompts the user. Root-level COMMITBRIEF.md and .commitbriefignore are intentionally excluded — they are team-shared by design (ADR-0007).

Variables

This section is empty.

Functions

func SecretPatternNames added in v0.8.0

func SecretPatternNames() []string

SecretPatternNames returns the labels of every pattern the scanner knows about, sorted alphabetically. Used by docs/tests as the authoritative list — keeps drift between the table here and the CHANGELOG/README description detectable.

func Triggers

func Triggers(d diff.Diff) []string

Types

type Options

type Options struct {
	AssumeYes      bool
	NonInteractive bool
	Writer         io.Writer
	Reader         io.Reader
}

type Result

type Result int
const (
	Continue Result = iota
	Abort
)

func CheckDiffForLocalConfig

func CheckDiffForLocalConfig(d diff.Diff, opts Options) (Result, error)

func (Result) String

func (r Result) String() string

type SecretMatch added in v0.8.0

type SecretMatch struct {
	Line     int      // 1-based line number within the diff string
	Patterns []string // alphabetised pattern names that matched this line
}

SecretMatch describes a single line in the diff that looks like it might contain a credential the user shouldn't ship to an LLM. Only the line number and the matched-pattern names are recorded — never the matched substring itself, so the scanner's own output can't become a secondary leak vector via logs, stderr, or cache files.

func ScanForSecrets added in v0.8.0

func ScanForSecrets(diff string) []SecretMatch

ScanForSecrets walks the diff and reports any added line (prefixed with a single `+`, excluding the `+++ b/path` header) that matches one or more of the credential patterns. Removed and context lines are skipped — the goal is to catch *new* leaks, not to re-flag historical content that's already on disk somewhere.

Returns a slice of matches sorted by line number. An empty diff or a diff with no `+` lines returns nil — callers can rely on `len(out) == 0` as the "all clear" signal.

Jump to

Keyboard shortcuts

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