Skip to content

feat(sources): honor -max-results across paginating sources - #1810

Merged
Mzack9999 merged 2 commits into
projectdiscovery:devfrom
Gerijacki:feat/max-results-paginating-sources
Aug 5, 2026
Merged

Mzack9999 merged 2 commits into
projectdiscovery:devfrom
Gerijacki:feat/max-results-paginating-sources

Conversation

@Gerijacki

@Gerijacki Gerijacki commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

-max-results (-mr) is currently honored only by the virustotal source. Every other paginating source keeps walking its cursor/pages to the end and burns API quota even when the user explicitly asked for a cap.

This applies the same early-stop pattern already used by virustotal to the rest of the paginating sources: once session.MaxResults results have been emitted, the source returns instead of requesting the next page.

Sources updated

censys, certspotter, shodan, securitytrails, quake, dnsdb, onyphe, rsecloud, redhuntlabs, urlscan, merklemap, commoncrawl.

Single-request sources are unaffected (there is nothing to paginate).

Behavior

  • 0 (default) means unlimited — existing behavior is unchanged, paid keys are never silently truncated.
  • With a positive value, pagination stops as soon as the limit is reached, bounding both results and request count.

Tests

Added httptest-based coverage for censys and certspotter proving that the cap stops pagination and bounds the number of requests, following the existing virustotal test pattern. Also updated the flag help text and README.

Summary by CodeRabbit

  • New Features
    • Added consistent max-results enforcement across multiple subdomain discovery sources.
    • Scraping now stops early (including pagination) once the configured maximum is reached, reducing extra requests.
    • A value of 0 continues to mean unlimited results.
  • Documentation
    • Updated CLI help and README guidance to clarify how limits interact with pagination and early stopping.
  • Tests
    • Added/expanded tests to verify both unlimited retrieval and early-stop behavior when limits are applied.

The -max-results flag was only honored by the virustotal source; every
other paginating source kept walking its cursor/pages and burning API
quota even when a cap was requested.

Apply the same early-stop pattern to the remaining paginating sources
(censys, certspotter, shodan, securitytrails, quake, dnsdb, onyphe,
rsecloud, redhuntlabs, urlscan, merklemap, commoncrawl): once
session.MaxResults results have been emitted the source returns instead
of requesting the next page. Single-request sources are unaffected.

Add httptest-based coverage for censys and certspotter proving the cap
stops pagination and bounds the request count, and update the flag help
text and docs to reflect the broader support.
@coderabbitai

coderabbitai Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3bf1ee49-2287-4a99-b71b-288af39f1abe

📥 Commits

Reviewing files that changed from the base of the PR and between 46d0dc1 and a23ed25.

📒 Files selected for processing (1)
  • pkg/subscraping/sources/onyphe/onyphe.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/subscraping/sources/onyphe/onyphe.go

Walkthrough

The CLI documentation now defines MaxResults behavior, and 13 scraping sources enforce the session-level cap during result emission and pagination. Censys and Certspotter receive focused tests for unlimited and capped pagination.

Changes

Max-results enforcement

