-
Notifications
You must be signed in to change notification settings - Fork 993
HTTP|HTTPS Port priority optimization #2298
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
Conversation
WalkthroughA new file Changes
Sequence DiagramsequenceDiagram
participant A as Runner.analyze
participant P as Port Optimization
participant R as Request Builder
A->>A: protocol is HTTPorHTTPS/HTTPandHTTPS?
rect rgb(240, 248, 255)
Note over A,P: Old behavior
A->>R: scheme = HTTPS (forced)
end
rect rgb(230, 245, 230)
Note over A,P: New behavior
A->>P: determineMostLikelySchemeOrder(target.Host)
P->>P: Extract port from host
P->>P: Check against common HTTP ports
P-->>A: Return HTTP or HTTPS
A->>R: scheme = determined value
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes The change introduces straightforward port-based scheme detection with limited logic paths. One new file adds a single utility function, and the modification in Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 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: 0
🧹 Nitpick comments (2)
runner/ports_optimization.go (2)
11-14: Expand the common HTTP ports list.The current list only includes ports 80 and 8080, but many other ports commonly serve HTTP traffic. Consider adding well-known HTTP ports such as 8000, 8008, 8888, 3000, 5000, 9090, etc.
Apply this diff to expand the list:
var commonHttpPorts = []string{ "80", "8080", + "8000", + "8008", + "8888", + "3000", + "5000", + "9090", }
17-33: Consider refining the function name and port > 1024 heuristic.Two observations:
The function name
determineMostLikelySchemeOrdersuggests it returns an ordering, but it actually returns a single scheme. Consider renaming todetermineMostLikelySchemefor clarity.The heuristic that ports > 1024 are "more likely to expose HTTP" is a broad generalization. While it may be statistically true based on Shodan data, it could produce false positives for services like development servers on high ports that use HTTPS. The existing retry logic in
runner.go(lines 1748-1756) will recover from incorrect guesses, but being more conservative here (e.g., defaulting to HTTPS for unknown ports) might reduce unnecessary retries.Optional refinement to be more conservative:
-// determineMostLikelySchemeOrder for the input -func determineMostLikelySchemeOrder(input string) string { +// determineMostLikelyScheme for the input +func determineMostLikelyScheme(input string) string { if _, port, err := net.SplitHostPort(input); err == nil { // if input has port that is commonly used for HTTP, return http then https if sliceutil.Contains(commonHttpPorts, port) { return httpx.HTTP } - // As of 10/2025 shodan shows that ports > 1024 are more likely to expose HTTP - // hence we test first http then https on higher ports - // if input has port > 1024, return http then https - if port, err := strconv.Atoi(port); err == nil && port > 1024 { + // Explicitly check for HTTPS port + if port == "443" { + return httpx.HTTPS + } + + // For high ports in specific ranges commonly used for HTTP dev servers + if port, err := strconv.Atoi(port); err == nil && port >= 8000 && port <= 9000 { return httpx.HTTP } } return httpx.HTTPS }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
runner/ports_optimization.go(1 hunks)runner/runner.go(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
runner/ports_optimization.go (1)
common/httpx/http2.go (2)
HTTP(15-15)HTTPS(17-17)
⏰ 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). (6)
- GitHub Check: Functional Test (macOS-latest)
- GitHub Check: Functional Test (ubuntu-latest)
- GitHub Check: Functional Test (windows-latest)
- GitHub Check: Analyze (go)
- GitHub Check: Lint Test
- GitHub Check: release-test
🔇 Additional comments (1)
runner/runner.go (1)
1580-1583: Good optimization for mixed-protocol handling.The integration of
determineMostLikelySchemeOrderimproves the efficiency of mixed-protocol probing by intelligently selecting the initial scheme based on port heuristics. The existing retry logic (lines 1748-1756) provides a safety net if the heuristic guess is incorrect, ensuring reliability.
|
@coderabbitai create an issue for this PR |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 13203 @Mzack9999, I'd be happy to create an issue for you! However, I need a bit more information to create a meaningful issue:
Once you provide these details, I'll create the issue with a link back to this PR (#2298) and assign it to you. |
|
@coderabbitai Create an issue related to this PR. The issue is about port priority optimization, where we try to guess the most like protocol based on port number and global service distribution |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 53 @Mzack9999, I've successfully created issue #2299 for port priority optimization! Issue: #2299 The issue describes the feature where httpx intelligently guesses the most likely protocol (HTTP or HTTPS) based on port numbers and global service distribution patterns. It includes:
The issue has been assigned to you as requested. |
|
Nice |
Summary by CodeRabbit
Embedded nuclei logic for http ports (ref: projectdiscovery/nuclei#6538)
Release Notes