Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ build-all:
.PHONY: test
test:
@echo "Running tests..."
sudo go test -v -race ./...
go test -v -race ./...
@echo "✓ All tests passed!"

# Run tests with coverage (needs sudo for E2E tests)
.PHONY: test-coverage
test-coverage:
@echo "Running tests with coverage..."
sudo go test -v -race -coverprofile=coverage.out ./...
go test -v -race -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
@echo "✓ Coverage report generated: coverage.html"

Expand Down
35 changes: 24 additions & 11 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,36 @@ type Config struct {

// NewCommand creates and returns the root serpent command
func NewCommand() *serpent.Command {
var config Config

return &serpent.Command{
Use: "jail [flags] -- command [args...]",
Short: "Monitor and restrict HTTP/HTTPS requests from processes",
Long: `jail creates an isolated network environment for the target process,
intercepting all HTTP/HTTPS traffic through a transparent proxy that enforces
user-defined rules.

Examples:
// To make the top level jail command, we just make some minor changes to the base command
cmd := BaseCommand()
cmd.Use = "jail [flags] -- command [args...]" // Add the flags and args pieces to usage.

// Add example usage to the long description. This is different from usage as a subcommand because it
// may be called something different when used as a subcommand / there will be a leading binary (i.e. `coder jail` vs. `jail`).
cmd.Long += `Examples:
# Allow only requests to github.com
jail --allow "github.com" -- curl https://github.com

# Monitor all requests to specific domains (allow only those)
jail --allow "github.com/api/issues/*" --allow "GET,HEAD github.com" -- npm install

# Block everything by default (implicit)`,
# Block everything by default (implicit)`

return cmd
}

// Base command returns the jail serpent command without the information involved in making it the
// *top level* serpent command. We are creating this split to make it easier to integrate into the coder
// cli without introducing sources of drift.
func BaseCommand() *serpent.Command {
var config Config

return &serpent.Command{
Use: "jail -- command",
Short: "Monitor and restrict HTTP/HTTPS requests from processes",
Long: `creates an isolated network environment for the target process,
intercepting all HTTP/HTTPS traffic through a transparent proxy that enforces
user-defined rules.`,
Options: serpent.OptionSet{
{
Name: "allow",
Expand Down
Loading