FIX: Accept local HTTP URLs for CLI --start-server#2212
Merged
romanlutz merged 3 commits intoJul 17, 2026
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 52d2518d-ebe5-4888-8189-6146b6503448
behnam-o
approved these changes
Jul 16, 2026
jbolor21
reviewed
Jul 16, 2026
jbolor21
approved these changes
Jul 16, 2026
Addresses review feedback on PR microsoft#2212: urllib.parse.urlparse is lightweight stdlib, so it belongs with the other top-level stdlib imports rather than being imported lazily inside functions. Removes the now-redundant function-local imports. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 259582f9-eccd-4fe6-93cb-21597e8bb54c
romanlutz
enabled auto-merge
July 17, 2026 14:07
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
pyrit_scan --start-serverpreviously refused to launch the bundled backend unless the resolved server URL was exactly the launcher default (http://localhost:8000). Anyone who set--server-urlor aserver.urlconfig entry to a different local port got an error telling them to start the backend manually, even though the launcher can bind a different local host/port just fine.This change relaxes the
--start-servervalidation to accept any plain local HTTP URL._resolve_server_url_asyncnow parses the resolved URL and allows it when:httplocalhostor127.0.0.1The parsed host and port are then forwarded to
ServerLauncher.start_async(host=..., port=...), so--start-serverhonors a custom local port instead of silently ignoring it. Non-local or otherwise non-plain URLs (remote hosts, embedded credentials, paths) still get a clear error directing the user to start a remote backend separately.Tests and Documentation
Unit tests in
tests/unit/cli/test_pyrit_scan.py:test_start_server_uses_custom_local_port, asserting the parsed host/port are forwarded tostart_async(host="127.0.0.1", port=8765).test_start_server_refuses_remote_urlto cover the rejection path.Ran JupyText on
doc/scanner/1_pyrit_scan.py, which exercisespyrit_scan --start-server. I also verified end to end that--start-servernow brings up the backend on a custom local URL/port (http://127.0.0.1:8137) that the previous code rejected, and stops cleanly via--stop-server.