@@ -2,6 +2,7 @@ package main
22
33import (
44"context"
5+ cryptotls "crypto/tls"
56"fmt"
67"log/slog"
78"os"
@@ -10,72 +11,70 @@ import (
1011"strings"
1112"syscall"
1213"time"
13- cryptotls "crypto/tls"
14-
15- "boundary/netjail"
16- "boundary/proxy"
17- "boundary/rules"
18- "boundary/tls"
1914
15+ "github.com/coder/jail/netjail"
16+ "github.com/coder/jail/proxy"
17+ "github.com/coder/jail/rules"
18+ "github.com/coder/jail/tls"
2019"github.com/coder/serpent"
2120)
2221
2322var (
24- allowStrings []string
25- noTLSIntercept bool
26- logLevel string
27- noJailCleanup bool
23+ allowStrings []string
24+ noTLSIntercept bool
25+ logLevel string
26+ noJailCleanup bool
2827)
2928
3029func main () {
3130cmd := & serpent.Command {
32- Use : "boundary [flags] -- command [args...]" ,
31+ Use : "jail [flags] -- command [args...]" ,
3332Short : "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,
3534intercepting all HTTP/HTTPS traffic through a transparent proxy that enforces
3635user-defined rules.
3736
3837Examples:
3938 # Allow only requests to github.com
40- boundary --allow "github.com" -- curl https://github.com
39+ jail --allow "github.com" -- curl https://github.com
4140
4241 # 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
4443
4544 # Block everything by default (implicit)` ,
4645Options : serpent.OptionSet {
4746{
4847Name : "allow" ,
4948Flag : "allow" ,
50- Env : "BOUNDARY_ALLOW " ,
49+ Env : "JAIL_ALLOW " ,
5150Description : "Allow rule (can be specified multiple times). Format: 'pattern' or 'METHOD[,METHOD] pattern'." ,
5251Value : serpent .StringArrayOf (& allowStrings ),
5352},
5453{
5554Name : "no-tls-intercept" ,
5655Flag : "no-tls-intercept" ,
57- Env : "BOUNDARY_NO_TLS_INTERCEPT " ,
56+ Env : "JAIL_NO_TLS_INTERCEPT " ,
5857Description : "Disable HTTPS interception." ,
5958Value : serpent .BoolOf (& noTLSIntercept ),
6059},
6160{
6261Name : "log-level" ,
6362Flag : "log-level" ,
64- Env : "BOUNDARY_LOG_LEVEL " ,
63+ Env : "JAIL_LOG_LEVEL " ,
6564Description : "Set log level (error, warn, info, debug)." ,
6665Default : "warn" ,
6766Value : serpent .StringOf (& logLevel ),
6867},
6968{
7069Name : "no-jail-cleanup" ,
7170Flag : "no-jail-cleanup" ,
72- Env : "BOUNDARY_NO_JAIL_CLEANUP " ,
71+ Env : "JAIL_NO_JAIL_CLEANUP " ,
7372Description : "Skip jail cleanup (hidden flag for testing)." ,
7473Value : serpent .BoolOf (& noJailCleanup ),
7574Hidden : true ,
7675},
7776},
78- Handler : runBoundary ,
77+ Handler : runJail ,
7978}
8079
8180err := cmd .Invoke ().WithOS ().Run ()
@@ -108,7 +107,7 @@ func setupLogging(logLevel string) *slog.Logger {
108107return slog .New (handler )
109108}
110109
111- func runBoundary (inv * serpent.Invocation ) error {
110+ func runJail (inv * serpent.Invocation ) error {
112111logger := setupLogging (logLevel )
113112
114113// Get command arguments
@@ -172,21 +171,21 @@ func runBoundary(inv *serpent.Invocation) error {
172171
173172// Set standard CA certificate environment variables for common tools
174173// 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
182181}
183182
184183// Create network jail configuration
185184netjailConfig := 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 ,
190189}
191190
192191// Create network jail
@@ -274,4 +273,4 @@ func runBoundary(inv *serpent.Invocation) error {
274273}
275274
276275return nil
277- }
276+ }
0 commit comments