1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//! **secretshape** — does this string look like a secret?
//!
//! A small library for detecting credential-*shaped* text: vendor token prefixes
//! (`ghp_`, `sk-ant-`, `AKIA…`), structural formats (JWTs, PEM blocks, DSNs with
//! embedded passwords) and, for the opaque rest, character-class + Shannon-entropy
//! heuristics. Built for clipboard managers, log scrubbers, LLM-prompt sanitizers
//! and CI checks — anywhere the question is "should this text be kept / shown /
//! sent?", not "is this repository clean?".
//!
//! # Two tiers, opposite error budgets
//!
//! | Tier | Cost | Deps | Errs toward | Use |
//! |------|------|------|-------------|-----|
//! | [`is_probably_secret`] | ~µs | none | **flagging** (a kept API key is worse than a forgotten hash) | drop/keep decisions |
//! | [`scan`] / [`redact`] (feature `rules`) | one regex pass | `regex` | **silence** (a finding pages a human) | reporting, redaction, dashboards |
//!
//! The tiers are calibrated against each other on purpose — don't expect them to
//! agree. The bool says "drop it" far more often than the rule engine says "alert".
//!
//! # Tier 1 — the dependency-free bool
//!
//! ```
//! // A clipboard manager deciding keep-or-drop:
//! assert!(secretshape::is_probably_secret("ghp_16C7e42F292c6912E7710c838347Ae178B4a"));
//! assert!(secretshape::is_probably_secret("Xk7pQm2Rv9Ls4Tz8Wn3Yb6Hd")); // opaque, high entropy
//!
//! // …without forgetting the things people copy all day:
//! assert!(!secretshape::is_probably_secret("https://github.com/klappstuhlpy/funke/releases/tag/v0.3.1"));
//! assert!(!secretshape::is_probably_secret("cargo clippy --workspace -- -D warnings"));
//! ```
//!
//! # Tier 2 — structured findings and redaction (feature `rules`, on by default)
//!
//! # What this cannot catch — honestly
//!
//! - **Short human passwords.** `Sommer2024!` is a word with a number on the end;
//! nothing about its shape distinguishes it from prose. If you manage passwords,
//! exclude them upstream (clipboard exclusion markers, vault hygiene) — shape
//! analysis will not save you.
//! - **Novel token formats.** A provider that launches tomorrow with an unprefixed
//! 32-char token is invisible to the rule tier until a rule lands (the entropy
//! heuristic may still catch it, at Tier-1 precision).
//! - **Secrets split across lines.** Both tiers judge the text they are given; a key
//! pasted as two halves is two innocent-looking strings.
//! - **Truth.** This crate judges *shape*, never validity — it does not (and will
//! not) call provider APIs to verify a match is live.
//!
//! # Features
//!
//! - `rules` *(default)* — the provider rule engine: [`scan`], [`Scanner`],
//! [`Finding`], [`Severity`], [`redact`]. Pulls in `regex`.
//! - `serde` — `Serialize`/`Deserialize` on [`Finding`] and [`Severity`].
//!
//! With `--no-default-features` the crate is dependency-free and exposes just
//! [`is_probably_secret`] — small enough for the hot path of a clipboard hook.
pub use is_probably_secret;
pub use ;
pub use ;
pub use ;