use crate::runner::DalfoxRunner;
#[derive(Debug, Clone, Default)]
pub struct DalfoxBuilder {
pub(crate) custom_headers: Vec<String>,
pub(crate) payloads: Vec<String>,
pub(crate) cookie: Option<String>,
pub(crate) cookie_from_raw: Option<String>,
pub(crate) user_agent: Option<String>,
pub(crate) proxy: Option<String>,
pub(crate) request_timeout_secs: Option<u64>,
pub(crate) scan_deadline_secs: Option<u64>,
pub(crate) delay_ms: Option<u64>,
pub(crate) workers: Option<u32>,
#[allow(dead_code)]
pub(crate) use_headless: bool,
#[allow(dead_code)]
pub(crate) deep_domxss: bool,
#[allow(dead_code)]
pub(crate) skip_headless: bool,
#[allow(dead_code)]
pub(crate) skip_bav: bool,
pub(crate) skip_mining_all: bool,
pub(crate) skip_mining_dom: bool,
pub(crate) skip_mining_dict: bool,
pub(crate) only_discovery: bool,
pub(crate) only_custom_payload: bool,
pub(crate) follow_redirects: bool,
pub(crate) waf_evasion: bool,
pub(crate) debug_mode: bool,
pub(crate) silence: bool,
pub(crate) params: Vec<String>,
pub(crate) mining_dict: Option<String>,
pub(crate) method: Option<String>,
pub(crate) data: Option<String>,
pub(crate) ignore_return_codes: Option<String>,
pub(crate) blind_callback: Option<String>,
pub(crate) remote_payloads: Option<String>,
pub(crate) remote_wordlists: Option<String>,
pub(crate) custom_alert_value: Option<String>,
pub(crate) only_poc: Option<String>,
pub(crate) poc_type: Option<String>,
#[allow(dead_code)]
pub(crate) found_action: Option<String>,
pub(crate) output_file: Option<String>,
#[allow(dead_code)]
pub(crate) output_all: bool,
pub(crate) binary_path: Option<String>,
}
impl DalfoxBuilder {
pub fn new() -> Self {
Self::default()
}
pub fn cookie(mut self, cookie: impl Into<String>) -> Self {
self.cookie = Some(cookie.into());
self
}
pub fn cookie_from_raw(mut self, file_path: impl Into<String>) -> Self {
self.cookie_from_raw = Some(file_path.into());
self
}
pub fn user_agent(mut self, user_agent: impl Into<String>) -> Self {
self.user_agent = Some(user_agent.into());
self
}
pub fn proxy(mut self, proxy_url: impl Into<String>) -> Self {
self.proxy = Some(proxy_url.into());
self
}
pub fn request_timeout(mut self, seconds: u64) -> Self {
self.request_timeout_secs = Some(seconds);
self
}
pub fn scan_deadline(mut self, seconds: u64) -> Self {
self.scan_deadline_secs = Some(seconds);
self
}
pub fn timeout(mut self, seconds: u64) -> Self {
self.request_timeout_secs = Some(seconds);
self.scan_deadline_secs = Some(seconds);
self
}
pub fn delay(mut self, milliseconds: u64) -> Self {
self.delay_ms = Some(milliseconds);
self
}
pub fn workers(mut self, count: u32) -> Self {
self.workers = Some(count);
self
}
#[deprecated(
since = "0.3.0",
note = "Dalfox v3 removed --use-headless; this builder method is a no-op"
)]
pub fn headless(mut self, enable: bool) -> Self {
self.use_headless = enable;
self
}
#[deprecated(
since = "0.3.0",
note = "Dalfox v3 removed --deep-domxss; this builder method is a no-op"
)]
pub fn deep_domxss(mut self, enable: bool) -> Self {
self.deep_domxss = enable;
self
}
#[deprecated(
since = "0.3.0",
note = "Dalfox v3 removed --skip-headless; this builder method is a no-op"
)]
pub fn skip_headless(mut self, skip: bool) -> Self {
self.skip_headless = skip;
self
}
#[deprecated(
since = "0.3.0",
note = "Dalfox v3 removed --skip-bav; this builder method is a no-op"
)]
pub fn skip_bav(mut self, skip: bool) -> Self {
self.skip_bav = skip;
self
}
pub fn skip_mining_all(mut self, skip: bool) -> Self {
self.skip_mining_all = skip;
self
}
pub fn skip_mining_dom(mut self, skip: bool) -> Self {
self.skip_mining_dom = skip;
self
}
pub fn skip_mining_dict(mut self, skip: bool) -> Self {
self.skip_mining_dict = skip;
self
}
pub fn only_discovery(mut self, enable: bool) -> Self {
self.only_discovery = enable;
self
}
pub fn only_custom_payload(mut self, enable: bool) -> Self {
self.only_custom_payload = enable;
self
}
pub fn follow_redirects(mut self, enable: bool) -> Self {
self.follow_redirects = enable;
self
}
pub fn waf_evasion(mut self, enable: bool) -> Self {
self.waf_evasion = enable;
self
}
pub fn debug(mut self, enable: bool) -> Self {
self.debug_mode = enable;
self
}
pub fn silence(mut self, enable: bool) -> Self {
self.silence = enable;
self
}
pub fn param(mut self, params: impl Into<String>) -> Self {
for name in params.into().split(',') {
let trimmed = name.trim();
if !trimmed.is_empty() {
self.params.push(trimmed.to_string());
}
}
self
}
pub fn mining_dict(mut self, path: impl Into<String>) -> Self {
self.mining_dict = Some(path.into());
self
}
pub fn method(mut self, method: impl Into<String>) -> Self {
self.method = Some(method.into());
self
}
pub fn data(mut self, body: impl Into<String>) -> Self {
self.data = Some(body.into());
self
}
pub fn ignore_return(mut self, codes: impl Into<String>) -> Self {
self.ignore_return_codes = Some(codes.into());
self
}
pub fn payload(mut self, file_path: impl Into<String>) -> Self {
self.payloads.push(file_path.into());
self
}
pub fn header(mut self, header: impl Into<String>) -> Self {
self.custom_headers.push(header.into());
self
}
pub fn blind_callback(mut self, url: impl Into<String>) -> Self {
self.blind_callback = Some(url.into());
self
}
pub fn remote_payloads(mut self, source: impl Into<String>) -> Self {
self.remote_payloads = Some(source.into());
self
}
pub fn remote_wordlists(mut self, source: impl Into<String>) -> Self {
self.remote_wordlists = Some(source.into());
self
}
pub fn custom_alert_value(mut self, value: impl Into<String>) -> Self {
self.custom_alert_value = Some(value.into());
self
}
pub fn only_poc(mut self, filter: impl Into<String>) -> Self {
self.only_poc = Some(filter.into());
self
}
pub fn poc_type(mut self, poc_type: impl Into<String>) -> Self {
self.poc_type = Some(poc_type.into());
self
}
#[deprecated(
since = "0.3.0",
note = "Dalfox v3 removed --found-action; this builder method is a no-op"
)]
pub fn found_action(mut self, command: impl Into<String>) -> Self {
self.found_action = Some(command.into());
self
}
pub fn output_file(mut self, path: impl Into<String>) -> Self {
self.output_file = Some(path.into());
self
}
#[deprecated(
since = "0.3.0",
note = "Dalfox v3 removed --output-all; this builder method is a no-op"
)]
pub fn output_all(mut self, enable: bool) -> Self {
self.output_all = enable;
self
}
pub fn binary_path(mut self, path: impl Into<String>) -> Self {
self.binary_path = Some(path.into());
self
}
pub fn build(self) -> DalfoxRunner {
DalfoxRunner::new(self)
}
}