fix: disclose Full-scan rate cap instead of clamping silently - #44
Merged
Conversation
A Full scan clamps masscan to full_scan_rate (10000 pps External, 1000 Internal) so a single 1-65535 sweep cannot exhaust firewall state tables. The clamp was silent, while main()'s run summary echoes the operator's requested max_rate — so requesting 5000 pps on an Internal Full scan printed "Max Packet Rate (pps): 5000" and then scanned at 1000, with the cap documented only in the config-help text an interactive run never shows. That reads as max_rate having been ignored outright. Print a notice when the clamp actually lowers the rate, naming both rates, why the cap exists, and that targeted scans use the full rate. Guarded on the comparison so a rate already under the cap stays quiet, and placed inside the scan_type == 'Full' branch so batched scans — which are deliberately uncapped — never mention it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Problem
A
Fullscan clamps masscan tofull_scan_rate— 10000 pps External, 1000 pps Internal — so that a single1-65535invocation cannot exhaust firewall state tables. That cap is correct and stays.The clamp was silent, while
main()'s run summary echoes the operator's requestedmax_rate. Requesting 5000 pps on an Internal Full scan printed:and then scanned at 1000. The summary actively contradicted what masscan was told to do, and the cap was documented only in the config-help text at
spoonmap.py:5060(Default = 2000 (full port scan capped at 1000)) — which an interactive run never displays. The observable behaviour is indistinguishable frommax_ratehaving been ignored outright, and it cost a real debugging session to track down.Change
Print a notice when the clamp actually lowers the rate, naming both rates and the reason:
Two placement details that are load-bearing:
int(full_scan_rate) < int(max_rate)— a rate already under the cap stays quiet rather than nagging on every run.scan_type == 'Full'branch, not next to thefull_scan_ratecomputation. That value is computed unconditionally atspoonmap.py:1610even for batched scans, so warning there would have told operators their rate was capped duringCategoryand custom scans — which are deliberately uncapped (spoonmap.py:1606-1607). That distinction is the actionable half of the message, so getting it wrong would have been worse than the original silence.It sits after the resume gate, so a resumed Full scan that skips masscan entirely does not claim to have capped a scan it never ran.
Tests
Three added to
TestFullPortScan, covering the notice, the under-cap silence, and the batched-scan silence.Verification
981 passed, 5 skipped— skips are the documented environmental ones (tcp/631 in use pertests/conftest.py, and the two root-gated-sUNSE cases)spoonmap.py(2342 stmts, 0 miss)ruff check spoonmap.py tests/cleanbanditclean against the committed.bandit-baseline.json— no new findings, no# nosecsuppressionsDocs
Added the Full-scan clamp to
CLAUDE.mdunder Firewall state table safety, including that it applies only toFulland why the notice exists. It previously appeared nowhere an operator or contributor would encounter it.🤖 Generated with Claude Code