pub struct EnvExpansionRule { /* private fields */ }Expand description
Rejects input containing environment variable expansion patterns.
Detects:
$NAME(simple variable reference)${NAME}(braced variable reference)%NAME%(Windows-style variable reference)
§Intentionally allowed patterns
The following patterns are not flagged:
- Positional parameters (
$1,$2, …) — These start with a digit and are not environment variable names. They are common in pricing text (e.g."$5 off") and typically cannot leak secrets. - Lone
$at end of input — Not a valid expansion.
If your use case requires blocking positional parameters as well,
combine this rule with ShellMetaRule, which
rejects the $ character itself.
§Rationale
Environment variable expansion can leak secrets or alter behavior:
$HOME/.ssh/id_rsa → leaks home directory
${SECRET_KEY} → leaks credentials
%USERPROFILE% → Windows equivalentImplementations§
Source§impl EnvExpansionRule
impl EnvExpansionRule
Sourcepub fn posix_only() -> Self
pub fn posix_only() -> Self
Create a POSIX-only rule (skip %VAR% detection).
Trait Implementations§
Source§impl Default for EnvExpansionRule
impl Default for EnvExpansionRule
Auto Trait Implementations§
impl Freeze for EnvExpansionRule
impl RefUnwindSafe for EnvExpansionRule
impl Send for EnvExpansionRule
impl Sync for EnvExpansionRule
impl Unpin for EnvExpansionRule
impl UnsafeUnpin for EnvExpansionRule
impl UnwindSafe for EnvExpansionRule
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