pub(crate) use crate::suppression::{
contains_uuid_v4_substring, looks_like_email_address,
looks_like_punctuation_decorated_identifier, looks_like_pure_identifier,
looks_like_regex_literal_tail, looks_like_scheme_prefixed_uri, looks_like_url_or_path_segment,
looks_like_vendored_minified_path, looks_like_word_separated_identifier,
};
#[cfg(feature = "simdsieve")]
pub(crate) use crate::suppression::looks_like_secret_scanner_source;
pub use crate::suppression::{
detector_weak_anchor, should_suppress_known_example_credential,
should_suppress_known_example_credential_with_source, should_suppress_named_detector_finding,
should_suppress_named_detector_finding_weak,
};
use crate::types::*;
use keyhog_core::{Chunk, MatchLocation, RawMatch};
use std::collections::HashMap;
use std::sync::Arc;
#[allow(clippy::too_many_arguments)]
pub fn build_raw_match(
detector: &keyhog_core::DetectorSpec,
metadata: (Arc<str>, Arc<str>, Arc<str>),
chunk: &Chunk,
credential: &str,
companions: HashMap<String, String>,
offset: usize,
line: usize,
ent: f64,
confidence: f64,
scan_state: &mut ScanState,
pattern_client_safe: bool,
) -> RawMatch {
let (detector_id, detector_name, service) = metadata;
let severity = if pattern_client_safe {
keyhog_core::Severity::ClientSafe
} else if chunk.metadata.source_type == "git/history" {
detector.severity.downgrade_one()
} else {
detector.severity
};
RawMatch {
detector_id,
detector_name,
service,
severity,
credential_hash: crate::sha256_hash(credential),
credential: scan_state.intern_credential(credential),
companions,
location: MatchLocation {
source: scan_state.intern_metadata(&chunk.metadata.source_type),
file_path: chunk
.metadata
.path
.as_ref()
.map(|p| scan_state.intern_metadata(p)),
line: Some(line + chunk.metadata.base_line),
offset: offset + chunk.metadata.base_offset,
commit: chunk
.metadata
.commit
.as_ref()
.map(|c| scan_state.intern_metadata(c)),
author: chunk
.metadata
.author
.as_ref()
.map(|a| scan_state.intern_metadata(a)),
date: chunk
.metadata
.date
.as_ref()
.map(|d| scan_state.intern_metadata(d)),
},
entropy: Some(ent),
confidence: Some(confidence),
}
}