pub struct UserPathRecognizer;Expand description
Recognizes home-directory paths that expose system usernames.
§Examples
use cloakrs_core::{EntityType, Recognizer};
use cloakrs_patterns::UserPathRecognizer;
let findings = UserPathRecognizer.scan("open /home/kadir/.ssh/id_rsa");
assert_eq!(findings[0].entity_type, EntityType::UserPath);
assert_eq!(UserPathRecognizer::extract_username("/home/kadir/.ssh/id_rsa").as_deref(), Some("kadir"));Implementations§
Source§impl UserPathRecognizer
impl UserPathRecognizer
Sourcepub fn extract_username(path: &str) -> Option<String>
pub fn extract_username(path: &str) -> Option<String>
Extracts the username segment from a supported home-directory path.
§Examples
use cloakrs_patterns::UserPathRecognizer;
assert_eq!(UserPathRecognizer::extract_username("/Users/john/Documents").as_deref(), Some("john"));
assert_eq!(UserPathRecognizer::extract_username(r"C:\Users\john.doe\Desktop").as_deref(), Some("john.doe"));Trait Implementations§
Source§impl Clone for UserPathRecognizer
impl Clone for UserPathRecognizer
Source§fn clone(&self) -> UserPathRecognizer
fn clone(&self) -> UserPathRecognizer
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for UserPathRecognizer
impl Debug for UserPathRecognizer
Source§impl Default for UserPathRecognizer
impl Default for UserPathRecognizer
Source§fn default() -> UserPathRecognizer
fn default() -> UserPathRecognizer
Returns the “default value” for a type. Read more
Source§impl Recognizer for UserPathRecognizer
impl Recognizer for UserPathRecognizer
Source§fn entity_type(&self) -> EntityType
fn entity_type(&self) -> EntityType
The entity type this recognizer detects.
Source§fn supported_locales(&self) -> &[Locale]
fn supported_locales(&self) -> &[Locale]
Locales this recognizer applies to. Empty means universal.
impl Copy for UserPathRecognizer
Auto Trait Implementations§
impl Freeze for UserPathRecognizer
impl RefUnwindSafe for UserPathRecognizer
impl Send for UserPathRecognizer
impl Sync for UserPathRecognizer
impl Unpin for UserPathRecognizer
impl UnsafeUnpin for UserPathRecognizer
impl UnwindSafe for UserPathRecognizer
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