Help us shape the future of Go! Take the 2026 Go Developer Survey

secrets

package
v1.6.0 Latest Latest
Warning

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

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

Documentation

Overview

Code generated by generate_rules.py. DO NOT EDIT.

Package secrets detects and redacts credential-like strings before output.

Index

Constants

This section is empty.

Variables

View Source
var CompiledRules = []Rule{}/* 221 elements not displayed */

Functions

This section is empty.

Types

type Detection

type Detection struct {
	RuleName string
	Match    string
}

Detection describes a single secret found in a file.

type Rule

type Rule struct {
	Name     string
	Keywords []string
	Regex    *regexp.Regexp
}

Rule is a named regex used to find secrets. When Keywords is non-empty, the regex is only evaluated if at least one keyword appears in the content.

type Scanner

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

Scanner scans content against the compiled gitleaks rules.

func New

func New() *Scanner

New returns a Scanner backed by the generated gitleaks rules.

func (*Scanner) RedactContent

func (s *Scanner) RedactContent(content []byte) ([]byte, []Detection)

RedactContent scans and sanitizes content for a single file. The keyword fast-path skips a rule's regex unless at least one of its keywords appears in the (case-folded) content. Content without detections (the common case) is returned untouched; the working copy is materialized only when the first rule matches.

func (*Scanner) RedactSelectedFiles

func (s *Scanner) RedactSelectedFiles(files []format.FileEntry) []format.FileEntry

RedactSelectedFiles runs secret scanning concurrently over the given files. Each worker sanitizes a disjoint slice of the returned copy, so no entry is ever mutated concurrently. SecretCount is set to the number of detections.

Jump to

Keyboard shortcuts

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