fix(query): allow empty ARG when a filter option is provided - #1211
fix(query): allow empty ARG when a filter option is provided#1211ocervell wants to merge 2 commits into
Conversation
When `-rf`, `-ws`, or `-d` is given without a query expression, `secator q` now returns all matching results instead of raising "Missing argument ARG". Bare `secator q` (no args, no options) still shows the error. Fixes #1210 Co-authored-by: Olivier Cervello <ocervell@users.noreply.github.com>
|
@claude no need to check for -rf or even -ws: The following should all work: |
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughThe Empty-ARG fallback in
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
|
Claude finished @ocervell's task in 2m 32s —— View job Todo
Changes made
# Before
if not arg:
if report_filter or workspace or time_delta:
run_report_show(...)
return
raise click.UsageError('Missing argument ARG ...')
# After
if not arg:
run_report_show(report_filter, output, time_delta, None, fmt, workspace, driver, dedupe, limit, output_folder)
returnAll three forms now work:
|
Remove the filter guard so that `secator q` (with no ARG, no -ws, no -rf) succeeds and queries the whole current workspace, matching: secator q # all results in current workspace secator q -rf "scans/23" # scoped to that report path secator q -ws test # scoped to 'test' workspace Co-authored-by: Olivier Cervello <ocervell@users.noreply.github.com>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/unit/test_query_cli.py (1)
130-149: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd one test for the
time_delta-only empty-ARG path.The new dispatch condition allows empty ARG when
time_deltais set, but this branch is not covered by the added tests. A singlequery -d ... --driver localcase would complete coverage for the new condition.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/unit/test_query_cli.py` around lines 130 - 149, Add a new test method to cover the time_delta-only empty-ARG path. Create a test similar to test_empty_arg_with_report_filter and test_empty_arg_with_workspace that invokes the query command with the time_delta flag (using -d parameter) and --driver local but no ARG value, then verify the results are returned successfully by asserting the exit code is 0, no exception occurred, and the expected vulnerability results are present.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/unit/test_query_cli.py`:
- Around line 130-149: Add a new test method to cover the time_delta-only
empty-ARG path. Create a test similar to test_empty_arg_with_report_filter and
test_empty_arg_with_workspace that invokes the query command with the time_delta
flag (using -d parameter) and --driver local but no ARG value, then verify the
results are returned successfully by asserting the exit code is 0, no exception
occurred, and the expected vulnerability results are present.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: be8060dd-10b5-4963-b84a-08e6d082b2ed
📒 Files selected for processing (2)
secator/cli.pytests/unit/test_query_cli.py
When
-rf,-ws, or-dis given without a query expression,secator qnow returns all matching results instead of raising "Missing argument ARG". Baresecator q(no args, no options) still shows the error.Fixes #1210
Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
querycommand no longer requires a search expression when report filters, workspace, or time range options are specified.Tests