Commit Graph
293 Commits
Author SHA1 Message Date
lukaszraczyloandGitHub f93a0e2865 Update go.mod and go.sum (#103) 2026-10-03 04:14:32 +01:00
lukaszraczyloandGitHub 90a6b99bb3 Update go.mod and go.sum (#102) 2026-10-02 04:04:16 +01:00
lukaszraczyloandGitHub 503d09f479 Update go.mod and go.sum (#101) 2026-10-01 04:07:38 +01:00
lukaszraczyloandGitHub dc034fb0c7 Update go.mod and go.sum (#100) 2026-09-30 04:04:34 +01:00
lukaszraczyloandGitHub 6554da0d04 Update go.mod and go.sum (#99) 2026-09-29 04:03:21 +01:00
lukaszraczyloandGitHub 819a8e2315 Update go.mod and go.sum (#98) 2026-09-28 04:05:44 +01:00
lukaszraczyloandGitHub 85531966fe Update go.mod and go.sum (#96) 2026-09-26 04:03:07 +01:00
lukaszraczyloandGitHub af2f5d2f96 Update go.mod and go.sum (#95) 2026-09-25 04:03:16 +01:00
lukaszraczyloandGitHub b8f01567b7 Update go.mod and go.sum (#94) 2026-09-24 04:02:30 +01:00
lukaszraczyloandGitHub 8cf525c924 Update go.mod and go.sum (#93) 2026-09-22 04:02:34 +01:00
lukaszraczyloandGitHub cc35d3fc38 Update go.mod and go.sum (#92) 2026-09-19 04:03:22 +01:00
lukaszraczyloandGitHub 5882042a9d Update go.mod and go.sum (#91) 2026-09-18 04:02:26 +01:00
lukaszraczyloandGitHub e0ad34c513 Update go.mod and go.sum (#90) 2026-09-16 04:03:13 +01:00
lukaszraczyloandGitHub aa5167c42b Update go.mod and go.sum (#89) 2026-09-15 04:02:28 +01:00
lukaszraczyloandGitHub e2d151e9b7 Update go.mod and go.sum (#88) 2026-09-13 04:02:14 +01:00
lukaszraczylo 02d9796adb fix(deps): update dependencies and allow loopback upstreams on fiber v3.5.0
Update all direct and indirect Go dependencies. Notable bumps are
gofiber/fiber v3.4.0 to v3.5.0, gofiber/contrib websocket v1.2.0 to
v1.2.6, fasthttp v1.72.0 to v1.74.0, gookit/goutil v0.7.6 to v0.8.0,
go-redis v9.20.1 to v9.22.0, pgx v5.10.0 to v5.11.0, OpenTelemetry
v1.44.0 to v1.46.0, grpc v1.82.1 to v1.83.2 and testify v1.11.1 to
v1.12.1. The go directive moves to 1.26.0 because websocket v1.2.6
requires it.

fiber v3.5.0 adds an SSRF dial guard to clients registered with
proxy.WithClient. The guard rejects loopback and private upstreams by
default. This proxy gets its upstream from operator configuration, and
sidecar deployments point it at localhost. Set
proxy.SecurityPolicy{AllowPrivateIPs: true} so these upstreams keep
working. This change also unblocks the nightly autoupdate workflow,
which failed on this guard.

Claude-Session: https://claude.ai/code/session_01Fu2wXqGUrfVBi5aLafKk8U
2026-09-10 15:18:31 +01:00
lukaszraczylo 6e571f8fa0 fix(deps): bump gofiber/fiber to v3.4.0 for HSTS advisory fix (GHSA-gv83-gqw6-9j2c)
Fiber v3.3.0 and earlier never set the HSTS header in the helmet middleware (GHSA-gv83-gqw6-9j2c, GO-2026-5912). Version v3.4.0 fixes that and adds an open-redirect fix and X-Forwarded-For hardening. Version v3.4.0 does NOT contain the loopback SSRF block that v3.5.0 added to the proxy middleware, so the 127.0.0.1 backend behaviour is unchanged. The full race test suite, including the loopback proxy tests, passes. Transitive bumps: fasthttp v1.71.0 to v1.72.0, klauspost/compress to v1.19.0.
2026-08-17 19:47:30 +01:00
lukaszraczylo 3bce659203 fix(deps): bump klauspost/compress to v1.18.7 for s2 out-of-bounds read (GHSA-259r-337f-4rfw)
The indirect dependency github.com/klauspost/compress v1.18.6 contained an out-of-bounds read in the s2 package (GO-2026-5841). The proxy pulls this module in through valyala/fasthttp. govulncheck reports the vulnerable path as unreachable, so the real risk is low, but v1.18.7 removes the defect. The bump is a patch release with no API change.
2026-08-17 19:30:07 +01:00
lukaszraczylo 8258b3d99a fix(auth): verify JWT signature to prevent cache-key forgery (GHSA-9gqw-h2rw-44wv)
The proxy derived per-user GraphQL cache keys from JWT claims without
verifying the token signature (CWE-345). A remote attacker could forge a
token that carried a victim's claim value and read the victim's cached
response.

This change adds opt-in signature verification behind JWT_VERIFY_SIGNATURE.
The flag defaults to false, so an upgrade without a config change keeps the
previous delegate-to-upstream behavior byte for byte.

When verification is on, the operator must set exactly one key source:
JWT_SECRET, JWT_PUBLIC_KEY, or JWT_JWKS_URL. The verifier pins the accepted
algorithms to the key family through WithValidMethods and a type-switched
keyfunc, and it refuses alg=none. This closes the algorithm-confusion class
of attack. A present but invalid token now returns 401. A missing
Authorization header stays anonymous.

Startup fails loudly when verification is on and the key source is absent or
unreadable, so the proxy can never boot half-configured.
2026-08-17 13:51:00 +01:00
lukaszraczylo 40eba2845c deps: bump grpc v1.81.1->v1.82.1 and x/text v0.38.0->v0.39.0 (govulncheck fixes GO-2026-6061, GO-2026-5970) 2026-08-13 15:22:21 +01:00
lukaszraczylo 55fc2ae1de feat(deps)!: migrate from fiber v2 to fiber v3
BREAKING CHANGE: upgrades the HTTP framework from gofiber/fiber/v2 to gofiber/fiber/v3, and gofiber/websocket/v2 to gofiber/contrib/v3/websocket.

- Handlers now take fiber.Ctx (interface) instead of *fiber.Ctx. - DisableStartupMessage moved from fiber.Config to fiber.ListenConfig on the proxy/api/monitoring Listen calls. - cors AllowOrigins is now []string; c.BodyParser -> c.Bind().Body(). - app.Test takes fiber.TestConfig instead of an int timeout (tests updated). - WebSocket swapped to contrib/v3/websocket (same Conn/New/Config/IsCloseError/IsWebSocketUpgrade API; Conn.Query preserved). - Adopts fasthttp v1.71.0 (pulled by fiber v3), resolving the v1.71 Host-header enforcement that broke the prior pinned-v1.69 workaround.

fix(connpool): the background keep-alive goroutine no longer reads the mutable global cfg (captures HostGraphQL/HealthcheckGraphQL at pool creation). Under v3 timing it raced with parseConfig/test cfg reassignment; go test -race ./... is now clean (0 data races).

test: make the circuit-breaker cache-fallback and request-coalescing integration tests deterministic (cache TTL outlives the retry loop; coalescing asserts against a measured single-request baseline instead of a hard-coded count); drop the flaky timing-ratio assertion in TestTimingAttackResistance (constant-time guarantee comes from subtle.ConstantTimeCompare, not wall-clock timing).

Verified: go build, go vet, golangci-lint (0 issues), go test -race ./... (all packages pass, 0 races), govulncheck (no vulnerabilities). App + dashboard + WebSocket verified live under v3 in single-node and cluster modes.
2026-06-21 13:15:14 +01:00
lukaszraczylo 877325a633 chore(deps): update dependencies and clear x/net vulnerabilities
Bump golang.org/x/net v0.52.0 -> v0.56.0, fixing GO-2026-5026 (idna Punycode label rejection) and GO-2026-4918 (HTTP/2 transport infinite loop). govulncheck now reports no vulnerabilities. Also bumps x/sync, x/sys, x/term, x/text, otel v1.43->v1.44, grpc v1.80->v1.81 and genproto.

Hold github.com/valyala/fasthttp at v1.69.0: v1.71.0 changes request handling such that the API auth/integration security suites fail (app.Test errors on benign requests), violating the behaviour-preserving upgrade rule. fasthttp had no flagged vulnerability, so pinning it back loses no security fix. Adopting v1.71.0 needs separate investigation.

Verified: go build, go vet, golangci-lint, go test -race ./... all pass; govulncheck clean.
2026-06-21 02:54:03 +01:00
lukaszraczylo 287289cd80 fix(telemetry): inject appVersion at build + auto-resolve at runtime
The released v0.45.1 binary shipped with the source default
appVersion="dev" because .goreleaser.yaml had ldflags="-s -w" only,
so every startup ping was rejected by the receiver with HTTP 400
(invalid version: regex requires leading digit).

Two-layer fix:

1. .goreleaser.yaml now passes -X main.appVersion={{.Version}} so
   goreleaser-built binaries report the actual release version.
2. Switch to telemetry.SendForModule which prefers
   debug.ReadBuildInfo Main/Deps when available, falling back to
   appVersion. This means `go install github.com/lukaszraczylo/
   [email protected]` users also get correct versions
   without relying on the ldflag.

Bumps oss-telemetry to v0.2.1 for SendForModule.
2026-05-22 23:34:09 +01:00
lukaszraczylo d96d2f429f feat: anonymous usage telemetry via oss-telemetry
Send a single fire-and-forget ping at startup to help track adoption
and version spread. No persistent identifiers are collected.

Adds main.appVersion var (defaulting to "dev"); wire ldflags
(-X main.appVersion=$VERSION) to populate it at release time.

Opt out via any of:
  DO_NOT_TRACK=1
  OSS_TELEMETRY_DISABLED=1
  GRAPHQL_MONITORING_PROXY_DISABLE_TELEMETRY=1
2026-05-21 03:06:34 +01:00
lukaszraczylo c2c75d69c0 perf+coverage: optimisation pass + coverage push to ≥70%
Performance / resource usage:
- circuit_breaker_metrics: fix data race on failCounters map (RWMutex + double-checked locking)
- server.go: drop user_id and op_name metric labels (Prometheus cardinality bound); de-duplicate extractUserInfo
- graphql.go: gate runtime.ReadMemStats per-request behind ENABLE_ALLOCATION_TRACKING flag (default off)
- graphql.go: collapse two-pass AST scan into single pass; lower-case once
- sanitization.go: cache compiled redaction regexes per pattern via sync.Map; hoist inner constants to pkg vars
- proxy.go: hoist connection/timeout substrings to pkg vars; sentinel errors for static error paths; drop dead Headers map alloc
- metrics_aggregator.go: log-field allocation guarded by Logger.IsLevelEnabled
- logging/logger.go: add IsLevelEnabled helper
- lru_cache.go: 16-shard sharding, FNV-1a routing (concurrent throughput +22%)
- cache/memory/lru_memory_cache.go: gzip compress/decompress moved outside mu.Lock
- rps_tracker.go: RWMutex+uint64 -> atomic.Uint64
- retry_budget.go: drop unused mutex
- api.go: bannedUsersIDs map+RWMutex -> sync.Map (+ snapshot/replace helpers)
- tracing/tracing.go: pkg-level constSpanAttrs, copy-then-append in StartSpanWithAttributes
- admin_dashboard.go: handleStatsWebSocket reuses bytes.Buffer + json.Encoder per connection

Build / runtime:
- Makefile: -ldflags="-s -w" -trimpath, CGO_ENABLED=0 for build (=1 for test recipes)
- Dockerfile + Dockerfile.goreleaser: ENV GOMEMLIMIT=512MiB
- main.go: blank import go.uber.org/automaxprocs (cgroup-aware GOMAXPROCS)
- main.go: PPROF_PORT env var wires net/http/pprof on 127.0.0.1 only with full server timeouts
- README.md: env-var docs + metric-label docs updated; cardinality note

Test coverage push (per package):
- main 51.2% -> 74.7%
- cache 66.3% -> 93.7%
- cache/redis 45.5% -> 98.2%
- tracing 66.7% -> 72.9%
- (cache/memory 91.6%, logging 91.9%, monitoring 77.6%, pkg/pools 100% unchanged)

New test files: coverage_micro_test, coverage_extras_test, server_handlers_test,
api_health_test, admin_dashboard_cluster_test, metrics_aggregator_test, concerns_test,
cache/cache_coverage_test, cache/redis/redis_coverage_test, tracing/tracing_coverage_test.

Bug fix: connection_resilience_test.go TestIntegratedHealthManagement.health_manager_startup
was sync.Once-coupled to InitializeBackendHealth and panicked when another test (e.g. via
parseConfig) had already triggered Once. Use NewBackendHealthManager directly.
2026-04-19 19:49:24 +01:00
lukaszraczyloandGitHub 65fa936b60 Update go.mod and go.sum (#86) 2026-04-04 04:48:07 +01:00
lukaszraczyloandGitHub 122148d23e Update go.mod and go.sum (#85) 2026-04-03 04:56:24 +01:00
lukaszraczyloandGitHub 6e493e4100 Update go.mod and go.sum (#84) 2026-04-02 04:54:42 +01:00
lukaszraczyloandGitHub 92da4af001 Update go.mod and go.sum (#83) 2026-04-01 05:02:25 +01:00
lukaszraczyloandGitHub c68dc2f20a Update go.mod and go.sum (#82) 2026-03-31 04:56:07 +01:00
lukaszraczyloandGitHub 11ff751001 Update go.mod and go.sum (#81) 2026-03-23 03:53:38 +00:00
lukaszraczyloandGitHub 0414473f15 Update go.mod and go.sum (#80) 2026-03-22 03:49:12 +00:00
lukaszraczyloandGitHub bc61557015 Update go.mod and go.sum (#79) 2026-03-21 03:42:49 +00:00
lukaszraczyloandGitHub 12ec00f697 Update go.mod and go.sum (#78) 2026-03-20 03:45:16 +00:00
lukaszraczyloandGitHub da4a179d66 Update go.mod and go.sum (#77) 2026-03-18 03:51:52 +00:00
lukaszraczyloandGitHub d0ecefce6c Update go.mod and go.sum (#76) 2026-03-17 03:46:12 +00:00
lukaszraczyloandGitHub c742530d2f Update go.mod and go.sum (#75) 2026-03-13 03:46:36 +00:00
lukaszraczyloandGitHub 7304559801 Update go.mod and go.sum (#74) 2026-03-12 03:45:51 +00:00
lukaszraczyloandGitHub aa46992497 Update go.mod and go.sum (#73) 2026-03-10 03:45:15 +00:00
lukaszraczyloandGitHub e968a48584 Update go.mod and go.sum (#72) 2026-03-09 03:47:33 +00:00
lukaszraczyloandGitHub c67dfe1827 Update go.mod and go.sum (#71) 2026-03-08 03:46:25 +00:00
lukaszraczyloandGitHub 55d86e34cf Update go.mod and go.sum (#70) 2026-03-07 03:37:20 +00:00
lukaszraczyloandGitHub cd4a1f16ed Update go.mod and go.sum (#69) 2026-03-03 03:46:23 +00:00
lukaszraczyloandGitHub 3352050bdb Update go.mod and go.sum (#68) 2026-02-27 03:46:24 +00:00
lukaszraczyloandGitHub bb2509e254 Update go.mod and go.sum (#67) 2026-02-26 03:47:30 +00:00
lukaszraczyloandGitHub d027122446 Update go.mod and go.sum (#66) 2026-02-25 03:48:58 +00:00
lukaszraczyloandGitHub 3abbaf66a1 Update go.mod and go.sum (#65) 2026-02-24 03:47:16 +00:00
lukaszraczyloandGitHub f8871a4fb7 Update go.mod and go.sum (#64) 2026-02-19 03:49:36 +00:00
lukaszraczyloandGitHub 420e63f383 Update go.mod and go.sum (#63) 2026-02-18 03:50:04 +00:00
lukaszraczyloandGitHub 9bd9f0b9ba Update go.mod and go.sum (#62) 2026-02-17 03:47:17 +00:00