Skip to content

Commit efb533e

Browse files
authored
Merge pull request #29 from tstromberg/main
Allow all events by default
2 parents f606185 + f7d991f commit efb533e

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

cmd/server/main.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ const (
3232
minMaskHeaderLength = 20 // Minimum header length before we show full "[REDACTED]"
3333
)
3434

35+
// getEnvOrDefault returns the value of the environment variable or the default if not set
36+
func getEnvOrDefault(key, defaultValue string) string {
37+
if value := os.Getenv(key); value != "" {
38+
return value
39+
}
40+
return defaultValue
41+
}
42+
3543
var (
3644
webhookSecret = flag.String("webhook-secret", os.Getenv("GITHUB_WEBHOOK_SECRET"), "GitHub webhook secret for signature verification")
3745
addr = flag.String("addr", ":8080", "HTTP service address")
@@ -42,8 +50,8 @@ var (
4250
maxConnsPerIP = flag.Int("max-conns-per-ip", 10, "Maximum WebSocket connections per IP")
4351
maxConnsTotal = flag.Int("max-conns-total", 1000, "Maximum total WebSocket connections")
4452
rateLimit = flag.Int("rate-limit", 100, "Maximum requests per minute per IP")
45-
allowedEvents = flag.String("allowed-events", os.Getenv("ALLOWED_WEBHOOK_EVENTS"),
46-
"Comma-separated list of allowed webhook event types (use '*' for all)")
53+
allowedEvents = flag.String("allowed-events", getEnvOrDefault("ALLOWED_WEBHOOK_EVENTS", "*"),
54+
"Comma-separated list of allowed webhook event types (use '*' for all, default: '*')")
4755
debugHeaders = flag.Bool("debug-headers", false, "Log request headers for debugging (security warning: may log sensitive data)")
4856
)
4957

@@ -62,13 +70,6 @@ func main() {
6270
log.Fatal("ERROR: Webhook secret is required for security. Set -webhook-secret or GITHUB_WEBHOOK_SECRET environment variable.")
6371
}
6472

65-
// Validate allowed events is configured (REQUIRED)
66-
if *allowedEvents == "" {
67-
cancel()
68-
log.Fatal("ERROR: Allowed events must be specified. Set -allowed-events or " +
69-
"ALLOWED_WEBHOOK_EVENTS environment variable. Use '*' to allow all events.")
70-
}
71-
7273
// Parse allowed events
7374
var allowedEventTypes []string
7475
if *allowedEvents == "*" {

0 commit comments

Comments
 (0)