[][src]Struct rusty_hogs::SecretScannerBuilder

pub struct SecretScannerBuilder {
    pub case_insensitive: bool,
    pub regex_json_str: Option<String>,
    pub regex_json_path: Option<String>,
    pub pretty_print: bool,
    pub output_path: Option<String>,
}

Used to instantiate the SecretScanner object with user-supplied options

Use the new() function to create a builder object, perform configurations as needed, then create the SecretScanner object with .build(). Each configuration method consumes and returns self so that you can chain them.

Examples

With no configuration you will inherit the default rules that are case sensitive...

use rusty_hogs::{SecretScannerBuilder, SecretScanner};
let ssb: SecretScannerBuilder = SecretScannerBuilder::new();
let ss: SecretScanner = ssb.build();
assert_ne!(ss.regex_map.len(), 0);

Alternatively, you can supply your own regular expression JSON, and set a global case-insensitive flag...

use rusty_hogs::{SecretScannerBuilder, SecretScanner};
let regex_string = r##"{ "Phone number" : "\\d{3}-?\\d{3}-\\d{4}" }"##;
let ssb: SecretScannerBuilder = SecretScannerBuilder::new()
    .set_json_str(regex_string)
    .global_case_insensitive(true);
assert!(ssb.case_insensitive);
let ss: SecretScanner = ssb.build();
assert_eq!(ss.regex_map.len(), 1);

Fields

case_insensitive: boolregex_json_str: Option<String>regex_json_path: Option<String>pretty_print: booloutput_path: Option<String>

Methods

impl SecretScannerBuilder[src]

pub fn new() -> Self[src]

Create a new SecretScannerBuilder object with the default config (50 rules, case sensitive)

pub fn conf_argm(self, arg_matches: &ArgMatches) -> Self[src]

Configure multiple values using the clap library's ArgMatches object. This function looks for a "CASE" flag and "REGEX" value.

pub fn set_json_path(self, json_path: &str) -> Self[src]

Supply a path to a JSON file on the system that contains regular expressions

pub fn set_json_str(self, json_str: &str) -> Self[src]

Supply a string containing a JSON object that contains regular expressions

pub fn global_case_insensitive(self, case_insensitive: bool) -> Self[src]

Force all regular expressions to be case-insensitive, overriding any flags in the regex

pub fn set_pretty_print(self, pretty_print: bool) -> Self[src]

Set output format to pretty printed JSON

pub fn set_output_path(self, output_path: &str) -> Self[src]

Set output path (stdout if set to None)

pub fn build(&self) -> SecretScanner[src]

Returns the configured SecretScanner object used to perform regex scanning

Trait Implementations

impl Clone for SecretScannerBuilder[src]

impl Debug for SecretScannerBuilder[src]

impl Default for SecretScannerBuilder[src]

impl Eq for SecretScannerBuilder[src]

impl Hash for SecretScannerBuilder[src]

impl PartialEq<SecretScannerBuilder> for SecretScannerBuilder[src]

impl StructuralEq for SecretScannerBuilder[src]

impl StructuralPartialEq for SecretScannerBuilder[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Err = <U as TryFrom<T>>::Err

impl<T> Typeable for T where
    T: Any