pub struct Allowlist {
pub credential_hashes: HashSet<CredentialHash>,
pub ignored_detectors: HashSet<String>,
pub ignored_paths: ObservedPaths,
pub rules: Vec<AllowlistRule>,
/* private fields */
}Expand description
Parsed .keyhogignore rules with compiled lookup structures and attribution.
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.
rules: Vec<AllowlistRule>Parsed suppression rules with match attribution tracking.
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 parse(content: &str) -> Self
pub fn parse(content: &str) -> Self
Parse allowlist from string content.
§Examples
use keyhog_core::Allowlist;
let path = std::env::temp_dir().join(format!(
"keyhog_allowlist_parse_{}.keyhogignore",
std::process::id()
));
std::fs::write(&path, "path:**/.env\ndetector:demo-token\n")?;
let allowlist = Allowlist::load_with_metadata_policy(&path, false, false, None)?;
std::fs::remove_file(&path)?;
assert!(allowlist.is_path_ignored("app/.env"));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"));Sourcepub fn record_match(&self, finding: &VerifiedFinding) -> bool
pub fn record_match(&self, finding: &VerifiedFinding) -> bool
Record a match against allowlist rules for a verified finding.
Sourcepub fn record_path_match(&self, path: &str) -> bool
pub fn record_path_match(&self, path: &str) -> bool
Record a match on an ignored path.
Sourcepub fn record_detector_match(&self, detector_id: &str) -> bool
pub fn record_detector_match(&self, detector_id: &str) -> bool
Record a match on an ignored detector.
Sourcepub fn record_hash_match(&self, hash: &CredentialHash) -> bool
pub fn record_hash_match(&self, hash: &CredentialHash) -> bool
Record a match on an ignored credential hash.
Sourcepub fn unused_entries(&self) -> Vec<UnusedAllowlistEntry>
pub fn unused_entries(&self) -> Vec<UnusedAllowlistEntry>
Retrieve all allowlist entries that matched zero times during the scan.
Sourcepub fn attributed_match_counts(&self) -> Vec<(String, usize)>
pub fn attributed_match_counts(&self) -> Vec<(String, usize)>
Retrieve match attribution for every registered allowlist entry.
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
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> ⓘ
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> ⓘ
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