policycontent

package
v0.175.0-rc.310 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: Apache-2.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TokenRules = []TokenRule{
	rule("github-pat", `\bghp_[0-9A-Za-z]{36}\b`, "ghp_"),
	rule("github-oauth", `\bgho_[0-9A-Za-z]{36}\b`, "gho_"),
	rule("github-app-token", `\b(?:ghu|ghs)_[0-9A-Za-z]{36}\b`, "ghu_", "ghs_"),
	rule("github-refresh-token", `\bghr_[0-9A-Za-z]{36}\b`, "ghr_"),
	rule("github-fine-grained-pat", `\bgithub_pat_[0-9A-Za-z_]{82}\b`, "github_pat_"),
	rule("gitlab-pat", `\bglpat-[0-9A-Za-z_-]{20}\b`, "glpat-"),
	rule("aws-access-token", `\b(?:A3T[A-Z0-9]|AKIA|ASIA|ABIA|ACCA)[A-Z2-7]{16}\b`, "A3T", "AKIA", "ASIA", "ABIA", "ACCA"),
	rule("gcp-api-key", `\bAIza[0-9A-Za-z_-]{35}\b`, "AIza"),
	rule("slack-token", `\bxox[abposr]-[0-9A-Za-z-]{10,}`, "xox"),
	rule("slack-webhook-url", `hooks\.slack\.com/(?:services|workflows|triggers)/[0-9A-Za-z+/_-]{20,}`, "hooks.slack.com"),
	rule("anthropic-api-key", `\bsk-ant-[a-z]+\d{2}-[0-9A-Za-z_-]{80,}`, "sk-ant-"),
	rule("openai-api-key", `\bsk-(?:proj|svcacct|admin)-[0-9A-Za-z_-]{20,}`, "sk-proj-", "sk-svcacct-", "sk-admin-"),
	rule("npm-access-token", `\bnpm_[0-9A-Za-z]{36}\b`, "npm_"),
	rule("1password-service-account-token", `\bops_eyJ[0-9A-Za-z+/=_-]{50,}`, "ops_eyJ"),
	rule("age-secret-key", `AGE-SECRET-KEY-1[0-9A-Z]{58}`, "AGE-SECRET-KEY-1"),
	rule("private-key", `-----BEGIN[ A-Z0-9_-]{0,100}PRIVATE KEY(?: BLOCK)?-----`, "PRIVATE KEY"),
	rule("jwt", `\beyJ[0-9A-Za-z_-]{10,}\.eyJ[0-9A-Za-z_-]{10,}\.[0-9A-Za-z_-]{10,}`, "eyJ"),

	rule("url-credentials", `\b[a-z][a-z0-9+.-]*://[^\s/:@'"]+:[^\s/@'"$<{%*][^\s/@'"]*@[0-9A-Za-z]`, "://"),
}

Functions

func CredentialShapes

func CredentialShapes(text string) []string

CredentialShapes are the ids of the token rules text matches, once each: the shapes of a credential (a private key, a token's prefix), none for a public value. A gitleaks:allow marker exempts nothing here.

func RulesAllowed

func RulesAllowed(p string, extra []string) bool

RulesAllowed rejects credential store names and excluded source trees.

Types

type TokenRule

type TokenRule struct {
	ID       string
	Keywords []string
	RE       *regexp.Regexp
}

TokenRule is a gitleaks rule: its id, the keywords one of which a match contains (a cheap prefilter), and the pattern.

Jump to

Keyboard shortcuts

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