Repository navigation
fix(sources): honor -max-results in windvane, zoomeyeapi, thc and rapiddns - #1986
Conversation
…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.
|
No actionable comments were generated in the recent review.
|
| 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:
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix · Severity of issue fixed: Medium
Possibly related PRs
- projectdiscovery/subfinder#1980: This PR also changes Windvane pagination termination and response disposal.
- projectdiscovery/subfinder#1981: This PR also changes the Windvane loop to enforce
session.MaxResults.
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: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Check name Status Explanation Description Check Check skipped - CodeRabbit’s high-level summary is enabled. Title check The title clearly and concisely identifies the main change: honoring -max-results in the four affected sources. Linked Issues check Issue #1985requires 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 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
#1985requires 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.
|
I’m not sure if this is relevant. Why would anyone want to limit the results from other APIs? |
|
You're right that |
Proposed changes
Closes #1985.
-max-resultsis documented as honored by paginating sources, butwindvane,zoomeyeapi,thcandrapiddnskeep 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 wayonyphe,securitytrailsand 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.
thcandrapiddnshad no tests, so they also get a test that an unlimited run still reads every page.Checklist
Summary by CodeRabbit