Skip to content

feat(server): unify scan target param on target, keep url as REST alias#1152

Merged
hahwul merged 2 commits into
mainfrom
feat/unify-scan-target-param
Jun 15, 2026
Merged

feat(server): unify scan target param on target, keep url as REST alias#1152
hahwul merged 2 commits into
mainfrom
feat/unify-scan-target-param

Conversation

@hahwul

@hahwul hahwul commented Jun 15, 2026

Copy link
Copy Markdown
Owner

Summary

Follow-up to the dogfooding finding that REST and MCP named the scan target differently. The MCP scan_with_dalfox tool and every response payload (ResultPayload.target, the submit {scan_id, target}) used target, but the REST request body and query string used url. Anyone wiring up both surfaces hit the mismatch.

Per the decision: standardize on target, keep url working for existing REST clients.

Changes

  • ScanRequest.urltarget with #[serde(alias = "url")] — POST /scan and POST /preflight accept {"target": ...} (canonical) or {"url": ...} (alias).
  • GET /scan reads the target query param, falling back to url.
  • MCP already used target — unchanged.
  • Docs (integrations/server.md) show target, with the url alias noted.

Backwards compatible: every existing client sending url (JSON body or query string) keeps working; response shapes are unchanged.

Verification (live server)

request result
POST /scan {"target":...} scan_id ✓
POST /scan {"url":...} (alias) scan_id ✓
GET /scan?target=... scan_id ✓
GET /scan?url=... (alias) scan_id ✓
POST /scan {"options":{}} (no target) 400 ✓
POST /preflight {"target":...} 200, params discovered ✓

Testing

  • cargo build / cargo clippy --all-targets clean
  • cargo test --lib — 1765 pass (added test_scan_request_accepts_target_canonical_and_url_alias, test_get_scan_handler_accepts_target_query_param)

… alias

The scan target was named inconsistently across surfaces: the MCP
`scan_with_dalfox` tool and every response payload (`ResultPayload.target`,
the submit `{scan_id, target}`) used `target`, but the REST request body and
query string used `url`. Anyone wiring up both surfaces hit the mismatch.

Standardize on `target` and keep `url` working for existing REST clients:
- `ScanRequest.url` → `target` with `#[serde(alias = "url")]`, so POST `/scan`
  and POST `/preflight` accept `{"target": ...}` (canonical) or `{"url": ...}`.
- GET `/scan` reads the `target` query param, falling back to `url`.
- MCP already used `target` — unchanged.

Backwards compatible: every existing client sending `url` (JSON body or query
string) keeps working; responses are unchanged.

Verified end-to-end against a live server: POST/GET with `target` and with the
`url` alias all return a scan_id, `/preflight` with `target` works, and a body
with neither field is a 400. Docs (integrations/server.md) updated to show
`target` with the alias noted; added serde-alias + GET-`target` unit tests.
@codecov

codecov Bot commented Jun 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Address the one behavior-change the review surfaced: a present-but-empty
`target` query param (e.g. a templated `?target=&url=...`) shadowed a real
`url` and 400'd. Filter empty target before the alias fallback so any caller
still sending `url` keeps working. Covered with a test.
@hahwul hahwul merged commit 3424201 into main Jun 15, 2026
13 checks passed
@hahwul hahwul deleted the feat/unify-scan-target-param branch June 15, 2026 08:26
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.

1 participant