High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
fix: remove recoveryMiddleware and fix gosec G204
Bosch109949fec336
diff --git a/cmd/pinchtab/cmd_bridge.go b/cmd/pinchtab/cmd_bridge.goindex d037713e..f6e56598 100644--- a/cmd/pinchtab/cmd_bridge.go+++ b/cmd/pinchtab/cmd_bridge.go@@ -2,7 +2,6 @@ package mainimport ("context"- "fmt""log/slog""net/http""os"@@ -46,7 +45,7 @@ func runBridgeServer(cfg *config.RuntimeConfig) {// HTTP serverserver := &http.Server{Addr: listenAddr,- Handler: handlers.RequestIDMiddleware(handlers.LoggingMiddleware(recoveryMiddleware(handlers.AuthMiddleware(cfg, mux)))),+ Handler: handlers.RequestIDMiddleware(handlers.LoggingMiddleware(handlers.AuthMiddleware(cfg, mux))),ReadHeaderTimeout: 10 * time.Second,ReadTimeout: 30 * time.Second,WriteTimeout: 60 * time.Second,@@ -74,25 +73,3 @@ func runBridgeServer(cfg *config.RuntimeConfig) {slog.Error("shutdown error", "err", err)}}--// recoveryMiddleware catches panics in HTTP handlers and returns a 500-// instead of crashing the bridge process. Go's net/http server only-// recovers panics in the serve goroutine; this middleware provides the-// same guarantee for the handler level and logs the panic for debugging.-func recoveryMiddleware(next http.Handler) http.Handler {- return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {- defer func() {- if p := recover(); p != nil {- handlers.RecordRecoveredPanic()- slog.Error("handler panic recovered",- "requestId", w.Header().Get("X-Request-Id"),- "method", r.Method,- "path", r.URL.Path,- "panic", fmt.Sprintf("%v", p),- )- http.Error(w, `{"error":"internal server error"}`, http.StatusInternalServerError)- }- }()- next.ServeHTTP(w, r)- })-}diff --git a/internal/handlers/metrics.go b/internal/handlers/metrics.goindex 35b7c474..c8a36065 100644--- a/internal/handlers/metrics.go+++ b/internal/handlers/metrics.go@@ -35,7 +35,6 @@ func SnapshotMetrics() map[string]any {return map[string]any{"requestsTotal": total,"requestsFailed": failed,- "panicsRecovered": atomic.LoadUint64(&metricPanicsRecovered),"avgLatencyMs": avgMs,"rateLimited": atomic.LoadUint64(&metricRateLimited),"staleRefRetries": atomic.LoadUint64(&metricStaleRefRetries),diff --git a/internal/handlers/middleware.go b/internal/handlers/middleware.goindex a5fed666..088fe5f4 100644--- a/internal/handlers/middleware.go+++ b/internal/handlers/middleware.go@@ -22,7 +22,6 @@ var (metricRequestLatencyN uint64metricRateLimited uint64metricStaleRefRetries uint64- metricPanicsRecovered uint64)func LoggingMiddleware(next http.Handler) http.Handler {diff --git a/internal/handlers/observability.go b/internal/handlers/observability.goindex c9f92cc4..caa15293 100644--- a/internal/handlers/observability.go+++ b/internal/handlers/observability.go@@ -33,11 +33,6 @@ func recordFailureEvent(ev FailureEvent) {}}-// RecordRecoveredPanic increments recovered panic monitoring for bridge HTTP handlers.-func RecordRecoveredPanic() {- atomic.AddUint64(&metricPanicsRecovered, 1)-}-// FailureSnapshot returns recent failure diagnostics for /health and /metrics.func FailureSnapshot() map[string]any {failureMu.Lock()@@ -45,9 +40,8 @@ func FailureSnapshot() map[string]any {failureMu.Unlock()return map[string]any{- "requestsFailed": atomic.LoadUint64(&metricRequestsFailed),- "panicsRecovered": atomic.LoadUint64(&metricPanicsRecovered),- "recent": recent,+ "requestsFailed": atomic.LoadUint64(&metricRequestsFailed),+ "recent": recent,}}@@ -55,9 +49,7 @@ func hasFailureDiagnostics() bool {failureMu.Lock()recentCount := len(recentFailures)failureMu.Unlock()- return atomic.LoadUint64(&metricRequestsFailed) > 0 ||- atomic.LoadUint64(&metricPanicsRecovered) > 0 ||- recentCount > 0+ return atomic.LoadUint64(&metricRequestsFailed) > 0 || recentCount > 0}func resetObservabilityForTests() {@@ -66,7 +58,6 @@ func resetObservabilityForTests() {atomic.StoreUint64(&metricRequestLatencyN, 0)atomic.StoreUint64(&metricRateLimited, 0)atomic.StoreUint64(&metricStaleRefRetries, 0)- atomic.StoreUint64(&metricPanicsRecovered, 0)failureMu.Lock()recentFailures = nilfailureMu.Unlock()diff --git a/internal/orchestrator/runner.go b/internal/orchestrator/runner.goindex ee82bbea..6f9c644f 100644--- a/internal/orchestrator/runner.go+++ b/internal/orchestrator/runner.go@@ -26,7 +26,7 @@ type localCmd struct {func (r *LocalRunner) Run(ctx context.Context, binary string, args []string, env []string, stdout, stderr io.Writer) (Cmd, error) {runCtx, cancel := context.WithCancel(ctx)- cmd := exec.CommandContext(runCtx, binary, args...)+ cmd := exec.CommandContext(runCtx, binary, args...) // #nosec G204 -- binary is the pinchtab executable path, args are internal subcommandscmd.Env = envcmd.Stdout = stdoutcmd.Stderr = stderr