fix: disable generic root requests - #37
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR tightens the dci CLI’s “locked-down” command surface by removing restish’s generic root request behavior, ensuring that the root command can’t be used as an ad-hoc HTTP client and instead only renders local help.
Changes:
- Disable generic root execution by forcing
cli.Rootto accept no positional operands and to render help via a safe handler. - Remove any root-level “hostname” completion hook by clearing
cli.Root.ValidArgsFunction. - Add a regression test to ensure the generic root request handler and hostname completion are not left installed.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| main.go | Hardens the root command (cli.Root) by disabling generic request execution and positional operands, and clearing root arg completion. |
| main_test.go | Adds a regression test asserting the generic root handler and hostname completion are removed and that root operands are rejected. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
chaim0m
force-pushed
the
codex/dci-root-argument-lock
branch
from
August 3, 2026 17:05
382b62b to
4f7df73
Compare
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.
Summary
dciroot commandThis is the focused follow-up to the root-cause gap Alfredo identified in his review of #36. It addresses note 2 only and is independently based on
main; it does not contain or depend on thedci versionpoint fix.Root cause
Restish installs a generic root
Runhandler that treatsargs[0]as a hostname. DCI removes the visible generic commands, but previously left that root handler and its positional-argument contract intact. An argument that bypassed command normalization—such asdci ""—could therefore initiate a generic request, with the activecustomerContextalready attached.The root command now accepts no operands and can only render local help. Generated DCI API subcommands and local commands continue to execute through their own handlers.
Test methods
The smoke test exits locally with
unknown command ""; it emits no URL, DNS lookup, or network error. A regression test verifies that the generic request handler and hostname completion are removed and that an empty root operand is rejected.Could this break things?
Risk: low-medium, intentionally restrictive. Anyone relying on the DCI binary as restish's undocumented generic HTTP client will no longer be able to make arbitrary-host requests through the root command. That behavior conflicts with DCI's locked command surface. Registered DCI API commands, local commands, help, and completion remain supported.
Jira
CMP-48648