Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c555f2f

Browse files
committed
use new jail base command and make subcommand properly hidden
1 parent 9911415 commit c555f2f

File tree

3 files changed

+7
-42
lines changed

3 files changed

+7
-42
lines changed

cli/jail.go

Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,43 +6,8 @@ import (
66
)
77

88
func (r *RootCmd) jail() *serpent.Command {
9-
var config jailcli.Config
10-
11-
return &serpent.Command{
12-
Use: "jail -- <command>",
13-
Short: "Monitor and restrict HTTP/HTTPS requests from processes",
14-
Long: `coder jail creates an isolated network environment for the target process,
15-
intercepting all HTTP/HTTPS traffic through a transparent proxy that enforces
16-
user-defined rules.
17-
18-
Examples:
19-
# Allow only requests to github.com
20-
coder jail --allow "github.com" -- curl https://github.com
21-
22-
# Monitor all requests to specific domains (allow only those)
23-
coder jail --allow "github.com/api/issues/*" --allow "GET,HEAD github.com" -- npm install
24-
25-
# Block everything by default (implicit)`,
26-
Options: serpent.OptionSet{
27-
{
28-
Name: "allow",
29-
Flag: "allow",
30-
Env: "JAIL_ALLOW",
31-
Description: "Allow rule (can be specified multiple times). Format: 'pattern' or 'METHOD[,METHOD] pattern'.",
32-
Value: serpent.StringArrayOf(&config.AllowStrings),
33-
},
34-
{
35-
Name: "log-level",
36-
Flag: "log-level",
37-
Env: "JAIL_LOG_LEVEL",
38-
Description: "Set log level (error, warn, info, debug).",
39-
Default: "warn",
40-
Value: serpent.StringOf(&config.LogLevel),
41-
},
42-
},
43-
Hidden: true,
44-
Handler: func(inv *serpent.Invocation) error {
45-
return jailcli.Run(inv.Context(), config, inv.Args)
46-
},
47-
}
9+
cmd := jailcli.BaseCommand() // Package coder/jail/cli exports a "base command" designed to be integrated as a subcommand.
10+
cmd.Hidden = true // We want jail to be a hidden command in coder for now.
11+
cmd.Use += " [args...]" // The base command looks like `jail -- command`. Serpent adds the flags piece, but we need to add the args.
12+
return cmd
4813
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ require (
479479
github.com/brianvoe/gofakeit/v7 v7.5.1
480480
github.com/coder/agentapi-sdk-go v0.0.0-20250505131810-560d1d88d225
481481
github.com/coder/aisdk-go v0.0.9
482-
github.com/coder/jail v1.0.1-0.20250911203532-70677f27857e
482+
github.com/coder/jail v1.0.1-0.20250912153404-1e687be21fb5
483483
github.com/coder/preview v1.0.4
484484
github.com/fsnotify/fsnotify v1.9.0
485485
github.com/go-git/go-git/v5 v5.16.2

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -922,10 +922,10 @@ github.com/coder/go-scim/pkg/v2 v2.0.0-20230221055123-1d63c1222136 h1:0RgB61LcNs
922922
github.com/coder/go-scim/pkg/v2 v2.0.0-20230221055123-1d63c1222136/go.mod h1:VkD1P761nykiq75dz+4iFqIQIZka189tx1BQLOp0Skc=
923923
github.com/coder/guts v1.5.0 h1:a94apf7xMf5jDdg1bIHzncbRiTn3+BvBZgrFSDbUnyI=
924924
github.com/coder/guts v1.5.0/go.mod h1:0Sbv5Kp83u1Nl7MIQiV2zmacJ3o02I341bkWkjWXSUQ=
925-
github.com/coder/jail v1.0.0 h1:HM8Bo5RlBbXeGJ4YIvNI/c0M9P9jE3h6gkWKxkPOTIo=
926-
github.com/coder/jail v1.0.0/go.mod h1:nWzW7Mlw6ucIIfxBVUaMrV4uwcBJ0vUId6xkm5lZ7j0=
927925
github.com/coder/jail v1.0.1-0.20250911203532-70677f27857e h1:hvqfdtxBJL3FavB0pb0H3JXmj8uFGRCxreHd5HyztdM=
928926
github.com/coder/jail v1.0.1-0.20250911203532-70677f27857e/go.mod h1:JrRS7QEvzNFLPjUcgVs9IjewlJmk4Ia9c4CatZfl0A8=
927+
github.com/coder/jail v1.0.1-0.20250912153404-1e687be21fb5 h1:CmGiqeVtb1tNlLxwlNKAGbGKwOfIBoeyFJCwONYZxf4=
928+
github.com/coder/jail v1.0.1-0.20250912153404-1e687be21fb5/go.mod h1:JrRS7QEvzNFLPjUcgVs9IjewlJmk4Ia9c4CatZfl0A8=
929929
github.com/coder/pq v1.10.5-0.20250807075151-6ad9b0a25151 h1:YAxwg3lraGNRwoQ18H7R7n+wsCqNve7Brdvj0F1rDnU=
930930
github.com/coder/pq v1.10.5-0.20250807075151-6ad9b0a25151/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
931931
github.com/coder/pretty v0.0.0-20230908205945-e89ba86370e0 h1:3A0ES21Ke+FxEM8CXx9n47SZOKOpgSE1bbJzlE4qPVs=

0 commit comments

Comments
 (0)