-
Notifications
You must be signed in to change notification settings - Fork 648
fix: handle comma-separated ports in ports file #1616
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
When using -pf with a file containing comma-separated ports on a single line, the entire line was passed as one element to parsePortsSlice, causing parsing to fail. This fix splits each element by comma before processing.
WalkthroughThe Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Fix all issues with AI Agents 🤖
In @pkg/runner/ports.go:
- Around line 179-182: The single-port validation in the parsing logic
incorrectly allows port 0; update the check in the block where strconv.Atoi is
called (variable portNumber) to ensure ports are within 1–65535 (e.g., if err !=
nil || portNumber < 1 || portNumber > 65535) and return the same formatted error
when out of range so single ports are validated consistently with the range
handling.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
pkg/runner/ports.go
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: Lint
- GitHub Check: release-test-windows
- GitHub Check: release-test-mac
- GitHub Check: Functional Test (ubuntu-latest)
- GitHub Check: Analyze (go)
🔇 Additional comments (2)
pkg/runner/ports.go (2)
142-146: LGTM! Core fix for comma-separated port parsing.The nested split and trim logic correctly handles comma-separated ports within file lines, addressing the regression from issue #1615. Skipping empty segments gracefully handles edge cases like trailing commas.
148-152: Protocol detection logic is correct.Per-segment UDP detection via
u:prefix with TCP default is properly implemented.
Summary
-pfwith a file containing comma-separated ports on a single line, the entire line was passed as one element toparsePortsSlice, causing the errorinvalid port selection segmentTest plan
80,443,8080,22-25)naabu -host 127.0.0.1 -pf ports.txtSummary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.