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
13 changes: 5 additions & 8 deletions .goreleaser-macos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,11 @@ brews:
install: |
bin.install "egressor"
pkgshare.install "config.yaml"
post_install: |
egressor_dir = Pathname.new("#{Dir.home}/.egressor")
egressor_dir.mkpath
config_dest = egressor_dir/"config.yaml"
unless config_dest.exist?
cp pkgshare/"config.yaml", config_dest
ohai "Config installed to #{config_dest}"
end
caveats: |
Egressor will auto-create ~/.egressor/config.yaml on first run.
To set up TLS interception, run:
egressor --generate-ca
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ~/.egressor/ca.pem
service: |
run [opt_bin/"egressor", "--headless"]
keep_alive true
Expand Down
31 changes: 30 additions & 1 deletion cmd/egressor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,29 @@ func fileExists(path string) bool {
return err == nil
}

const defaultConfig = `listen_address: "127.0.0.1:8080"

policy:
deny_file_patterns:
- "*.env"
- "*.pem"
- "*.key"
- "**/secrets/**"
- "**/credentials*"
- ".aws/*"

logging:
format: json
file: ~/.egressor/logs/audit.log
max_size_mb: 2

intercept:
ca_cert: ~/.egressor/ca.pem
ca_key: ~/.egressor/ca-key.pem
log_body: true
max_body_size: 1048576
`

func resolveConfigPath(explicit string) string {
if explicit != "" {
return explicit
Expand All @@ -123,8 +146,14 @@ func resolveConfigPath(explicit string) string {
if _, err := os.Stat(p); err == nil {
return p
}
// 3. Auto-create default config at ~/.egressor/config.yaml
if err := os.MkdirAll(filepath.Dir(p), 0o755); err == nil {
if err := os.WriteFile(p, []byte(defaultConfig), 0o644); err == nil {
fmt.Printf(" Default config created at %s\n\n", p)
return p
}
}
}
// Fall back to ./config.yaml (will produce a clear error on load)
return "config.yaml"
}

Expand Down
Loading