@@ -2,6 +2,7 @@ package main
2
2
3
3
import (
4
4
"context"
5
+ cryptotls "crypto/tls"
5
6
"fmt"
6
7
"log/slog"
7
8
"os"
@@ -10,72 +11,70 @@ import (
10
11
"strings"
11
12
"syscall"
12
13
"time"
13
- cryptotls "crypto/tls"
14
-
15
- "boundary/netjail"
16
- "boundary/proxy"
17
- "boundary/rules"
18
- "boundary/tls"
19
14
15
+ "github.com/coder/jail/netjail"
16
+ "github.com/coder/jail/proxy"
17
+ "github.com/coder/jail/rules"
18
+ "github.com/coder/jail/tls"
20
19
"github.com/coder/serpent"
21
20
)
22
21
23
22
var (
24
- allowStrings []string
25
- noTLSIntercept bool
26
- logLevel string
27
- noJailCleanup bool
23
+ allowStrings []string
24
+ noTLSIntercept bool
25
+ logLevel string
26
+ noJailCleanup bool
28
27
)
29
28
30
29
func main () {
31
30
cmd := & serpent.Command {
32
- Use : "boundary [flags] -- command [args...]" ,
31
+ Use : "jail [flags] -- command [args...]" ,
33
32
Short : "Monitor and restrict HTTP/HTTPS requests from processes" ,
34
- Long : `boundary creates an isolated network environment for the target process,
33
+ Long : `jail creates an isolated network environment for the target process,
35
34
intercepting all HTTP/HTTPS traffic through a transparent proxy that enforces
36
35
user-defined rules.
37
36
38
37
Examples:
39
38
# Allow only requests to github.com
40
- boundary --allow "github.com" -- curl https://github.com
39
+ jail --allow "github.com" -- curl https://github.com
41
40
42
41
# Monitor all requests to specific domains (allow only those)
43
- boundary --allow "github.com/api/issues/*" --allow "GET,HEAD github.com" -- npm install
42
+ jail --allow "github.com/api/issues/*" --allow "GET,HEAD github.com" -- npm install
44
43
45
44
# Block everything by default (implicit)` ,
46
45
Options : serpent.OptionSet {
47
46
{
48
47
Name : "allow" ,
49
48
Flag : "allow" ,
50
- Env : "BOUNDARY_ALLOW " ,
49
+ Env : "JAIL_ALLOW " ,
51
50
Description : "Allow rule (can be specified multiple times). Format: 'pattern' or 'METHOD[,METHOD] pattern'." ,
52
51
Value : serpent .StringArrayOf (& allowStrings ),
53
52
},
54
53
{
55
54
Name : "no-tls-intercept" ,
56
55
Flag : "no-tls-intercept" ,
57
- Env : "BOUNDARY_NO_TLS_INTERCEPT " ,
56
+ Env : "JAIL_NO_TLS_INTERCEPT " ,
58
57
Description : "Disable HTTPS interception." ,
59
58
Value : serpent .BoolOf (& noTLSIntercept ),
60
59
},
61
60
{
62
61
Name : "log-level" ,
63
62
Flag : "log-level" ,
64
- Env : "BOUNDARY_LOG_LEVEL " ,
63
+ Env : "JAIL_LOG_LEVEL " ,
65
64
Description : "Set log level (error, warn, info, debug)." ,
66
65
Default : "warn" ,
67
66
Value : serpent .StringOf (& logLevel ),
68
67
},
69
68
{
70
69
Name : "no-jail-cleanup" ,
71
70
Flag : "no-jail-cleanup" ,
72
- Env : "BOUNDARY_NO_JAIL_CLEANUP " ,
71
+ Env : "JAIL_NO_JAIL_CLEANUP " ,
73
72
Description : "Skip jail cleanup (hidden flag for testing)." ,
74
73
Value : serpent .BoolOf (& noJailCleanup ),
75
74
Hidden : true ,
76
75
},
77
76
},
78
- Handler : runBoundary ,
77
+ Handler : runJail ,
79
78
}
80
79
81
80
err := cmd .Invoke ().WithOS ().Run ()
@@ -108,7 +107,7 @@ func setupLogging(logLevel string) *slog.Logger {
108
107
return slog .New (handler )
109
108
}
110
109
111
- func runBoundary (inv * serpent.Invocation ) error {
110
+ func runJail (inv * serpent.Invocation ) error {
112
111
logger := setupLogging (logLevel )
113
112
114
113
// Get command arguments
@@ -172,21 +171,21 @@ func runBoundary(inv *serpent.Invocation) error {
172
171
173
172
// Set standard CA certificate environment variables for common tools
174
173
// This makes tools like curl, git, etc. trust our dynamically generated CA
175
- extraEnv ["SSL_CERT_FILE" ] = caCertPath // OpenSSL/LibreSSL-based tools
176
- extraEnv ["SSL_CERT_DIR" ] = configDir // OpenSSL certificate directory
177
- extraEnv ["CURL_CA_BUNDLE" ] = caCertPath // curl
178
- extraEnv ["GIT_SSL_CAINFO" ] = caCertPath // Git
179
- extraEnv ["REQUESTS_CA_BUNDLE" ] = caCertPath // Python requests
180
- extraEnv ["NODE_EXTRA_CA_CERTS" ] = caCertPath // Node.js
181
- extraEnv ["BOUNDARY_CA_CERT " ] = string (caCertPEM ) // Keep for backward compatibility
174
+ extraEnv ["SSL_CERT_FILE" ] = caCertPath // OpenSSL/LibreSSL-based tools
175
+ extraEnv ["SSL_CERT_DIR" ] = configDir // OpenSSL certificate directory
176
+ extraEnv ["CURL_CA_BUNDLE" ] = caCertPath // curl
177
+ extraEnv ["GIT_SSL_CAINFO" ] = caCertPath // Git
178
+ extraEnv ["REQUESTS_CA_BUNDLE" ] = caCertPath // Python requests
179
+ extraEnv ["NODE_EXTRA_CA_CERTS" ] = caCertPath // Node.js
180
+ extraEnv ["JAIL_CA_CERT " ] = string (caCertPEM ) // Keep for backward compatibility
182
181
}
183
182
184
183
// Create network jail configuration
185
184
netjailConfig := netjail.Config {
186
- HTTPPort : 8040 ,
187
- HTTPSPort : 8043 ,
188
- NetJailName : "boundary " ,
189
- SkipCleanup : noJailCleanup ,
185
+ HTTPPort : 8040 ,
186
+ HTTPSPort : 8043 ,
187
+ NetJailName : "jail " ,
188
+ SkipCleanup : noJailCleanup ,
190
189
}
191
190
192
191
// Create network jail
@@ -274,4 +273,4 @@ func runBoundary(inv *serpent.Invocation) error {
274
273
}
275
274
276
275
return nil
277
- }
276
+ }
0 commit comments