impeccable icon indicating copy to clipboard operation
impeccable copied to clipboard

fix(detect): add --url for Windows cmd ampersand-safe scans (#403)

Open stantheman0128 opened this issue 4 months ago • 1 comments

Before opening

This repo is issue-first for outside contributions. If you are not pbakaus or abdulwahabone, please link the issue where a maintainer approved or requested this PR. Unsolicited PRs may be closed without review.

  • Linked issue: https://github.com/pbakaus/impeccable/issues/403
  • Contributor status:
    • [ ] I am pbakaus or abdulwahabone
    • [ ] A maintainer approved this PR in the linked issue

Note: #403 is a filed Windows bug with a concrete repro and suggested mitigations (--url / docs). Happy to close or reshape if you want discussion first.

Summary

Fixes #403. On Windows cmd.exe, bare & in a URL is a command separator, and the npm .cmd shim does not reliably preserve quoting via %*. This adds detect --url <url> / --url= so query strings can be passed as a flag value, and documents the cmd.exe quoting caveat in --help.

Type of change

  • [x] Bug fix

Checklist

  • [ ] Source files updated in source/ (CLI-only change under cli/)
  • [ ] bun run build ran successfully (not required for this CLI path)
  • [x] Targeted tests pass (bun test tests/detect-antipatterns.test.js -t --help|--url)
  • [ ] Tested with at least one provider
  • [ ] README / DEVELOP.md updated if needed (help text covers the caveat)
  • [x] I reviewed the full diff myself before requesting human review
  • [x] I disclosed any AI assistance in this PR and related commits/comments, or no AI assistance was used

Evidence

$ bun test tests/detect-antipatterns.test.js -t --help|--url
(pass) CLI > --help exits 0
(pass) CLI > --url accepts a URL with query string ampersands
(pass) CLI > --url= form is accepted as a detect target alongside files
3 pass
0 fail

AI assistance

Assisted by Cursor/Grok. Human author: Stan Shih (@stantheman0128).


[!NOTE] Low Risk CLI-only argument parsing and help text; no changes to detection engines or security-sensitive paths.

Overview Fixes Windows cmd.exe breaking bare URLs when query strings contain &, by letting users pass the scan target via detect --url / --url= instead of a positional argument.

The detect CLI parses and removes --url values into the scan target list (supports space-separated and inline forms), errors if the flag has no value (except when --help is also present), and documents the cmd.exe quoting caveat in top-level help, detect --help, and examples.

Tests cover help text, missing-value behavior, argv consumption without a browser, optional Puppeteer checks that the full URL (including &) reaches navigation, and local paths passed through --url.

Reviewed by Cursor Bugbot for commit 7777b4dc11974c791429cfed7e3f72b919c89b3f. Bugbot is set up for automated code reviews on this repo. Configure here.

stantheman0128 avatar Jul 23 '26 10:07 stantheman0128

Greptile Summary

This PR adds a safer way to pass URL targets to impeccable detect on Windows cmd.exe. The main changes are:

  • Adds --url <value> and --url=<value> parsing before detect target collection.
  • Reports a clear error when --url is passed without a value.
  • Updates detect and top-level help text with the Windows & quoting caveat.
  • Adds CLI tests for help output, missing values, argument consumption, and query-string preservation.

Confidence Score: 5/5

Safe to merge with minimal risk.

The change is limited to CLI argument parsing, help text, and targeted tests. The new parser follows the existing option-consumption pattern and preserves existing detect behavior for normal targets.

Files Needing Attention: No files require special attention.

T-Rex T-Rex Logs

What T-Rex did

  • Ran the automated URL detection test and captured results showing 7 pass, 290 filtered out, and 0 fail with exit code 0, indicating the test suite completed successfully.
  • Validated the manual CLI proof for URL detection, confirming the command supports --url and --url=<value>, includes examples like foo=1&bar=2, and notes the Windows cmd.exe usage, with exit code 0.

View all artifacts

T-Rex Ran code and verified through T-Rex

Important Files Changed

Filename Overview
cli/bin/cli.js Updates top-level help to mention the Windows cmd.exe --url workaround for detect scans; no issues found.
cli/engine/cli/main.mjs Adds --url <value> / --url=<value> parsing before target collection, with missing-value handling and help text; no issues found.
tests/detect-antipatterns.test.js Adds CLI tests for help text, bare --url errors, query-string preservation, and argument consumption; no issues found.

Reviews (3): Last reviewed commit: "fix(detect): keep --help working when a ..." | Re-trigger Greptile

greptile-apps avatar Jul 23 '26 10:07 greptile-apps

Thanks for the review threads — addressed in d928b2c and 7777b4d:

  • Added real --url / --url= tests that assert the full query string (including &) survives parsing via the DNS error echo path.
  • Documented the inline --url=<value> form in --help and the Options list.
  • Fixed detect --help when a bare --url is present (7777b4d).

Resolved the open Copilot threads on my side. Let me know if anything else is needed.

Stan Shih (stantheman0128)

stantheman0128 avatar Jul 28 '26 17:07 stantheman0128

Hi @pbakaus — quick status ping when you have a moment.

Both Copilot review threads are resolved (fixes in 7777b4d). The waiting on contributor / blocked: review threads labels may be stale. Happy to push anything else you want before merge.

Stan Shih (@stantheman0128)

stantheman0128 avatar Jul 29 '26 03:07 stantheman0128

Hi @stantheman0128

Thank you for your work

Unfortunately, issue #403 was not approved for PR, its against the repository policy to open PRs if unapproved.

Please continue discussion and suggest fixes on #403 . Once a maintainer approves the issue, you can reopen.

abdulwahabone avatar Jul 30 '26 11:07 abdulwahabone