Documentation
¶
Overview ¶
Package triage provides lightweight security analysis of byte strings: Shannon entropy scoring, content classification (URL, email, IPv4/IPv6, domain, file path, hex, base64, UUID), and secret/credential detection (AWS keys, PEM private keys, GitHub/Slack/Stripe tokens, Google API keys, JWTs, and generic key=value assignments).
It depends only on the standard library, making it easy to embed in scanners, CI secret gates, log scrubbers, and forensics tooling. The entry point is Classify; Entropy is exposed separately for reuse.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Category ¶
type Category string
Category is a human-readable classification of a string's content.
const ( CategoryURL Category = "URL" CategoryEmail Category = "Email" CategoryIPv4 Category = "IPv4" CategoryIPv6 Category = "IPv6" CategoryUUID Category = "UUID" CategoryPathWindows Category = "WinPath" CategoryPathUnix Category = "UnixPath" CategoryDomain Category = "Domain" CategoryHex Category = "Hex" CategoryBase64 Category = "Base64" )
Classification categories.
type Result ¶
type Result struct {
// Entropy is the Shannon entropy (bits/byte) of the trimmed string.
Entropy float64
// HighEntropy is true when Entropy meets the configured threshold and the
// string looks like an opaque token rather than natural-language text.
HighEntropy bool
// Categories holds the content classification (at most one, first match
// wins by priority); empty when nothing matched.
Categories []Category
// Secrets holds any detected secrets/credentials.
Secrets []SecretFinding
}
Result holds the triage analysis of a single string.
func Classify ¶
Classify analyzes a string and returns its entropy, content category, and any detected secrets. minEntropy is the threshold (bits/byte) above which an opaque token is flagged as high-entropy; pass 0 to disable that flag.
func (Result) Interesting ¶
Interesting reports whether the result is worth surfacing in --secrets mode: it contains a detected secret or qualifies as a high-entropy blob.
type SecretFinding ¶
type SecretFinding struct {
Rule string `json:"rule"`
Severity Severity `json:"severity"`
Match string `json:"match"`
// Start and End are the byte offsets of the match within the scanned
// string: str[Start:End] == Match. End is exclusive. They make it possible
// to highlight or redact the exact span (see [Redact]).
Start int `json:"start"`
End int `json:"end"`
}
SecretFinding describes a single secret detected inside a string.