Skip to content

Commit 2044fed

Browse files
freeinternet865freeinternet865
andauthored
config: reject zero scan batch size (#23)
Validate scan_batch_size at config load time so scan-ips cannot reach candidate_ips.chunks(0) and panic. Add a focused regression test for scan_batch_size = 0. Co-authored-by: freeinternet865 <free@internet865.com>
1 parent 90749f3 commit 2044fed

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

src/config.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,11 @@ impl Config {
165165
));
166166
}
167167
}
168+
if self.scan_batch_size == 0 {
169+
return Err(ConfigError::Invalid(
170+
"scan_batch_size must be greater than 0".into(),
171+
));
172+
}
168173
Ok(())
169174
}
170175

@@ -227,6 +232,18 @@ mod tests {
227232
let cfg: Config = serde_json::from_str(s).unwrap();
228233
assert!(cfg.validate().is_err());
229234
}
235+
236+
#[test]
237+
fn rejects_zero_scan_batch_size() {
238+
let s = r#"{
239+
"mode": "apps_script",
240+
"auth_key": "SECRET",
241+
"script_id": "X",
242+
"scan_batch_size": 0
243+
}"#;
244+
let cfg: Config = serde_json::from_str(s).unwrap();
245+
assert!(cfg.validate().is_err());
246+
}
230247
}
231248

232249
#[cfg(test)]

0 commit comments

Comments
 (0)