mod detection;
mod models;
mod patterns;
mod ruleset;
#[allow(unused_imports)] pub use detection::{get_technology_category, DetectedTechnology};
#[allow(unused_imports)] pub use models::{FingerprintMetadata, FingerprintRuleset, Technology};
#[allow(unused_imports)] pub use ruleset::init_ruleset;
pub(crate) use ruleset::ruleset_identity_summary;
pub(crate) use detection::{
detect_technologies_blocking, dns_records_haystack, is_challenge_interstitial,
supplement_technologies_with_dns_cert, supplement_technologies_with_script_text,
};
#[cfg(test)]
pub(crate) use ruleset::get_ruleset;
#[cfg(test)]
mod tests {
use super::*;
use crate::fingerprint::patterns::matches_pattern;
use reqwest::header::HeaderMap;
use std::collections::{HashMap, HashSet};
use std::sync::Arc;
#[tokio::test]
async fn test_pattern_matching() {
assert!(matches_pattern("nginx", "nginx/1.18.0").matched);
assert!(matches_pattern("", "anything").matched);
assert!(!matches_pattern("apache", "nginx/1.18.0").matched);
}
#[test]
fn test_detect_technologies_empty() {
let meta_tags = HashMap::new();
let script_sources = Vec::new();
let html_text = "";
let headers = HeaderMap::new();
let url = "https://example.com";
let script_tag_ids = HashSet::new();
let normalized_body = html_text.to_lowercase();
let ruleset = Arc::new(FingerprintRuleset::empty_for_tests());
let detected = detect_technologies_blocking(
&ruleset,
&headers,
&meta_tags,
&script_sources,
&normalized_body,
url,
&script_tag_ids,
"",
)
.expect("empty ruleset detection should succeed");
assert!(
detected.is_empty(),
"Empty input should return empty detection"
);
}
}