Skip to content

fix(scan): percent-encode dork queries before search - #327

Merged
vmfunc merged 1 commit into
vmfunc:mainfrom
TBX3D:fix/dork-query-encoding
Jul 22, 2026
Merged

fix(scan): percent-encode dork queries before search#327
vmfunc merged 1 commit into
vmfunc:mainfrom
TBX3D:fix/dork-query-encoding

Conversation

@TBX3D

@TBX3D TBX3D commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

the google-search client only swaps spaces for '+' and drops the term
into the query string verbatim, so a dork carrying a raw '#' or '&' cut
the request url short at the fragment or split it into stray query
params. the search then ran against a fragment of the intended dork.
encode the term up front so the whole dork survives.

@TBX3D
TBX3D requested a review from vmfunc as a code owner July 4, 2026 01:11
@github-actions github-actions Bot added scan changes to scan engine tests test changes size/m <200 lines changed labels Jul 4, 2026
@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown

pr summary

2 files changed (+95 -5)

category files
go source 2
tests 1

@codecov-commenter

codecov-commenter commented Jul 4, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 40.00000% with 3 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@7ea1cd2). Learn more about missing BASE report.

Files with missing lines Patch % Lines
internal/scan/dork.go 40.00% 3 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #327   +/-   ##
=======================================
  Coverage        ?   54.74%           
=======================================
  Files           ?       81           
  Lines           ?     6876           
  Branches        ?        0           
=======================================
  Hits            ?     3764           
  Misses          ?     2843           
  Partials        ?      269           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

the google-search client only swaps spaces for '+' and drops the term
into the query string verbatim, so a dork carrying a raw '#' or '&' cut
the request url short at the fragment or split it into stray query
params. the search then ran against a fragment of the intended dork.
encode the term up front so the whole dork survives.
@TBX3D
TBX3D force-pushed the fix/dork-query-encoding branch from e368f7c to 24bf8ee Compare July 9, 2026 23:52

@vmfunc vmfunc left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

checked the actual client, buildUrl in rocketlaunchr/google-search just does Trim then space->'+' and drops the term straight into ?q=, zero encoding. so yeah, a raw '#' landed in the fragment and '&' split the params, exactly as you describe. QueryEscape is the right call here: space still ends up as '+' so the client's own replace is a no-op, and '#'/'&'/'+' round-trip clean on google's side. nice that buildSearchURL in the test actually mirrors buildUrl instead of asserting against itself, the truncation guard is real. in.

@vmfunc
vmfunc merged commit 1f6d0f7 into vmfunc:main Jul 22, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scan changes to scan engine size/m <200 lines changed tests test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants