pub struct AutoDetectPatterns;Expand description
Auto-detection patterns for identifying sensitive environment variables.
This utility helps determine which environment variables should be encrypted based on their names. It uses common patterns to identify secrets like tokens, passwords, and API keys.
§Examples
use dotenvage::AutoDetectPatterns;
assert!(AutoDetectPatterns::should_encrypt("API_TOKEN"));
assert!(AutoDetectPatterns::should_encrypt("DATABASE_PASSWORD"));
assert!(!AutoDetectPatterns::should_encrypt("PORT"));
assert!(!AutoDetectPatterns::should_encrypt("AWS_REGION"));Implementations§
Source§impl AutoDetectPatterns
impl AutoDetectPatterns
Sourcepub const ENCRYPT_PATTERNS: &'static [&'static str]
pub const ENCRYPT_PATTERNS: &'static [&'static str]
Patterns indicating a variable should be encrypted.
Variables containing any of these substrings (case-insensitive) will be
automatically encrypted unless they match a pattern in
NEVER_ENCRYPT.
Sourcepub const NEVER_ENCRYPT: &'static [&'static str]
pub const NEVER_ENCRYPT: &'static [&'static str]
Variables that should never be encrypted.
These are typically configuration values that need to be plaintext for readability or compatibility reasons.
Sourcepub fn should_encrypt(key: &str) -> bool
pub fn should_encrypt(key: &str) -> bool
Returns true if an environment variable name should be encrypted.
This checks the variable name against
ENCRYPT_PATTERNS
and NEVER_ENCRYPT lists.
§Examples
use dotenvage::AutoDetectPatterns;
assert!(AutoDetectPatterns::should_encrypt("STRIPE_API_KEY"));
assert!(AutoDetectPatterns::should_encrypt("github_token"));
assert!(!AutoDetectPatterns::should_encrypt("DATABASE_NAME"));Auto Trait Implementations§
impl Freeze for AutoDetectPatterns
impl RefUnwindSafe for AutoDetectPatterns
impl Send for AutoDetectPatterns
impl Sync for AutoDetectPatterns
impl Unpin for AutoDetectPatterns
impl UnwindSafe for AutoDetectPatterns
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more