baseline

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package baseline provides functionality to track and suppress known findings.

Index

Constants

View Source
const DefaultBaselineFile = ".gosecretscanner-baseline.json"

DefaultBaselineFile is the default baseline file name.

Variables

This section is empty.

Functions

func Fingerprint

func Fingerprint(filePath, ruleID, secretValue string) string

Fingerprint generates a unique identifier for a finding. The fingerprint is based on: file path, rule ID, and the secret value. Line numbers are NOT included since they drift as code changes.

func SecretHash

func SecretHash(secretValue string) string

SecretHash generates a hash of the secret value for verification.

Types

type Baseline

type Baseline struct {
	Version string  `json:"version"`
	Entries []Entry `json:"entries"`
	// contains filtered or unexported fields
}

Baseline holds all known/accepted findings.

func Load

func Load(path string) (*Baseline, error)

Load reads a baseline from the specified file. Returns an empty baseline if the file doesn't exist.

func New

func New() *Baseline

New creates an empty baseline.

func (*Baseline) Add

func (b *Baseline) Add(entry Entry)

Add adds a new entry to the baseline.

func (*Baseline) Contains

func (b *Baseline) Contains(fingerprint string) bool

Contains checks if a fingerprint is in the baseline.

func (*Baseline) Count

func (b *Baseline) Count() int

Count returns the number of entries in the baseline.

func (*Baseline) IsBaselined

func (b *Baseline) IsBaselined(filePath, ruleID, secretValue string) bool

IsBaselined checks if a finding (by path, rule, secret) is in the baseline.

func (*Baseline) Save

func (b *Baseline) Save(path string) error

Save writes the baseline to the specified file.

type Entry

type Entry struct {
	Fingerprint string `json:"fingerprint"`      // Unique identifier for this finding
	FilePath    string `json:"file"`             // Relative file path
	LineNumber  int    `json:"line"`             // Original line number (may drift)
	RuleID      string `json:"rule_id"`          // Rule that triggered this finding
	SecretHash  string `json:"secret_hash"`      // SHA256 of the secret value (for verification)
	Reason      string `json:"reason,omitempty"` // Why this was baselined (optional)
}

Entry represents a single finding in the baseline.

func CreateEntry

func CreateEntry(filePath string, lineNumber int, ruleID, secretValue, reason string) Entry

CreateEntry creates a baseline entry from finding details.

Jump to

Keyboard shortcuts

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