Skip to content

fix(runner): report a response time value that does not fit a duration - #2655

Open
CalvinTjoaquinn wants to merge 1 commit into
projectdiscovery:devfrom
CalvinTjoaquinn:fix/filter-operator-overflow
Open

CalvinTjoaquinn wants to merge 1 commit into
projectdiscovery:devfrom
CalvinTjoaquinn:fix/filter-operator-overflow

Conversation

@CalvinTjoaquinn

@CalvinTjoaquinn CalvinTjoaquinn commented Sep 29, 2026 •

Copy link
Copy Markdown

Proposed changes

FilterOperator.Parse reads a bare number as seconds by retrying time.ParseDuration with an s appended, and that retry discarded its error:

value, err = time.ParseDuration(timeVal)
if err != nil && strings.Contains(err.Error(), "missing unit") {
    value, _ = time.ParseDuration(fmt.Sprintf("%ss", timeVal))
} else if err != nil {
    return operator, value, fmt.Errorf("invalid value provided for %s", f.flag)
}

A number that parses fine on its own but overflows once seconds are added takes the first branch, so value stays at zero and nothing is reported:

-mrt '>=10000000000'   ->  operator=">=" value=0s  err=<nil>

>= 0s is true for every response, so the flag silently matches every host instead of being rejected. The flags affected are -mrt, -match-response-time and -frt, -filter-response-time.

Larger values happen to be caught already, because they fail the first parse with "invalid duration" rather than "missing unit" and fall through to the error branch:

-mrt '>=99999999999999999999'  ->  err=invalid value provided for -mrt

So the gap is the range where the bare number is a valid float but the duration overflows, which starts a little above 9223372036 seconds.

Proof

Parse had no tests, so the new file covers the whole contract: each of the six operators, the bare-number path, space trimming, and the inputs that have to be rejected.

Against the current code only the overflow case fails:

--- FAIL: TestFilterOperatorParse/rejected/>=10000000000

The other fifteen subtests pass before and after, so the change is limited to the value that used to be swallowed.

go test ./runner/ passes, go vet is clean, and gofmt reports nothing.

Checklist

  • Pull request is created against the dev branch
  • All checks passed (lint, unit/integration/regression tests etc.) with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Summary by CodeRabbit

  • Bug Fixes
    • Improved validation of duration filter values. Bare numeric values that exceed the supported duration range now return an invalid-value error instead of being treated as a zero-duration value. Valid formats, including bare numbers interpreted as seconds and values with surrounding whitespace, continue to work. This helps prevent invalid filters from silently producing misleading results.

@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 743b1a7a-b052-4881-ba64-251bf6636de9

📥 Commits

Reviewing files that changed from the base of the PR and between 39e2416 and 9ec2c1d.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 2c61981a-3c4d-4b62-bc21-ff088312dab1

📥 Commits

Reviewing files that changed from the base of the PR and between d3b9d3d and 39e2416.

📒 Files selected for processing (2)
  • runner/filteroperator.go
  • runner/filteroperator_test.go

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


Walkthrough

FilterOperator.Parse now returns an invalid-value error when a numeric duration cannot be parsed after interpreting it as seconds. Tests cover valid operators and duration formats, whitespace, and rejected inputs.

Changes

Duration parsing

Layer / File(s) Summary
Bare-number parsing and validation
runner/filteroperator.go, runner/filteroperator_test.go
The parser now returns an error if parsing a bare number as seconds fails. Tests cover valid operators and durations, whitespace, and rejected inputs.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 39e24

Oversized response-time filter values are now rejected instead of silently matching every host. The change is small and covered by tests, so it looks safe to merge.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 39e24

The change rejects an oversized response-time value instead of allowing it to act as a zero-duration filter. The identified callers already handle parsing errors before comparing response times. No broader boundary change was identified, though external exposure is not fully established.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The evidenced effect is confined to duration validation and its response-time filter consumers; broader external exposure cannot be determined from the available topology.

Trust Boundaries and Controls

  • inferred — On the identified runner paths, parser errors are handled before the duration is used for filtering, and the new overflow error follows that existing control flow.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: reporting an error when a response-time value does not fit within a duration.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

I’m a rabbit, pleased to see
Bad seconds raise errors cleanly.
I nibble tests beside the code,
And hop along the parse-time road.
My whiskers twitch; the values pass!

Comment @coderabbitai help to get the list of available commands.

FilterOperator.Parse reads a bare number as seconds by retrying
time.ParseDuration with an "s" appended, and that retry discarded its error.
A number too large to hold as a duration left value at zero with nothing
reported, so -mrt '>=10000000000' became a filter matching every host rather
than a rejected flag.

The function had no tests. The new ones cover each operator, the bare-number
path, trimming, and the inputs that have to be rejected. Only the overflow
case changes: the other fifteen pass before and after.
@CalvinTjoaquinn
CalvinTjoaquinn force-pushed the fix/filter-operator-overflow branch from 39e2416 to 9ec2c1d Compare September 29, 2026 06:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant