Skip to content

fix(sources): honor -max-results in windvane, zoomeyeapi, thc and rapiddns - #1986

Merged
Mzack9999 merged 1 commit into
projectdiscovery:devfrom
arxhr007:fix/honor-max-results-paginating-sources
Oct 31, 2026
Merged

Mzack9999 merged 1 commit into
projectdiscovery:devfrom
arxhr007:fix/honor-max-results-paginating-sources

Conversation

@arxhr007

@arxhr007 arxhr007 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Proposed changes

Closes #1985.

-max-results is documented as honored by paginating sources, but windvane, zoomeyeapi, thc and rapiddns keep requesting pages until the API runs out, so the limit has no effect on them. They now return as soon as the result that reaches the limit has been sent, the same way onyphe, securitytrails and the other paginating sources do. With no limit set (0) nothing changes.

Proof

Each source has a test against a local mock server that fails without the change and passes with it. Without the change, for example, windvane returns all 3000 results with a limit of 1000.

go test ./pkg/subscraping/sources/{windvane,zoomeyeapi,thc,rapiddns}/
ok  .../windvane
ok  .../zoomeyeapi
ok  .../thc
ok  .../rapiddns

thc and rapiddns had no tests, so they also get a test that an unlimited run still reads every page.

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

  • New Features
    • RapidDNS, THC, Windvane, and ZoomEye now honor the configured maximum-results limit during a run, stopping pagination once the limit is reached.
    • When no positive limit is configured, these sources continue collecting results according to their existing pagination behavior.

…iddns

The -max-results flag is documented as honored by paginating sources, and
most of them stop requesting pages once the limit is reached. These four
paginate through every page regardless, so a limit set to protect an API
quota had no effect on them.

Stop after the result that reaches the limit, as the other sources do, and
add a test for each that fails without the change.
@coderabbitai

coderabbitai Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 891cbe98-30bc-40a9-9475-e82765bc3b53
Commits

Reviewing files that changed from the base of the PR and between 98ef871 and ee49f46.

Files selected for processing: 8
  • pkg/subscraping/sources/rapiddns/rapiddns.go
  • pkg/subscraping/sources/rapiddns/rapiddns_test.go
  • pkg/subscraping/sources/thc/thc.go
  • pkg/subscraping/sources/thc/thc_test.go
  • pkg/subscraping/sources/windvane/windvane.go
  • pkg/subscraping/sources/windvane/windvane_test.go
  • pkg/subscraping/sources/zoomeyeapi/zoomeyeapi.go
  • pkg/subscraping/sources/zoomeyeapi/zoomeyeapi_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

RapidDNS, THC, Windvane, and ZoomEye API now honor positive session.MaxResults values by stopping result emission and pagination at the limit. Tests check capped and unlimited runs, including the number of requests made.

Changes

Paginating source result limits

Layer / File(s) Summary
Enforce limits in paginating sources
pkg/subscraping/sources/{rapiddns,thc,windvane,zoomeyeapi}/*.go
Each source stops after emitting the configured positive number of results. Zero or negative values do not cap results. Windvane discards the current response when it reaches the limit.
Test capped and unlimited pagination
pkg/subscraping/sources/{rapiddns,thc,windvane,zoomeyeapi}/*_test.go
HTTP test servers verify result counts and request counts for capped and unlimited runs. Windvane tests limits of 1,000, 1,500, and 5,000 results against 3,000 available results.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related PRs

Suggested reviewers: dwisiswant0

Merge Risk: Minimal · up to ee49f

The change limits pagination per source and target domain. No merge-blocking risk was identified.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely identifies the main change: honoring -max-results in the four affected sources.
Linked Issues check Passed Issue #1985 requires that windvane, zoomeyeapi, thc, and rapiddns stop requesting pages once -max-results is reached. A limit of 0 keeps unlimited behavior. At the reviewed head (ee49f46), windvane.go…
Out of Scope Changes check Passed The PR summary lists changes only in the four linked sources: pkg/subscraping/sources/{windvane,zoomeyeapi,thc,rapiddns}, both source files and their test files. Each change adds a MaxResults check to…
Full details: Linked Issues check

Explanation

Issue #1985 requires that windvane, zoomeyeapi, thc, and rapiddns stop requesting pages once -max-results is reached. A limit of 0 keeps unlimited behavior. At the reviewed head (ee49f46), windvane.go reads session.MaxResults. After each emitted subdomain, it checks maxResults > 0 && stats.Results >= maxResults, then discards the current HTTP response and returns before the next request. Without a positive limit, the loop continues as before. The PR summary reports the same stop-at-limit logic for zoomeyeapi.go (stops after emitting that many nonempty domains), thc.go (stops emitting once the positive limit is reached), and rapiddns.go (stops after emitting that many results). Tests cover the new behavior: TestWindvaneSource_HonorsMaxResults, TestZoomeyeAPISource_HonorsMaxResults, TestTHCSource_HonorsMaxResults, TestTHCSource_FollowsPagesWhenUnlimited, and rapiddns pagination tests with a limit of 3 and unlimited runs. Limitation: repository diff reads for the zoomeyeapi, thc, and rapiddns files returned no content, and the inspection budget was used. The behavior of those three sources rests on the PR summary and was not checked line by line.

Full details: Out of Scope Changes check

Explanation

The PR summary lists changes only in the four linked sources: pkg/subscraping/sources/{windvane,zoomeyeapi,thc,rapiddns}, both source files and their test files. Each change adds a MaxResults check to the pagination loop or adds tests for that behavior. No exported declarations changed. No unrelated source, configuration, or documentation changes are listed. The windvane.go content at head confirms the windvane change is limited to the MaxResults handling and a comment about per-page response discard. Test additions and helper updates support the linked behavior. The three non-windvane source files were not re-read; their scope rests on the PR summary.

Full details: Docstring Coverage

Explanation

Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 4 functions across 8 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

A rabbit checks the page count twice
Four sources stop at the limit
The next page waits unrequested
Test servers count each turn
Six domains hop, then three
The rabbit thumps: results complete

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

@Bundy01

Bundy01 commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

I’m not sure if this is relevant.
The -mr option was introduced because of VirusTotal’s new API policy.

Why would anyone want to limit the results from other APIs?

@arxhr007

Copy link
Copy Markdown
Contributor Author

You're right that -mr started with VirusTotal in #1719. #1810 then extended it to the other paginating sources (censys, certspotter, shodan, securitytrails, onyphe, dnsdb, urlscan, merklemap and more) so that a set limit also stops their pagination, and the help text and README now describe it as a general per-source limit ("honored by paginating sources"). windvane, zoomeyeapi, thc and rapiddns weren't covered by #1810 and still page through everything, so this PR applies the same early stop to them. For the keyed sources (windvane, zoomeyeapi) that saves quota. For thc and rapiddns it bounds the number of requests and the run time. With -mr 0 (the default) nothing changes.

@Mzack9999
Mzack9999 merged commit 5e3e2c9 into projectdiscovery:dev Oct 31, 2026
9 checks passed
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.

[Issue] -max-results is ignored by windvane, zoomeyeapi, thc and rapiddns

3 participants