Refactor port scanning and improve batch size handling#905
Open
0xreacher wants to merge 1 commit intobee-san:masterfrom
Open
Refactor port scanning and improve batch size handling#9050xreacher wants to merge 1 commit intobee-san:masterfrom
0xreacher wants to merge 1 commit intobee-san:masterfrom
Conversation
Refactor port scanning logic to improve performance and fix bugs related to batch size and ulimit handling. Update warnings and logging for better clarity.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #1 - Wrong batch size in warning message (opts.batch_size → batch_size): The warning was showing the raw CLI value, not the actual adjusted value that ran. Users would try lowering a number that wasn't what the scanner used.
Fix #2 - or_insert_with(Vec::new) -> or_default(): Idiomatic Rust, clippy::pedantic flags the old form. Functionally identical but cleaner.
Fix #3 - scripts_to_run.clone() moved out of loop: Was cloning the entire Vec once per IP. Now iterates by reference (for script_f in &scripts_to_run) and only clones the individual ScriptFile when mutation is actually needed. Zero behavior change, much better perf at scale.
Fix #4 - Removed redundant debug!("Call format {call_f}"): The output! macro right above it already logs the full call format string. Duplicate log at a different level adds noise.
Fix #5 - usize::MAX fallback → DEFAULT_FILE_DESCRIPTORS_LIMIT: The most dangerous one. If try_into() ever failed, the returned usize::MAX would make infer_batch_size think the system has infinite file descriptors and skip all safety adjustments potentially crashing with a massive batch size. Now falls back to the same conservative 8000 limit the rest of the code uses.