Layer / File(s) Summary
Max-results contract
README.md, pkg/runner/options.go
CLI and README help text define 0 as unlimited and describe early stopping by paginated sources.
Censys and Certspotter pagination
pkg/subscraping/sources/censys/*, pkg/subscraping/sources/certspotter/*
Both sources stop pagination when session.MaxResults is reached; tests cover capped and unlimited pagination plus Certspotter metadata and API-key behavior.
Streaming and paginated source enforcement
pkg/subscraping/sources/{commoncrawl,dnsdb,merklemap,quake,redhuntlabs,securitytrails,shodan,urlscan}/*.go
Sources stop result processing, streaming, or additional page requests when the configured limit is reached.
Multi-field and endpoint termination
pkg/subscraping/sources/onyphe/onyphe.go, pkg/subscraping/sources/rsecloud/rsecloud.go
Onyphe centralizes capped emission across result fields, and RSECloud skips later endpoint requests after reaching the limit.

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

Sequence Diagram(s)

sequenceDiagram
  participant Session
  participant Source
  participant ProviderAPI
  participant ResultsChannel
  Session->>Source: provide MaxResults
  Source->>ProviderAPI: request page or stream
  ProviderAPI-->>Source: return subdomain results
  Source->>ResultsChannel: emit results
  Source->>Source: stop when MaxResults is reached
Loading

Possibly related PRs

Suggested reviewers: mzack9999

Poem

I’m a rabbit counting names in a queue,
With a tidy little limit to pursue.
Pages may hop, but when the count is done,
I tuck my ears and stop the run.
Zero means carrots for everyone! 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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 accurately summarizes the main change: paginating sources now honor -max-results.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@pkg/subscraping/sources/onyphe/onyphe.go`:
- Around line 103-112: Update the emit helper in the Onyphe source to send
results with a select that also observes ctx.Done(), returning immediately with
the appropriate uncapped status when cancellation occurs. Preserve the existing
empty-subdomain filtering, result counting, and maxResults cap behavior for
successful channel sends.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1dad9316-2714-4d9d-86b5-82c711ab6647

📥 Commits

Reviewing files that changed from the base of the PR and between d0ea102 and 46d0dc1.

📒 Files selected for processing (16)
  • README.md
  • pkg/runner/options.go
  • pkg/subscraping/sources/censys/censys.go
  • pkg/subscraping/sources/censys/censys_maxresults_test.go
  • pkg/subscraping/sources/certspotter/certspotter.go
  • pkg/subscraping/sources/certspotter/certspotter_test.go
  • pkg/subscraping/sources/commoncrawl/commoncrawl.go
  • pkg/subscraping/sources/dnsdb/dnsdb.go
  • pkg/subscraping/sources/merklemap/merklemap.go
  • pkg/subscraping/sources/onyphe/onyphe.go
  • pkg/subscraping/sources/quake/quake.go
  • pkg/subscraping/sources/redhuntlabs/redhuntlabs.go
  • pkg/subscraping/sources/rsecloud/rsecloud.go
  • pkg/subscraping/sources/securitytrails/securitytrails.go
  • pkg/subscraping/sources/shodan/shodan.go
  • pkg/subscraping/sources/urlscan/urlscan.go

@Gerijacki

Copy link
Copy Markdown
Contributor Author

Good catch — updated the onyphe emit helper to send inside a select that also observes ctx.Done(), matching the pattern used by the other sources, so it can't block on a cancelled context. Done in a23ed25.

@dogancanbakir
dogancanbakir requested a review from Mzack9999 August 5, 2026 15:16
@Mzack9999
Mzack9999 merged commit d426b12 into projectdiscovery:dev Aug 5, 2026
8 checks passed
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
subfinder 2.16.0

Created-by: HarmonybrewBot
Commit-by: HarmonybrewBot
Merged-by: HarmonybrewBot
Description: Created by `brew bump`

---

Created with `brew bump-formula-pr`.<details>
  <summary>release notes</summary>
  <pre><!-- Release notes generated using configuration in .github/release.yml at main -->

## What's Changed

* feat(sources): honor -max-results across paginating sources by @Gerijacki in projectdiscovery/subfinder#1810
* fix(extractor): match the target domain literally and reject partial hosts by @Gerijacki in projectdiscovery/subfinder#1811
* fix(subscraping): cap untrusted source response bodies with a size limit by @adamsjack711-ux in projectdiscovery/subfinder#1809
* fix(subscraping): use DialContext instead of the deprecated Dial by @jonaslejon in projectdiscovery/subfinder#1835
* feat: add scanmalware passive source by @jonaslejon in projectdiscovery/subfinder#1834
* fix(crtsh): set statement_timeout via SQL query to avoid PgBouncer handshake rejection (#1828) by @gcoinstash-cmd in projectdiscovery/subfinder#1832

## New Contributors
* @J12934 made their first contribution in projectdiscovery/subfinder#1823
* @adamsjack711-ux made their first contribution in projectdiscovery/subfinder#1809
* @gcoinstash-cmd made their first contribution in projectdiscovery/subfinder#1832

**Full Changelog**: https://github.com/projectdiscovery/subfinder/compare/v2.15.0...v2.16.0</pre>
  <p>View the full release notes at <a href="https://github.com/projectdiscovery/subfinder/releases/tag/v2.16.0">https://github.com/projectdiscovery/subfinder/releases/tag/v2.16.0</a>.</p>
</details>
<hr>

See merge request: Harmonybrew/homebrew-core!17505
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.

2 participants