diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 881b3d1..f2f5551 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -16,7 +16,7 @@ jobs: - uses: actions/checkout@v5 - uses: actions/setup-go@v6 with: - go-version: 1.26.0 + go-version: 1.26.1 - name: go fix run: | go fix ./... @@ -24,4 +24,4 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v9 with: - version: v2.9.0 + version: v2.11.2 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index b0566e0..4b9bef1 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -35,7 +35,7 @@ jobs: run: | echo "VERSION=$(git describe --tags --always)" >> $GITHUB_ENV echo "GIT_COMMIT=$(git rev-parse HEAD)" >> $GITHUB_ENV - echo "GO_VERSION=1.26.0" >> $GITHUB_ENV + echo "GO_VERSION=1.26.1" >> $GITHUB_ENV - name: Set up Go if: github.event_name == 'release' || inputs.build_binaries diff --git a/Dockerfile b/Dockerfile index 143dc5c..b67698d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -ARG GO_VERSION=1.26.0 +ARG GO_VERSION=1.26.1 FROM docker.io/library/golang:${GO_VERSION}-alpine AS builder diff --git a/Taskfile.yaml b/Taskfile.yaml index e713a4d..a4a84f8 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -3,7 +3,7 @@ version: "3" vars: BIN_DIR: ./bin - GOLANGCI_LINT_VERSION: v2.9.0 + GOLANGCI_LINT_VERSION: v2.11.2 GOLANGCI: "{{.BIN_DIR}}/golangci-lint-{{.GOLANGCI_LINT_VERSION}}" tasks: diff --git a/cmd/cli/main.go b/cmd/cli/main.go index 2ca978c..84283d2 100644 --- a/cmd/cli/main.go +++ b/cmd/cli/main.go @@ -14,7 +14,7 @@ import ( ) func main() { - ctx, cancel := context.WithCancel(context.Background()) + ctx, cancel := context.WithCancel(context.Background()) //nolint:gosec // G118: cancel is called in listenForTermination goroutine go listenForTermination(func() { cancel() }) combinedConfig := config.ReadAllConfigs() diff --git a/go.mod b/go.mod index ee5d66a..bd82129 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module go.aykhans.me/sarin -go 1.26.0 +go 1.26.1 require ( github.com/brianvoe/gofakeit/v7 v7.14.1 diff --git a/internal/config/config.go b/internal/config/config.go index 42b7ff7..a266f9e 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -418,7 +418,7 @@ func (config Config) Validate() error { validationErrors = append(validationErrors, types.NewFieldValidationError("Duration", "0", errors.New("duration must be greater than 0"))) } - if *config.Timeout < 1 { + if config.Timeout == nil || *config.Timeout < 1 { validationErrors = append(validationErrors, types.NewFieldValidationError("Timeout", "0", errors.New("timeout must be greater than 0"))) } diff --git a/internal/config/env.go b/internal/config/env.go index b273a75..b6fe0d6 100644 --- a/internal/config/env.go +++ b/internal/config/env.go @@ -157,7 +157,7 @@ func (parser ConfigENVParser) Parse() (*Config, error) { types.NewFieldParseError( parser.getFullEnvName("DURATION"), duration, - errors.New("invalid value duration, expected a duration string (e.g., '10s', '1h30m')"), + errors.New("invalid value for duration, expected a duration string (e.g., '10s', '1h30m')"), ), ) } else { @@ -173,7 +173,7 @@ func (parser ConfigENVParser) Parse() (*Config, error) { types.NewFieldParseError( parser.getFullEnvName("TIMEOUT"), timeout, - errors.New("invalid value duration, expected a duration string (e.g., '10s', '1h30m')"), + errors.New("invalid value for duration, expected a duration string (e.g., '10s', '1h30m')"), ), ) } else { diff --git a/internal/sarin/client.go b/internal/sarin/client.go index 77b7a13..8854b7b 100644 --- a/internal/sarin/client.go +++ b/internal/sarin/client.go @@ -172,7 +172,6 @@ func fasthttpSocksDialerDualStackTimeout(ctx context.Context, proxyURL *url.URL, return nil, types.NewProxyDialError(proxyStr, err) } - // Cap DNS resolution to half the timeout to reserve time for dial dnsCtx, dnsCancel := context.WithTimeout(ctx, timeout) ips, err := net.DefaultResolver.LookupIP(dnsCtx, "ip", host) dnsCancel() @@ -244,7 +243,7 @@ func fasthttpHTTPSDialerDualStackTimeout(proxyURL *url.URL, timeout time.Duratio } // Upgrade to TLS - tlsConn := tls.Client(conn, &tls.Config{ //nolint:gosec + tlsConn := tls.Client(conn, &tls.Config{ ServerName: proxyURL.Hostname(), }) if err := tlsConn.Handshake(); err != nil { diff --git a/internal/sarin/helpers.go b/internal/sarin/helpers.go index d5cc22e..dab4942 100644 --- a/internal/sarin/helpers.go +++ b/internal/sarin/helpers.go @@ -8,7 +8,7 @@ import ( func NewDefaultRandSource() rand.Source { now := time.Now().UnixNano() return rand.NewPCG( - uint64(now), //nolint:gosec // G115: Safe conversion; UnixNano timestamp used as random seed, bit pattern is intentional - uint64(now>>32), //nolint:gosec // G115: Safe conversion; right-shifted timestamp for seed entropy, overflow is acceptable + uint64(now), + uint64(now>>32), ) } diff --git a/internal/sarin/request.go b/internal/sarin/request.go index f2088ca..727a05b 100644 --- a/internal/sarin/request.go +++ b/internal/sarin/request.go @@ -91,7 +91,7 @@ func NewRequestGenerator( return err } - bodyTemplateFuncMapData.ClearFormDataContenType() + bodyTemplateFuncMapData.ClearFormDataContentType() if err = bodyGenerator(reqData, data); err != nil { return err } @@ -99,8 +99,8 @@ func NewRequestGenerator( if err = headersGenerator(reqData, data); err != nil { return err } - if bodyTemplateFuncMapData.GetFormDataContenType() != "" { - reqData.Headers["Content-Type"] = append(reqData.Headers["Content-Type"], bodyTemplateFuncMapData.GetFormDataContenType()) + if bodyTemplateFuncMapData.GetFormDataContentType() != "" { + reqData.Headers["Content-Type"] = append(reqData.Headers["Content-Type"], bodyTemplateFuncMapData.GetFormDataContentType()) } if err = paramsGenerator(reqData, data); err != nil { diff --git a/internal/sarin/template.go b/internal/sarin/template.go index fae5a73..917ff92 100644 --- a/internal/sarin/template.go +++ b/internal/sarin/template.go @@ -286,7 +286,7 @@ func NewDefaultTemplateFuncMap(randSource rand.Source, fileCache *FileCache) tem "fakeit_AdverbFrequencyDefinite": fakeit.AdverbFrequencyDefinite, "fakeit_AdverbFrequencyIndefinite": fakeit.AdverbFrequencyIndefinite, - // Propositions + // Prepositions "fakeit_Preposition": fakeit.Preposition, "fakeit_PrepositionSimple": fakeit.PrepositionSimple, "fakeit_PrepositionDouble": fakeit.PrepositionDouble, @@ -589,15 +589,15 @@ func NewDefaultTemplateFuncMap(randSource rand.Source, fileCache *FileCache) tem } type BodyTemplateFuncMapData struct { - formDataContenType string + formDataContentType string } -func (data BodyTemplateFuncMapData) GetFormDataContenType() string { - return data.formDataContenType +func (data BodyTemplateFuncMapData) GetFormDataContentType() string { + return data.formDataContentType } -func (data *BodyTemplateFuncMapData) ClearFormDataContenType() { - data.formDataContenType = "" +func (data *BodyTemplateFuncMapData) ClearFormDataContentType() { + data.formDataContentType = "" } func NewDefaultBodyTemplateFuncMap( @@ -628,7 +628,7 @@ func NewDefaultBodyTemplateFuncMap( var multipartData bytes.Buffer writer := multipart.NewWriter(&multipartData) - data.formDataContenType = writer.FormDataContentType() + data.formDataContentType = writer.FormDataContentType() for i := 0; i < len(pairs); i += 2 { key := pairs[i]