Skip to content
Draft
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: 9 additions & 4 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:
branches:
- "master"

permissions:
contents: "read"

jobs:
quality-check:
runs-on: "ubuntu-24.04"
Expand All @@ -24,13 +27,15 @@ jobs:
restore-keys: |
${{ runner.os }}-go-
- run: |
go install honnef.co/go/tools/cmd/staticcheck@latest
go install golang.org/x/tools/cmd/goimports@latest
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
go install honnef.co/go/tools/cmd/staticcheck@v0.7.0
go install golang.org/x/tools/cmd/goimports@v0.48.0
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.12.2
go install golang.org/x/vuln/cmd/govulncheck@v1.6.0

- run: "go vet ./..."
- run: "staticcheck ./..."
- run: "golangci-lint run ./..."
- run: "govulncheck ./..."
- run: |
diff=$(goimports -d .)
if [ -n "$diff" ]; then
Expand Down Expand Up @@ -74,4 +79,4 @@ jobs:
GRANT ALL PRIVILEGES ON DATABASE kit_test TO kit;
EOF
PGPASSWORD=kit psql -h localhost -U kit -d kit_test -c "ALTER SCHEMA public OWNER TO kit;"
- run: "go test -v -count=1 ./..."
- run: "go test -race -v -count=1 ./..."
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- Harden PostgreSQL pool cleanup, metrics registration, TLS validation, and migration locking.
- Prevent HTTP SSRF proxy bypasses and redact sensitive telemetry and error responses.
- Remove connection-level HTTP spans that incorrectly parent unrelated keep-alive requests.
- Propagate shutdown cancellation, bound shutdown and HTTP waits, and recover worker panics.
- Use secure telemetry defaults and redact secrets from printed configuration.

### Security

- Omit SQL query text from traces by default and reduce attacker-controlled telemetry cardinality.
- Pin CI tools, run race-enabled tests, and scan dependencies with `govulncheck`.

## [0.11.0] - 2026-05-25

### Added
Expand All @@ -27,7 +40,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- **httpclient**: Retry round tripper with exponential backoff and jitter for transient failures (5xx, 429, and connection errors). Enabled via `WithMaxRetries`, `WithRetryMinWait`, and `WithRetryMaxWait` options.
- **pg**: `WithMaxConnLifetimeJitter` option to smear connection recycle events and avoid synchronized reconnect storms. Defaults to 5 minutes; pass `0` to disable.
- **pg**: `WithHealthCheckPeriod` option to tune how often the pool checks idle connections and enforces MinConns/MaxConnIdleTime/MaxConnLifetime. A zero value leaves the pgx default (1 minute) in place.

Expand Down
5 changes: 5 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# PERFORMANCE OF THIS SOFTWARE.

GO ?= go
GOFMT ?= gofmt
GOIMPORTS ?= goimports
GOLANGCI_LINT ?= golangci-lint

Expand Down Expand Up @@ -46,6 +47,10 @@ lint-goimports:
exit 1; \
fi

.PHONY: go-fmt
go-fmt:
$(GO) fmt $(PACKAGES)

.PHONY: test
test:
$(GO) test -count=1 $(PACKAGES)
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Kit provides foundational packages for building production-grade Go services wit

## Requirements

- Go 1.25+
- Go 1.26+

## Installation

Expand All @@ -36,6 +36,14 @@ go get go.gearno.de/kit

See the [Go package documentation](https://pkg.go.dev/go.gearno.de/kit) for API reference and examples.

## Production safety

- Enable `httpclient.WithSSRFProtection` whenever users can influence URLs.
- Use `pg.WithTLS` and `pg.WithRequireTLS` for non-local databases.
- SQL query text is excluded from traces by default.
- Metrics bind to loopback and OTLP/HTTP uses verified TLS by default.
- Outbound requests have bounded response-header and total timeouts.

## Contributing

Contributions are welcome. Please open an issue to discuss proposed changes before submitting a pull request.
Expand Down
47 changes: 23 additions & 24 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,55 +1,54 @@
module go.gearno.de/kit

go 1.26
go 1.26.0

require (
github.com/fatih/color v1.19.0
github.com/go-chi/chi/v5 v5.2.5
github.com/jackc/pgx/v5 v5.9.1
github.com/jackc/pgx/v5 v5.11.0
github.com/prometheus/client_golang v1.23.2
github.com/stretchr/testify v1.11.1
github.com/stretchr/testify v1.12.1
go.gearno.de/crypto/uuid v0.1.0
go.gearno.de/x/panicf v0.1.1
go.opentelemetry.io/otel v1.42.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.42.0
go.opentelemetry.io/otel/sdk v1.42.0
go.opentelemetry.io/otel/trace v1.42.0
go.opentelemetry.io/otel v1.47.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.47.0
go.opentelemetry.io/otel/sdk v1.47.0
go.opentelemetry.io/otel/trace v1.47.0
sigs.k8s.io/yaml v1.6.0
)

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-logr/logr v1.4.4 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.28.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.30.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/puddle/v2 v2.2.2 // indirect
github.com/klauspost/compress v1.18.2 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.67.5 // indirect
github.com/prometheus/procfs v0.20.1 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/stretchr/objx v0.5.3 // indirect
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.42.0 // indirect
go.opentelemetry.io/otel/metric v1.42.0 // indirect
go.opentelemetry.io/proto/otlp v1.10.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.47.0 // indirect
go.opentelemetry.io/otel/log v1.47.0 // indirect
go.opentelemetry.io/otel/metric v1.47.0 // indirect
go.opentelemetry.io/proto/otlp v1.11.0 // indirect
go.yaml.in/yaml/v2 v2.4.4 // indirect
golang.org/x/net v0.52.0 // indirect
golang.org/x/sync v0.20.0 // indirect
golang.org/x/sys v0.42.0 // indirect
golang.org/x/text v0.35.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20260401024825-9d38bb4040a9 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260401024825-9d38bb4040a9 // indirect
google.golang.org/grpc v1.80.0 // indirect
google.golang.org/protobuf v1.36.11 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
go.yaml.in/yaml/v3 v3.0.5 // indirect
golang.org/x/net v0.61.0 // indirect
golang.org/x/sync v0.24.0 // indirect
golang.org/x/sys v0.49.0 // indirect
golang.org/x/text v0.43.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20260928230214-8a89bd6388cc // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260928230214-8a89bd6388cc // indirect
google.golang.org/grpc v1.84.0 // indirect
google.golang.org/protobuf v1.36.12 // indirect
)
Loading