diff --git a/.golangci.yml b/.golangci.yml index 08eb6726..56f5f761 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,14 +1,14 @@ # This file is licensed under the terms of the MIT license https://opensource.org/license/mit -# Copyright (c) 2021-2025 Marat Reymers +# Copyright (c) 2021-2025 Marat Reimers -## Golden config for golangci-lint v2.5.0 +## Golden config for golangci-lint v2.9.0 # # This is the best config for golangci-lint based on my experience and opinion. # It is very strict, but not extremely strict. # Feel free to adapt it to suit your needs. -# If this config helps you, please consider keeping a link to this file (see the next comment). +# If this config helps you, please consider keeping a link to this repo (see the next comment). -# Based on https://gist.github.com/maratori/47a4d00457a92aa426dbd48a18776322 +# Based on https://github.com/maratori/golangci-lint-config version: "2" @@ -82,6 +82,7 @@ linters: - makezero # finds slice declarations with non-zero initial length - mirror # reports wrong mirror patterns of bytes/strings usage - mnd # detects magic numbers + - modernize # suggests simplifications to Go code, using modern language and library features - musttag # enforces field tags in (un)marshaled structs - nakedret # finds naked returns in functions greater than a specified function length - nestif # reports deeply nested if statements @@ -256,10 +257,15 @@ linters: - ^firebase.google.com/go/v4/messaging.Message$ - ^github.com/aws/aws-sdk-go-v2/service/s3.+Input$ - ^github.com/aws/aws-sdk-go-v2/service/s3/types.ObjectIdentifier$ + - ^github.com/go-telegram-bot-api/telegram-bot-api/.+Config$ + - ^github.com/go-telegram/bot.+Params$ + - ^github.com/go-telegram/bot/models.+$ - ^github.com/gofiber/.+Config$ - ^github.com/golang-jwt/jwt/v5.+Claims$ - ^github.com/mitchellh/mapstructure.DecoderConfig$ + - ^github.com/mymmrac/telego.+Parameters$ - ^github.com/prometheus/client_golang/.+Opts$ + - ^github.com/revrost/go-openrouter.+$ - ^github.com/secsy/goftp.Config$ - ^github.com/Shopify/sarama.Config$ - ^github.com/Shopify/sarama.ProducerMessage$ @@ -268,6 +274,7 @@ linters: - ^github.com/stretchr/testify/mock.Mock$ - ^github.com/testcontainers/testcontainers-go.+Request$ - ^github.com/testcontainers/testcontainers-go.FromDockerfile$ + - ^github.com/ThreeDotsLabs/watermill.+(Config|Schema|Adapter)$ - ^github.com/urfave/cli.v3.ArgumentBase$ - ^github.com/urfave/cli.v3.Command$ - ^github.com/urfave/cli.v3.FlagBase$ @@ -328,6 +335,16 @@ linters: # Assert no unused link in godocs. # https://github.com/godoc-lint/godoc-lint?tab=readme-ov-file#no-unused-link - no-unused-link + # Require proper doc links to standard library declarations where applicable. + # https://github.com/godoc-lint/godoc-lint?tab=readme-ov-file#require-stdlib-doclink + - require-stdlib-doclink + + gosec: + # To specify a set of rules to explicitly exclude. + # Available rules: https://github.com/securego/gosec#available-rules + excludes: + - G117 # Potential exposure of secrets via JSON marshaling + - G704 # SSRF via taint analysis govet: # Enable all analyzers. @@ -376,6 +393,9 @@ linters: max-func-lines: 0 nolintlint: + # Disable to ensure that all nolint directives actually have an effect. + # Default: false + allow-unused: true # Exclude following linters from requiring an explanation. # Default: [] allow-no-explanation: [funlen, gocognit, golines] diff --git a/go.mod b/go.mod index df0aa953..b18a6dd7 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.24.3 require ( firebase.google.com/go/v4 v4.12.1 - github.com/android-sms-gateway/client-go v1.9.6-0.20251123133512-f7816d96f90a + github.com/android-sms-gateway/client-go v1.10.1 github.com/ansrivas/fiberprometheus/v2 v2.6.1 github.com/capcom6/go-helpers v0.3.0 github.com/capcom6/go-infra-fx v0.5.2 diff --git a/go.sum b/go.sum index b5d9c70c..cc7a0fcd 100644 --- a/go.sum +++ b/go.sum @@ -34,6 +34,12 @@ github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/android-sms-gateway/client-go v1.9.6-0.20251123133512-f7816d96f90a h1:Tm1FDTqFRs1ZftaEmQqDdIXtMRZf2aGCp8t2BgXY/rs= github.com/android-sms-gateway/client-go v1.9.6-0.20251123133512-f7816d96f90a/go.mod h1:DQsReciU1xcaVW3T5Z2bqslNdsAwCFCtghawmA6g6L4= +github.com/android-sms-gateway/client-go v1.10.1-0.20260217004820-83d276545735 h1:/dwS503F7TbfkmKoEWHVb1FHZMzdX5fUUEyQgRiojXU= +github.com/android-sms-gateway/client-go v1.10.1-0.20260217004820-83d276545735/go.mod h1:DQsReciU1xcaVW3T5Z2bqslNdsAwCFCtghawmA6g6L4= +github.com/android-sms-gateway/client-go v1.10.1-0.20260218044357-fb0b167fbe22 h1:egrBOdjsn7onxrbFQwZ0wptDgN/5xO6nsfSIlraB7RU= +github.com/android-sms-gateway/client-go v1.10.1-0.20260218044357-fb0b167fbe22/go.mod h1:DQsReciU1xcaVW3T5Z2bqslNdsAwCFCtghawmA6g6L4= +github.com/android-sms-gateway/client-go v1.10.1 h1:8Sby6DRp5CEVpTSeZDvi9r1ooMK21Vf1lZkeu7absVw= +github.com/android-sms-gateway/client-go v1.10.1/go.mod h1:DQsReciU1xcaVW3T5Z2bqslNdsAwCFCtghawmA6g6L4= github.com/andybalholm/brotli v1.2.0 h1:ukwgCxwYrmACq68yiUqwIWnGY0cTPox/M94sVwToPjQ= github.com/andybalholm/brotli v1.2.0/go.mod h1:rzTDkvFWvIrjDXZHkuS16NPggd91W3kUSvPlQ1pLaKY= github.com/ansrivas/fiberprometheus/v2 v2.6.1 h1:wac3pXaE6BYYTF04AC6K0ktk6vCD+MnDOJZ3SK66kXM= diff --git a/internal/config/types.go b/internal/config/types.go index 82e12439..1992075a 100644 --- a/internal/config/types.go +++ b/internal/config/types.go @@ -10,7 +10,7 @@ import ( type Duration time.Duration -// Duration returns the underlying time.Duration value. +// Duration returns the underlying [time.Duration] value. func (d *Duration) Duration() time.Duration { if d == nil { return 0 diff --git a/internal/sms-gateway/handlers/middlewares/userauth/userauth.go b/internal/sms-gateway/handlers/middlewares/userauth/userauth.go index 601e9f13..82cd61cd 100644 --- a/internal/sms-gateway/handlers/middlewares/userauth/userauth.go +++ b/internal/sms-gateway/handlers/middlewares/userauth/userauth.go @@ -37,15 +37,11 @@ func NewBasic(usersSvc *users.Service) fiber.Handler { // Check if the credentials are in the correct form // which is "username:password". - index := strings.Index(creds, ":") - if index == -1 { + username, password, ok := strings.Cut(creds, ":") + if !ok { return fiber.ErrUnauthorized } - // Get the username and password - username := creds[:index] - password := creds[index+1:] - user, err := usersSvc.Login(c.Context(), username, password) if err != nil { return fiber.ErrUnauthorized diff --git a/internal/sms-gateway/modules/metrics/handler.go b/internal/sms-gateway/modules/metrics/handler.go index b62a56ba..83c41d6f 100644 --- a/internal/sms-gateway/modules/metrics/handler.go +++ b/internal/sms-gateway/modules/metrics/handler.go @@ -1,3 +1,4 @@ +//nolint:revive // ignore package name package metrics import ( diff --git a/internal/sms-gateway/modules/metrics/module.go b/internal/sms-gateway/modules/metrics/module.go index ace82c08..d1f9a521 100644 --- a/internal/sms-gateway/modules/metrics/module.go +++ b/internal/sms-gateway/modules/metrics/module.go @@ -1,3 +1,4 @@ +//nolint:revive // ignore package name package metrics import ( diff --git a/internal/sms-gateway/modules/settings/utils.go b/internal/sms-gateway/modules/settings/utils.go index e6fbdb40..cc5d32a8 100644 --- a/internal/sms-gateway/modules/settings/utils.go +++ b/internal/sms-gateway/modules/settings/utils.go @@ -34,6 +34,9 @@ var ( "retry_count": "", "signing_key": "", }, + "gateway": map[string]any{ + "notification_channel": "", + }, } rulesPublic = map[string]any{ @@ -56,6 +59,9 @@ var ( "internet_required": "", "retry_count": "", }, + "gateway": map[string]any{ + "notification_channel": "", + }, } ) diff --git a/internal/version/version.go b/internal/version/version.go index 504a2153..52f4b5b0 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -1,4 +1,4 @@ -package version +package version //nolint:revive // ignore package name import "strconv" diff --git a/test/e2e/docker-compose.yml b/test/e2e/docker-compose.yml index 0044501b..1e00f5da 100644 --- a/test/e2e/docker-compose.yml +++ b/test/e2e/docker-compose.yml @@ -1,6 +1,6 @@ services: public: - image: android-sms-gateway/server + image: android-sms-gateway/server:public build: context: ../.. dockerfile: ./build/package/Dockerfile @@ -22,13 +22,13 @@ services: - "3000:3000" volumes: - ./data/config.yml:/app/config.yml:ro - restart: 'unless-stopped' + restart: "unless-stopped" depends_on: db: condition: service_healthy private: - image: android-sms-gateway/server + image: android-sms-gateway/server:private build: context: ../.. dockerfile: ./build/package/Dockerfile @@ -50,7 +50,7 @@ services: - "3001:3000" volumes: - ./data/config.yml:/app/config.yml:ro - restart: 'unless-stopped' + restart: "unless-stopped" depends_on: db: condition: service_healthy @@ -62,7 +62,7 @@ services: - MARIADB_AUTO_UPGRADE=1 volumes: - ./data/10-init.sql:/docker-entrypoint-initdb.d/10-init.sql:ro - restart: 'unless-stopped' + restart: "unless-stopped" healthcheck: test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] start_period: 4s