use super::{ScanContext, ScanPhase};
use crate::protocols::intolerance::IntoleranceTester;
use crate::{Args, Result};
use async_trait::async_trait;
pub struct IntolerancePhase;
impl IntolerancePhase {
pub fn new() -> Self {
Self
}
}
impl Default for IntolerancePhase {
fn default() -> Self {
Self::new()
}
}
#[async_trait]
impl ScanPhase for IntolerancePhase {
fn name(&self) -> &'static str {
"Testing TLS Intolerance"
}
fn should_run(&self, args: &Args) -> bool {
args.scan.all
}
async fn execute(&self, context: &mut ScanContext) -> Result<()> {
let tester = IntoleranceTester::new(context.target());
let intolerance_results = tester.test_all().await?;
context.results.advanced_mut().intolerance = Some(intolerance_results);
Ok(())
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_intolerance_phase_should_run() {
let phase = IntolerancePhase::new();
let mut args = Args::default();
args.scan.all = true;
assert!(phase.should_run(&args));
let args = Args::default();
assert!(!phase.should_run(&args));
let mut args = Args::default();
args.target = Some("example.com".to_string());
assert!(!phase.should_run(&args));
}
#[test]
fn test_intolerance_phase_name() {
let phase = IntolerancePhase::new();
assert_eq!(phase.name(), "Testing TLS Intolerance");
}
}