use super::{ScanContext, ScanPhase};
use crate::protocols::client_cas::ClientCAsTester;
use crate::{Args, Result};
use async_trait::async_trait;
pub struct ClientCasPhase;
impl ClientCasPhase {
pub fn new() -> Self {
Self
}
}
impl Default for ClientCasPhase {
fn default() -> Self {
Self::new()
}
}
#[async_trait]
impl ScanPhase for ClientCasPhase {
fn name(&self) -> &'static str {
"Extracting Client CAs List"
}
fn should_run(&self, args: &Args) -> bool {
args.scan.show_client_cas
}
async fn execute(&self, context: &mut ScanContext) -> Result<()> {
let tester = ClientCAsTester::new(context.target());
let client_cas_results = tester.enumerate_client_cas().await?;
context.results.advanced_mut().client_cas = Some(client_cas_results);
Ok(())
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_client_cas_phase_should_run() {
let phase = ClientCasPhase::new();
let mut args = Args::default();
args.scan.show_client_cas = true;
assert!(phase.should_run(&args));
let args = Args::default();
assert!(!phase.should_run(&args));
let mut args = Args::default();
args.scan.all = true;
assert!(!phase.should_run(&args));
}
#[test]
fn test_client_cas_phase_name() {
let phase = ClientCasPhase::new();
assert_eq!(phase.name(), "Extracting Client CAs List");
}
}