Repository navigation
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
agammann
left a comment
There was a problem hiding this comment.
One API-surface suggestion: lib/mod.rs makes the entire dns_server module public solely so the binary can call is_valid_vm_name. Could we keep mod dns_server; private and re-export just the helper (pub use dns_server::is_valid_vm_name;), with src/main.rs importing it from softnet? That preserves the existing module boundary while still sharing the exact validator between the CLI, RPC parser, and DNS server.
…ing dns_server module
|
Updated in b7ca52b: kept \dns_server\ private in \lib/mod.rs\ and re-exported \is_valid_vm_name\ from the crate root via \pub use dns_server::is_valid_vm_name;, with \src/main.rs\ importing from \softnet::is_valid_vm_name. Thanks for the suggestion! |
Summary
Add early validation of the
--vm-nameCLI argument and the JSON-RPCnamefield insoftnet.initialize, ensuring invalid VM names are rejected before startup / manager dispatch.Problem
Softnet's DNS server (
DnsServer::new) enforces that VM names must be single-label (no dots), non-FQDN, and non-wildcard. However, neither the CLI--vm-nameargument nor the JSON-RPCsoftnet.initializenamefield validated this constraint at parse time. This meant:--vm-name foo.baraccepted the argument, started the process, and only then crashed inside manager initialization withinvalid VM name foo.bar: expected a single DNS label.softnet.initializecall with"name": "foo.bar"was dispatched to the manager and returned aCALL_EXECUTION_FAILED_CODE(-32000) instead of the expectedINVALID_PARAMS_CODE(-32602).Solution
lib/dns_server/mod.rs: Extracted the single-label validation into a new publicis_valid_vm_name()helper function. Also refactoredDnsServer::newto use it instead of an inline check.lib/mod.rs: Made thedns_servermodulepubsosrc/main.rscan import the helper.lib/control.rs: Importedis_valid_vm_nameand applied it inparse_initializewhen parsing the optional VMnamefield, returningINVALID_PARAMS_CODEon failure.src/main.rs: Replaced the inline|value: &str| Name::from_ascii(value)lambda with a dedicatedparse_vm_namefunction that also callsis_valid_vm_name, producing a clearclaperror before startup.Testing
src/main.rs:test_cli_rejects_multi_label_vm_name_before_startup: verifiesfoo.bar,foo.internal., and*.fooall fail during argument parsing with an appropriate error message.test_cli_accepts_single_label_vm_name: verifies a valid single-label name likemyvmis accepted.rejects_invalid_initialization_and_closes_every_descriptortest inlib/control_test.rs:foo.bar→INVALID_PARAMS_CODE.foo.internal.→INVALID_PARAMS_CODE.Tests run via CI (macOS-only build/test environment); the local environment is Windows and does not have a Rust toolchain installed.
Related Issue
Closes #233