-
Notifications
You must be signed in to change notification settings - Fork 275
add comma separated support for -l option #895
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
WalkthroughAdds comma-separated input support for the -l/--list flag, centralizes hosts input parsing via preProcessArgument, and tightens stdin/stream-mode validation (stdin exclusivity across input flags; disallow hosts in stream mode). Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant User
participant CLI as CLI Options
participant Runner
participant ArgProc as preProcessArgument
User->>CLI: Provide -l/--list (file | stdin | comma-separated)
CLI->>CLI: Validate stdin exclusivity across flags
CLI-->>User: Error if multiple flags use stdin
CLI->>CLI: If stream mode, disallow hosts
CLI-->>User: Error if hosts in stream mode
User->>Runner: Run with validated options
Runner->>ArgProc: Resolve hosts input
ArgProc-->>Runner: []hosts or error
Runner-->>User: Proceed or report error
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Assessment against linked issues
Assessment against linked issues: Out-of-scope changes
Poem
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
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
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
internal/runner/options.go (1)
286-295: Remove stream-mode check from the multi-stdin exclusivity block.The inner
if options.Stream { ... "argument stdin not supported in stream mode" }only triggers when two flags use stdin and is redundant/confusing since stream-mode constraints are enforced below. Keep this block focused on exclusivity across flags.Apply this diff:
- // stdin can be set only on one flag - if (argumentHasStdin(options.Domains) && argumentHasStdin(options.WordList)) || - (argumentHasStdin(options.Domains) && argumentHasStdin(options.Hosts)) || - (argumentHasStdin(options.WordList) && argumentHasStdin(options.Hosts)) { - if options.Stream { - gologger.Fatal().Msgf("argument stdin not supported in stream mode") - } - gologger.Fatal().Msgf("stdin can be set for one flag") - } + // stdin can be set only on one flag + if (argumentHasStdin(options.Domains) && argumentHasStdin(options.WordList)) || + (argumentHasStdin(options.Domains) && argumentHasStdin(options.Hosts)) || + (argumentHasStdin(options.WordList) && argumentHasStdin(options.Hosts)) { + gologger.Fatal().Msgf("stdin can be set for one flag") + }
🧹 Nitpick comments (2)
internal/runner/options.go (1)
303-305: Clarify the stream-mode error for -l with a usage hint.Suggest making the message actionable so users know how to feed stdin in stream mode.
- gologger.Fatal().Msgf("hosts not supported in stream mode") + gologger.Fatal().Msgf("hosts (-l) not supported in stream mode; pipe input instead (e.g., dnsx -stream < hosts.txt)")internal/runner/runner.go (1)
256-259: Add empty-item guard and clearer empty-input error
- In the
if sc == nilblock, distinguishHosts == ""and return
errors.New("no input provided: use -l <file|comma-separated values> or pipe via stdin")instead of the opaque"empty argument".- In the host loop, immediately skip blank entries after trimming:
for item := range sc { item := normalize(item) if item == "" { continue } … }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
internal/runner/options.go(3 hunks)internal/runner/runner.go(1 hunks)
⏰ 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). (2)
- GitHub Check: Analyze (go)
- GitHub Check: Functional Test (windows-latest)
🔇 Additional comments (1)
internal/runner/options.go (1)
97-97: Help text update for -l looks good.Accurately reflects comma-separated support and aligns with -d/-w descriptions.
| } | ||
| } else { | ||
| return errors.New("hosts file or stdin not provided") | ||
| sc, err = r.preProcessArgument(r.options.Hosts) |
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.
This seems to break stdin support:
% echo scanme.sh | go run . -verbose
_ __ __
__| | _ __ ___ \ \/ /
/ _' || '_ \ / __| \ /
| (_| || | | |\__ \ / \
\__,_||_| |_||___//_/\_\
projectdiscovery.io
[INF] Current dnsx version 1.2.2 (latest)
%
Mzack9999
left a 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.
breaks stdin import + failing tests
closes #878
Summary by CodeRabbit