-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
feat: add -specify-ip option to allow for specified CustomIP values #5898
base: dev
Are you sure you want to change the base?
Conversation
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe changes introduce a new boolean flag Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
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
🧹 Outside diff range and nitpick comments (3)
pkg/input/provider/list/hmap.go (1)
153-153
: Improve the comment for clarity.The current comment could be more descriptive about the fallback behavior.
- // if no comma, let's process the URL normally + // If no comma is found in the input, process the entire string as a URL without custom IP specificationpkg/types/types.go (1)
320-321
: Enhance field documentation.The comment could be more detailed about the expected format and provide an example.
- // Provide IP address with the URL, as IP,URL + // SpecifyIP enables providing a custom IP address with the URL in the format "IP,URL". + // Example: "192.168.1.1,example.com" will scan example.com using 192.168.1.1cmd/nuclei/main.go (1)
239-239
: LGTM! Consider enhancing the flag documentation.The new
-specify-ip
flag is well-integrated into the input options group. However, the description could be more detailed to help users understand:
- The specific use cases (e.g., scanning through reverse proxies, WAFs)
- Examples of valid input formats
- Interaction with other input methods (list, stdin)
Consider updating the flag description to be more comprehensive:
-flagSet.BoolVarP(&options.SpecifyIP, "specify-ip", "ip", false, "scan the specified IP address (items provided as IP,URL)") +flagSet.BoolVarP(&options.SpecifyIP, "specify-ip", "ip", false, "scan the specified IP address (format: IP,URL). Useful for scanning through reverse proxies/WAFs or when target resolution is not desired")
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (4)
cmd/nuclei/main.go
(1 hunks)pkg/input/provider/list/hmap.go
(3 hunks)pkg/input/provider/list/utils.go
(1 hunks)pkg/types/types.go
(1 hunks)
🔇 Additional comments (2)
pkg/input/provider/list/utils.go (1)
4-4
: LGTM!
The addition of the SpecifyIP
field to the ipOptions
struct is clean and well-aligned with the existing boolean fields.
cmd/nuclei/main.go (1)
239-241
: Verify interaction with other IP-related flags.
The new -specify-ip
flag is added alongside other IP-related flags. Please ensure proper interaction between these flags.
✅ Verification successful
Let me analyze the interactions between these IP-related flags based on the code snippets found.
The search results show clear handling of these flags in the codebase:
-
In
pkg/input/provider/list/hmap.go
, the flags are used in a mutually compatible way:SpecifyIP
handles custom IP,URL pairs with proper parsingScanAllIPs
performs DNS lookups to get all associated IPsIPVersion
is used to filter IPs (4/6) during processing
-
In
internal/runner/options.go
, there's proper default handling for IP versions where IPv4 is the default if none specified.
Let me verify one more aspect to ensure there are no conflicting conditions between these flags.
Let me try one more search to specifically look for any validation logic between these flags.
Based on the code analysis, I can now provide a final response:
The IP-related flags are properly implemented with compatible interactions
The codebase shows well-structured handling of these flags:
SpecifyIP
andScanAllIPs
are processed independently in separate code blocksIPVersion
works as a filter on top of either flag's behavior- Default IPv4 is properly set when no IP version is specified
- No conflicting validation rules or mutually exclusive conditions were found
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for potential conflicts or interactions between IP-related flags
# Test: Search for IP-related flag handling logic
rg -A 5 "SpecifyIP|ScanAllIPs|IPVersion" --type go
Length of output: 5023
Script:
#!/bin/bash
# Check for any validation or conflict checks between these flags
ast-grep --pattern 'if $_ && $_.$_ {
$$$
}'
Length of output: 47
Script:
#!/bin/bash
# Look for validation logic in runner or options initialization
rg -A 5 "func.*[Vv]alidate.*Options|func.*[Cc]heck.*Options" --type go
Length of output: 2307
if i.ipOptions.SpecifyIP { | ||
valueParsed := strings.SplitN(value, ",", 2) | ||
if len(valueParsed) == 2 { | ||
metaInput := contextargs.NewMetaInput() | ||
metaInput.Input = strings.TrimSpace(valueParsed[1]) | ||
metaInput.CustomIP = strings.TrimSpace(valueParsed[0]) | ||
i.delItem(metaInput) | ||
return | ||
} | ||
// if no comma, let's process the URL normally | ||
} |
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.
🛠️ Refactor suggestion
Add IP address validation.
The code should validate that the specified IP address is in a valid format before using it.
Example implementation:
+func isValidIP(ip string) bool {
+ return net.ParseIP(ip) != nil
+}
if i.ipOptions.SpecifyIP {
valueParsed := strings.SplitN(value, ",", 2)
if len(valueParsed) == 2 {
+ ip := strings.TrimSpace(valueParsed[0])
+ if !isValidIP(ip) {
+ gologger.Warning().Msgf("Invalid IP address specified: %s", ip)
+ return
+ }
metaInput := contextargs.NewMetaInput()
metaInput.Input = strings.TrimSpace(valueParsed[1])
- metaInput.CustomIP = strings.TrimSpace(valueParsed[0])
+ metaInput.CustomIP = ip
i.delItem(metaInput)
return
}
Committable suggestion skipped: line range outside the PR's diff.
Thanks for your contribution @p-l- ! :) |
Proposed changes
This PR adds a
-specify-ip
which changes the expected target formet to<IP address>,<URL>
.It makes it easier to scan one host with a given hostname, that could be either non-resolvable / internal, or that could resolve to a reverse-proxy or WAF and we have found the origin.
The format is compatible with zgrab2.
Checklist
Summary by CodeRabbit
New Features
Bug Fixes
Documentation