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

Skip to content

Commit 65d5092

Browse files
committed
initial coder jail hidden subcommand
1 parent e53bc24 commit 65d5092

File tree

4 files changed

+52
-1
lines changed

4 files changed

+52
-1
lines changed

cli/jail.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package cli
2+
3+
import (
4+
jailcli "github.com/coder/jail/cli"
5+
"github.com/coder/serpent"
6+
)
7+
8+
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+
Handler: func(inv *serpent.Invocation) error {
44+
return jailcli.Run(config, inv.Args)
45+
},
46+
}
47+
}

cli/root.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ func (r *RootCmd) CoreSubcommands() []*serpent.Command {
130130
r.connectCmd(),
131131
r.expCmd(),
132132
gitssh(),
133+
r.jail(),
133134
r.support(),
134135
r.vpnDaemon(),
135136
r.vscodeSSH(),

go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/coder/coder/v2
22

3-
go 1.24.6
3+
go 1.25
44

55
// Required until a v3 of chroma is created to lazily initialize all XML files.
66
// None of our dependencies seem to use the registries anyways, so this
@@ -510,6 +510,7 @@ require (
510510
github.com/cenkalti/backoff/v5 v5.0.2 // indirect
511511
github.com/charmbracelet/x/exp/slice v0.0.0-20250327172914-2fdc97757edf // indirect
512512
github.com/cncf/xds/go v0.0.0-20250501225837-2ac532fd4443 // indirect
513+
github.com/coder/jail v1.0.0 // indirect
513514
github.com/dgryski/go-farm v0.0.0-20240924180020-3414d57e47da // indirect
514515
github.com/envoyproxy/go-control-plane/envoy v1.32.4 // indirect
515516
github.com/envoyproxy/protoc-gen-validate v1.2.1 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,8 @@ 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=
925927
github.com/coder/pq v1.10.5-0.20250807075151-6ad9b0a25151 h1:YAxwg3lraGNRwoQ18H7R7n+wsCqNve7Brdvj0F1rDnU=
926928
github.com/coder/pq v1.10.5-0.20250807075151-6ad9b0a25151/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
927929
github.com/coder/pretty v0.0.0-20230908205945-e89ba86370e0 h1:3A0ES21Ke+FxEM8CXx9n47SZOKOpgSE1bbJzlE4qPVs=

0 commit comments

Comments
 (0)