aboutsummaryrefslogtreecommitdiffstats
path: root/crates/atuin-client/src/secrets.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/atuin-client/src/secrets.rs')
-rw-r--r--crates/atuin-client/src/secrets.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/crates/atuin-client/src/secrets.rs b/crates/atuin-client/src/secrets.rs
index c3053b79..e249910d 100644
--- a/crates/atuin-client/src/secrets.rs
+++ b/crates/atuin-client/src/secrets.rs
@@ -1,11 +1,14 @@
// This file will probably trigger a lot of scanners. Sorry.
+use regex::RegexSet;
+use std::sync::LazyLock;
+
pub enum TestValue<'a> {
Single(&'a str),
Multiple(&'a [&'a str]),
}
-// A list of (name, regex, test), where test should match against regex
+/// A list of `(name, regex, test)`, where `test` should match against `regex`.
pub static SECRET_PATTERNS: &[(&str, &str, TestValue)] = &[
(
"AWS Access Key ID",
@@ -114,6 +117,12 @@ pub static SECRET_PATTERNS: &[(&str, &str, TestValue)] = &[
),
];
+/// The `regex` expressions from [`SECRET_PATTERNS`] compiled into a `RegexSet`.
+pub static SECRET_PATTERNS_RE: LazyLock<RegexSet> = LazyLock::new(|| {
+ let exprs = SECRET_PATTERNS.iter().map(|f| f.1);
+ RegexSet::new(exprs).expect("Failed to build secrets regex")
+});
+
#[cfg(test)]
mod tests {
use regex::Regex;