use super::*;
use fuzzyhash::FuzzyHash;
#[derive(Default, Debug, PartialEq)]
pub struct SimilarityFilter {
pub text: String,
pub threshold: u32,
}
impl FeroxFilter for SimilarityFilter {
fn should_filter_response(&self, response: &FeroxResponse) -> bool {
let other = FuzzyHash::new(&response.text);
if let Ok(result) = FuzzyHash::compare(&self.text, &other.to_string()) {
return result >= self.threshold;
}
log::warn!("Could not hash body from {}", response.as_str());
false
}
fn box_eq(&self, other: &dyn Any) -> bool {
other.downcast_ref::<Self>().map_or(false, |a| self == a)
}
fn as_any(&self) -> &dyn Any {
self
}
}