scanning

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package scanning is the secret-scanning ruleset (ADR docs/adr/secret-scanning.md).

The compiled ruleset is a pinned, allowlisted, fixtured snapshot of the gitleaks rules plus one Hikyo-owned two-stage rule for the hik_ family. The runtime here imports no hash/HMAC primitive: per-rule semantic digests and the snapshot version are computed at generation and embedded as constants (see internal/scanning/gen). A Finding carries a rule id only — no match text, offset, length or excerpt exists on any exported type (ADR §4), so the scanner cannot mint a new disclosure path.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Finding

type Finding struct {
	RuleID string
}

Finding is the redacted result: a rule id and nothing else. No match text, offset, length or excerpt may ever be added — the type is the enforcement point for the non-disclosure invariant (ADR §4, SS4).

type Ruleset

type Ruleset struct {
	// contains filtered or unexported fields
}

Ruleset is the validated, boot-compiled ruleset.

func Load

func Load() (*Ruleset, error)

Load validates the embedded compiled ruleset and returns it. Any inconsistency is an error; server boot refuses to start on it (fail fast, ADR §7). Load is the only constructor callers use.

func (*Ruleset) RuleIDs

func (r *Ruleset) RuleIDs() []string

RuleIDs returns the compiled rule ids in table order.

func (*Ruleset) Scan

func (r *Ruleset) Scan(ctx context.Context, content []byte) ([]Finding, error)

Scan reports which rules match content. It returns one Finding per matched rule (no offsets, so duplicate hits carry no information). Keywords prefilter only. ctx cancellation/deadline is honoured between rules — the scan shares the enclosing operation's clock (ADR §7).

func (*Ruleset) SemanticDigest

func (r *Ruleset) SemanticDigest(ruleID string) (string, bool)

SemanticDigest returns the generation-time digest of a rule, used to key dismissals (ADR §4). The second result is false for an unknown rule id.

func (*Ruleset) SnapshotVersion

func (r *Ruleset) SnapshotVersion() string

SnapshotVersion is the stable identifier binding the gitleaks pin and the allowlist digest (ADR §4).

func (*Ruleset) Subset

func (r *Ruleset) Subset(ids []string) (*Ruleset, error)

Subset returns a ruleset carrying only the named rules, with their compiled form, semantic digests and snapshot version unchanged, so a verdict from the subset is the verdict the full ruleset gives for those rules. It narrows and never widens: an unknown id, a duplicate or an empty selection is an error.

Directories

Path Synopsis
Package bench is the schema shared by cmd/bench-scan (which writes the result artifact) and the scanning validation test (which parses it).
Package bench is the schema shared by cmd/bench-scan (which writes the result artifact) and the scanning validation test (which parses it).
Package corpus is the true-positive / false-positive fixture corpus for the secret scanner (ADR §3, SS1).
Package corpus is the true-positive / false-positive fixture corpus for the secret scanner (ADR §3, SS1).
Command gen produces internal/scanning/rules_gen.go from the vendored gitleaks snapshot plus the committed allowlist.
Command gen produces internal/scanning/rules_gen.go from the vendored gitleaks snapshot plus the committed allowlist.

Jump to

Keyboard shortcuts

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