rules

package
v0.1.38 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: BSD-2-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultStopWords = []string{}/* 1477 elements not displayed */
View Source
var EmailDomainStopWords = []string{}
View Source
var UrlDomainStopWords = []string{

	"facebook.com",
	"youtube.com",
	"twitter.com",
	".x.com",

	"olx.com.br",
	"7games.bet",
	"www.google.com",
	"translate.google.com",
	"instagram.com",
	"www.godaddy.com",
	"tiktok.com",
	"www.paypal.com",
	"www.netflix.com",
	"www.roblox.com",
	"www.amazon.com",

	"yandex.ru",
}

Functions

This section is empty.

Types

type Rule

type Rule struct {
	// RuleID is a unique identifier for this rule
	RuleID string

	// Description is the description of the rule.
	Description string

	// Entropy is a float representing the minimum shannon
	// entropy a regex group must have to be considered a secret.
	Entropy float64

	// SecretGroup is an int used to extract secret from regex
	// match and used as the group that will have its entropy
	// checked if `entropy` is set.
	SecretGroup int

	// Regex is a golang regular expression used to detect secrets.
	Regex *regexp.Regexp

	// Path is a golang regular expression used to
	// filter secrets by path
	Path *regexp.Regexp

	// Tags is an array of strings used for metadata
	// and reporting purposes.
	Tags []string

	// Keywords are used for pre-regex check filtering. Rules that contain
	// keywords will perform a quick string compare check to make sure the
	// keyword(s) are in the content being scanned.
	Keywords []string

	CheckGlobalStopWord bool

	PostProcessor func(*models.Finding) (bool, error)
}

Rules contain information that define details on how to detect secrets

func Document added in v0.1.36

func Document() *Rule

Document extracts Brazilian CPF and CNPJ numbers, formatted or glued, into a single index distinguished by the is_cpf / is_cnpj flags.

Both documents carry check digits, so the regex only proposes candidates and the PostProcessor confirms them with the official checksum. That makes the validation extremely strong: random 11/14 digit runs almost never pass, so the false-positive rate is low even on the glued (unformatted) variants.

func Email

func Email() *Rule

func Leak1

func Leak1() *Rule

func Leak2

func Leak2() *Rule

func Leak3 added in v0.1.13

func Leak3() *Rule

func Phone added in v0.1.36

func Phone() *Rule

Phone extracts Brazilian and US phone numbers written in the many common formattings (with/without +55 or +1, with/without parenthesised area code, with spaces, dots or dashes, and the fully glued "no separator" variant).

The regex is intentionally only a candidate detector: it grabs phone-shaped spans and the PostProcessor performs the strict numbering-plan validation (real BR DDDs, NANP rules, subscriber length/leading-digit). The Secret that reaches the PostProcessor is re-parsed from its bare digits, so whatever the regex happened to capture into groups is irrelevant for classification.

func Url

func Url() *Rule

func (Rule) Validate

func (r Rule) Validate() error

Validate guards against common misconfigurations.

Jump to

Keyboard shortcuts

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