pub struct Allowlist {
pub credential_hashes: HashSet<CredentialHash>,
pub ignored_detectors: HashSet<String>,
pub ignored_paths: ObservedPaths,
/* private fields */
}Expand description
User-defined suppressions loaded from .keyhogignore: credential hashes, detector IDs, and path globs.
§Examples
use keyhog_core::Allowlist;
let path = std::env::temp_dir().join(format!(
"keyhog_allowlist_struct_{}.keyhogignore",
std::process::id()
));
std::fs::write(&path, "detector:demo-token\npath:**/*.md\n")?;
let allowlist = Allowlist::load_with_metadata_policy(&path, false, false, None)?;
std::fs::remove_file(&path)?;
assert!(allowlist.ignored_detectors.contains("demo-token"));Fields§
§credential_hashes: HashSet<CredentialHash>SHA-256 hashes of credentials to ignore.
ignored_detectors: HashSet<String>Detector IDs to ignore entirely.
ignored_paths: ObservedPathsGlob patterns for paths to ignore (raw, as authored). Kept as the public
Vec-compatible contract + serialized form; the matcher consumes the
precompiled [PathGlobIndex] built from these in Allowlist::parse.
Implementations§
Source§impl Allowlist
impl Allowlist
Sourcepub fn load_with_metadata_policy(
path: &Path,
require_reason: bool,
require_approved_by: bool,
max_expires_days: Option<u64>,
) -> Result<Self, Error>
pub fn load_with_metadata_policy( path: &Path, require_reason: bool, require_approved_by: bool, max_expires_days: Option<u64>, ) -> Result<Self, Error>
Load from a .keyhogignore file and enforce metadata governance.
Sourcepub fn is_path_ignored(&self, path: &str) -> bool
pub fn is_path_ignored(&self, path: &str) -> bool
Check whether a raw path matches an ignored-path glob.
§Examples
use keyhog_core::Allowlist;
let path = std::env::temp_dir().join(format!(
"keyhog_allowlist_path_{}.keyhogignore",
std::process::id()
));
std::fs::write(&path, "path:**/*.md\n")?;
let allowlist = Allowlist::load_with_metadata_policy(&path, false, false, None)?;
std::fs::remove_file(&path)?;
assert!(allowlist.is_path_ignored("docs/README.md"));Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Allowlist
impl RefUnwindSafe for Allowlist
impl Send for Allowlist
impl Sync for Allowlist
impl Unpin for Allowlist
impl UnsafeUnpin for Allowlist
impl UnwindSafe for Allowlist
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more