Repository navigation
fix(crtsh): drop unused certificate metadata from SQL query (#1773) - #1787
Conversation
…iscovery#1773) The Postgres query inherited the verbatim form crt.sh's web UI uses to render its certificate browser. subfinder consumes NAME_VALUE only, so GROUP BY sub.CERTIFICATE on multi-KB DER blobs, the four x509_* function calls per group, the correlated LEFT JOIN LATERAL into ct_log_entry, and the trailing ORDER BY ENTRY_TIMESTAMP are all discarded. Replacing the WITH/JOIN with a direct DISTINCT NAME_VALUE preserves the result set (verified parity on iana.org: 24 unique names from both queries) and lets the LIMIT 10000 clause bound unique subdomains instead of raw certificate rows. The downstream SplitSeq + Extractor path is unchanged.
Neo - PR Security ReviewNo security issues found Comment |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe crt.sh PostgreSQL query is simplified to directly select distinct NAME_VALUE from certificate_and_identities using full-text and ILIKE matching, eliminating unnecessary certificate metadata extraction, grouping, joins, and ordering that subfinder does not use. ChangesQuery Simplification
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 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)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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. Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.Comment |
subfinder 2.15.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>## What's Changed ### 🎉 New Features * Added shodanct passive source by @dogancanbakir in projectdiscovery/subfinder#1796 * Added Option `-vR`, `-virustotal-res` for VirusTotal source by @Bundy01 in projectdiscovery/subfinder#1719 * Added machine-readable source listing with `-ls -oJ` by @Gerijacki in projectdiscovery/subfinder#1812 ### 🐞 Bug Fixes * Fixed source leaks by @Mzack9999 in projectdiscovery/subfinder#1801 * Fixed drain source channels on cancel so source goroutines exit instead of leaking on a blocked send by @Mzack9999 in projectdiscovery/subfinder#1799 * Fixed crtsh's query by dropping unused certificate metadata from SQL query by @ChrisJr404 in projectdiscovery/subfinder#1787 * Fixed VirusTotal source by capping pagination and providing clearer 429 message by @ChrisJr404 in projectdiscovery/subfinder#1788 * Fixed Anubis source by switching subdomain API to anubisdb.com by @jatinder14 in projectdiscovery/subfinder#1815 ### Other Changes * Fixed lint issues by @dogancanbakir in projectdiscovery/subfinder#1820 * Refactored loadFromFile to use bufio.Scanner by @nandaanomi in projectdiscovery/subfinder#1791 ## New Contributors * @ChrisJr404 made their first contribution in projectdiscovery/subfinder#1787 * @Bundy01 made their first contribution in projectdiscovery/subfinder#1719 * @nandaanomi made their first contribution in projectdiscovery/subfinder#1791 * @jatinder14 made their first contribution in projectdiscovery/subfinder#1815 * @Gerijacki made their first contribution in projectdiscovery/subfinder#1812 **Full Changelog**: https://github.com/projectdiscovery/subfinder/compare/v2.14.0...v2.15.0</pre> <p>View the full release notes at <a href="https://github.com/projectdiscovery/subfinder/releases/tag/v2.15.0">https://github.com/projectdiscovery/subfinder/releases/tag/v2.15.0</a>.</p> </details> <hr> See merge request: Harmonybrew/homebrew-core!16007
Closes #1773.
Background
The Postgres query in
pkg/subscraping/sources/crtsh/crtsh.gowas inherited verbatim from crt.sh's web UI (which renders a certificate browser). subfinder only ever consumesNAME_VALUE, so the certificate-metadata ceremony is wasted work on crt.sh's free public database:GROUP BY sub.CERTIFICATEon multi-KB DER blobsx509_*function calls per certificate group (CPU-intensive ASN.1 parsing)LEFT JOIN LATERALintoct_log_entryper groupORDER BY ENTRY_TIMESTAMP(subfinder dedupes downstream — ordering is irrelevant)LIMIT 10000placed on raw certificate rows (a band-aid against the ceremony costs)@lc's issue lays this out in detail.
Change
Replace the WITH/JOIN/x509-functions form with a direct
SELECT DISTINCT cai.NAME_VALUE. The downstreamSplitSeq+Extractorpath is unchanged, so any consumer behavior is identical.A pleasant side-effect:
LIMIT 10000now bounds distinct subdomains rather than raw certificate hits, so the implicit cap is more useful in practice. The unlimited "All" mode is preserved.Verification
psqldirectly againstcrt.shforiana.org:diffof the dedup'd result sets is empty — same subdomains discovered, same identity coverage. The 23-vs-24 row gap is a single*.iana.orgwildcard string that the existing query repeats per cert; the new query emits it once.CI's existing
pkg/passive/sources_wo_auth_test.goskips crtsh in GitHub Actions (IP-based ban), so this change is exercised by manualpsqlverification rather than the integration suite.Notes
+8 / -26lines, single file.getSubdomainsFromHTTP).Summary by CodeRabbit