scan

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 4 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

Overview

Package scan finds likely secrets in transcripts before they move.

It uses a small set of strict rules (API keys, tokens, private keys) written for hopsesh, and can produce a redacted copy. Results are shown to the user in the plan; nothing is ever sent anywhere.

Index

Constants

This section is empty.

Variables

View Source
var Rules = []Rule{
	{"anthropic-api-key", regexp.MustCompile(`sk-ant-[A-Za-z0-9_\-]{20,}`)},
	{"openai-api-key", regexp.MustCompile(`sk-(?:proj|svcacct|admin)-[A-Za-z0-9_\-]{30,}|sk-[A-Za-z0-9]{20}T3BlbkFJ[A-Za-z0-9]{20}`)},
	{"github-token", regexp.MustCompile(`gh[pousr]_[A-Za-z0-9]{36,}|github_pat_[A-Za-z0-9_]{60,}`)},
	{"aws-access-key-id", regexp.MustCompile(`\b(?:AKIA|ASIA|ABIA|ACCA)[0-9A-Z]{16}\b`)},
	{"google-api-key", regexp.MustCompile(`AIza[0-9A-Za-z_\-]{35}`)},
	{"slack-token", regexp.MustCompile(`xox[baprs]-[0-9A-Za-z\-]{10,}`)},
	{"stripe-secret-key", regexp.MustCompile(`(?:sk|rk)_live_[0-9A-Za-z]{24,}`)},
	{"huggingface-token", regexp.MustCompile(`\bhf_[A-Za-z0-9]{34,}\b`)},
	{"private-key", regexp.MustCompile(`-----BEGIN (?:[A-Z]+ )*PRIVATE KEY-----`)},
	{"jwt", regexp.MustCompile(`\beyJ[A-Za-z0-9_\-]{10,}\.eyJ[A-Za-z0-9_\-]{10,}\.[A-Za-z0-9_\-]{10,}`)},
	{"bearer-token", regexp.MustCompile(`(?i)\bbearer\s+[A-Za-z0-9._~+/\-]{24,}=*`)},
}

Functions

func Redact

func Redact(raw []byte) ([]byte, int)

Redact replaces every match with [REDACTED:<rule>] and reports how many it replaced. It is meant as rewrite.Options.Redact, which only passes it rewritable string tokens.

Types

type Finding

type Finding struct {
	Rule    string `json:"rule"`
	Line    int    `json:"line"`
	Preview string `json:"preview"`
}

Finding is one likely secret. Preview never contains the secret itself.

type Rule

type Rule struct {
	ID string
	// contains filtered or unexported fields
}

Rule is one secret pattern. The patterns follow the high-confidence rules popularised by gitleaks (MIT); they are written independently here and kept deliberately strict to avoid flooding users with false positives.

type Summary

type Summary struct {
	Total  int            `json:"total"`
	ByRule map[string]int `json:"byRule"`
	// Findings is capped; Total is exact.
	Findings []Finding `json:"findings,omitempty"`
}

Summary counts findings by rule.

func Reader

func Reader(r io.Reader) (Summary, error)

Reader scans line-oriented content.

func (*Summary) Merge

func (s *Summary) Merge(o Summary)

Merge adds another summary into s.

func (Summary) RuleIDs

func (s Summary) RuleIDs() []string

RuleIDs returns the rule ids with findings, sorted.

Jump to

Keyboard shortcuts

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