From 135aa8d9ea5750298374467085f4a5b31adebc3f Mon Sep 17 00:00:00 2001 From: eikendev Date: Sat, 13 Apr 2024 15:43:38 +0200 Subject: [PATCH] Add sectxtbin option to enable strict parsing --- sectxtbin/src/main.rs | 2 +- sectxtbin/src/settings.rs | 4 ++++ sectxtlib/src/securitytxt_options.rs | 9 +++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/sectxtbin/src/main.rs b/sectxtbin/src/main.rs index 52fda5b..582422a 100644 --- a/sectxtbin/src/main.rs +++ b/sectxtbin/src/main.rs @@ -65,7 +65,7 @@ async fn process_domains(s: &'static Settings) -> (u64, u64) { .build() .unwrap(); - let options: SecurityTxtOptions = Default::default(); + let options: SecurityTxtOptions = SecurityTxtOptions::new(s.strict); let statuses = stdin(s.threads) .map(|input| { diff --git a/sectxtbin/src/settings.rs b/sectxtbin/src/settings.rs index 7375212..834e897 100644 --- a/sectxtbin/src/settings.rs +++ b/sectxtbin/src/settings.rs @@ -11,6 +11,10 @@ pub struct Settings { #[argh(option, default = "3")] pub timeout: u64, + /// whether to be strict with line endings or more relaxed + #[argh(switch)] + pub strict: bool, + /// only print domains for which the run was successful #[argh(switch, short = 'q')] pub quiet: bool, diff --git a/sectxtlib/src/securitytxt_options.rs b/sectxtlib/src/securitytxt_options.rs index ce53d4b..0d06e7b 100644 --- a/sectxtlib/src/securitytxt_options.rs +++ b/sectxtlib/src/securitytxt_options.rs @@ -10,6 +10,15 @@ pub struct SecurityTxtOptions { pub strict: bool, } +impl SecurityTxtOptions { + pub fn new(strict: bool) -> Self { + Self { + now: Utc::now(), + strict: strict, + } + } +} + impl Default for SecurityTxtOptions { fn default() -> Self { Self {