Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add missing pre commits #1289

Merged
merged 3 commits into from
Feb 27, 2024
Merged
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
3 changes: 3 additions & 0 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ tests-integration:
pre-commit: # Generate the final spec and run all the pre-commit hooks
LOCALLY
BUILD --pass-args ./releases+sdk-generate
FOR component IN $(cd ./libs && ls -d */)
BUILD --pass-args ./libs/${component}+pre-commit
END
FOR component IN $(cd ./tools && ls -d */)
BUILD --pass-args ./tools/${component}+pre-commit
END
Expand Down
3 changes: 2 additions & 1 deletion components/fctl/cmd/wallets/balances/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ package balances

import (
"fmt"
"math/big"

"github.com/formancehq/fctl/cmd/wallets/internal"
fctl "github.com/formancehq/fctl/pkg"
"github.com/formancehq/formance-sdk-go/v2/pkg/models/operations"
"github.com/formancehq/formance-sdk-go/v2/pkg/models/shared"
"github.com/pkg/errors"
"github.com/pterm/pterm"
"github.com/spf13/cobra"
"math/big"
)

type CreateStore struct {
Expand Down
43 changes: 43 additions & 0 deletions components/ledger/libs/.golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
allow-parallel-runners: true
run:
timeout: 5m
linters:
disable-all: true
enable:
- gofmt
- goimports
- unused
- gosec
linters-settings:
gosec:
# To select a subset of rules to run.
# Available rules: https://github.com/securego/gosec#available-rules
includes:
- G103 # Audit the use of unsafe block
- G104 # Audit errors not checked
- G106 # Audit the use of ssh.InsecureIgnoreHostKey
- G108 # Profiling endpoint automatically exposed on /debug/pprof
- G109 # Potential Integer overflow made by strconv.Atoi result conversion to int16/32
- G110 # Potential DoS vulnerability via decompression bomb
- G111 # Potential directory traversal
- G112 # Potential slowloris attack
# - G113 # Usage of Rat.SetString in math/big with an overflow (CVE-2022-23772)
- G201 # SQL query construction using format string
- G202 # SQL query construction using string concatenation
- G203 # Use of unescaped data in HTML templates
- G204 # Audit use of command execution
- G301 # Poor file permissions used when creating a directory
- G302 # Poor file permissions used with chmod
- G303 # Creating tempfile using a predictable path
- G304 # File path provided as taint input
- G305 # File traversal when extracting zip/tar archive
- G306 # Poor file permissions used when writing to a new file
- G307 # Poor file permissions used when creating a file with os.Create
- G401 # Detect the usage of DES, RC4, MD5 or SHA1
- G403 # Ensure minimum RSA key length of 2048 bits
- G501 # Import blocklist: crypto/md5
- G502 # Import blocklist: crypto/des
- G503 # Import blocklist: crypto/rc4
- G504 # Import blocklist: net/http/cgi
- G505 # Import blocklist: crypto/sha1
- G602 # Slice access out of bounds
17 changes: 16 additions & 1 deletion components/ledger/libs/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ VERSION --arg-scope-and-set --pass-args --use-function-keyword 0.7

ARG core=github.com/formancehq/earthly:v0.11.1
IMPORT $core AS core
IMPORT ../.. AS stack

FROM core+base-image

Expand All @@ -15,4 +16,18 @@ tidy:
COPY (+sources/*) /src
WORKDIR /src
DO --pass-args stack+GO_TIDY
SAVE ARTIFACT go.* AS LOCAL ./
SAVE ARTIFACT go.* AS LOCAL ./

lint:
FROM core+builder-image
COPY (+sources/*) /src
WORKDIR /src
COPY --pass-args +tidy/go.* .
DO --pass-args stack+GO_LINT
SAVE ARTIFACT * AS LOCAL ./

pre-commit:
WAIT
BUILD --pass-args +tidy
END
BUILD --pass-args +lint
1 change: 1 addition & 0 deletions components/ledger/libs/aws/iam/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package iam

import (
"context"

"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/spf13/pflag"
Expand Down
3 changes: 2 additions & 1 deletion components/ledger/libs/bun/bunconnect/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ package bunconnect
import (
"context"
"database/sql/driver"
"time"

"github.com/aws/aws-sdk-go-v2/config"
"github.com/formancehq/stack/libs/go-libs/aws/iam"
"github.com/formancehq/stack/libs/go-libs/logging"
"github.com/formancehq/stack/libs/go-libs/service"
"github.com/lib/pq"
"github.com/spf13/pflag"
"github.com/spf13/viper"
"time"
)

const (
Expand Down
1 change: 1 addition & 0 deletions components/ledger/libs/bun/bunconnect/iam.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"database/sql/driver"
"fmt"

"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/feature/rds/auth"
"github.com/formancehq/stack/libs/go-libs/logging"
Expand Down
1 change: 1 addition & 0 deletions components/ledger/libs/bun/bunconnect/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package bunconnect

import (
"context"

"github.com/formancehq/stack/libs/go-libs/logging"
"github.com/uptrace/bun"
"go.uber.org/fx"
Expand Down
1 change: 1 addition & 0 deletions components/ledger/libs/bun/bunmigrate/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/formancehq/stack/libs/go-libs/bun/bunconnect"
"github.com/spf13/cobra"
"github.com/uptrace/bun"

// Import the postgres driver.
_ "github.com/lib/pq"
)
Expand Down
3 changes: 2 additions & 1 deletion components/ledger/libs/bun/bunmigrate/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"context"
"database/sql"
"fmt"
"io"

"github.com/formancehq/stack/libs/go-libs/bun/bunconnect"
sharedlogging "github.com/formancehq/stack/libs/go-libs/logging"
"github.com/formancehq/stack/libs/go-libs/pointer"
Expand All @@ -14,7 +16,6 @@ import (
"github.com/uptrace/bun"
"github.com/uptrace/bun/extra/bundebug"
"github.com/xo/dburl"
"io"
)

func isDatabaseExists(ctx context.Context, db *bun.DB, name string) (bool, error) {
Expand Down
6 changes: 3 additions & 3 deletions components/ledger/libs/bun/bunmigrate/run_test.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package bunmigrate

import (
"os"
"testing"

"github.com/formancehq/stack/libs/go-libs/bun/bunconnect"
"github.com/formancehq/stack/libs/go-libs/logging"
"github.com/formancehq/stack/libs/go-libs/pgtesting"
"github.com/stretchr/testify/require"
"github.com/uptrace/bun"
"os"
"testing"
)

func TestRunMigrate(t *testing.T) {
Expand All @@ -19,7 +20,6 @@ func TestRunMigrate(t *testing.T) {
connectionOptions := &bunconnect.ConnectionOptions{
DatabaseSourceName: pgtesting.Server().GetDatabaseDSN("testing"),
Debug: testing.Verbose(),
Writer: os.Stdout,
}
executor := func(args []string, db *bun.DB) error {
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package bunpaginate_test

import (
"context"
"math/big"
"testing"

"github.com/formancehq/stack/libs/go-libs/bun/bunconnect"
bunpaginate2 "github.com/formancehq/stack/libs/go-libs/bun/bunpaginate"
"github.com/formancehq/stack/libs/go-libs/logging"
"math/big"
"testing"

"github.com/formancehq/stack/libs/go-libs/pgtesting"
"github.com/stretchr/testify/require"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package bunpaginate_test

import (
"context"
"testing"

"github.com/formancehq/stack/libs/go-libs/bun/bunconnect"
bunpaginate2 "github.com/formancehq/stack/libs/go-libs/bun/bunpaginate"
"github.com/formancehq/stack/libs/go-libs/logging"
"testing"

"github.com/formancehq/stack/libs/go-libs/pgtesting"
"github.com/stretchr/testify/require"
Expand Down
1 change: 0 additions & 1 deletion components/ledger/libs/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ toolchain go1.21.5

require (
github.com/IBM/sarama v1.42.1
github.com/Shopify/sarama v1.38.1
github.com/ThreeDotsLabs/watermill v1.3.5
github.com/ThreeDotsLabs/watermill-http/v2 v2.1.0
github.com/ThreeDotsLabs/watermill-kafka/v3 v3.0.0
Expand Down
4 changes: 0 additions & 4 deletions components/ledger/libs/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2y
github.com/Microsoft/go-winio v0.6.0/go.mod h1:cTAf44im0RAYeL23bpB+fzCyDH2MJiz2BO69KH/soAE=
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw=
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk=
github.com/Shopify/sarama v1.38.1 h1:lqqPUPQZ7zPqYlWpTh+LQ9bhYNu2xJL6k1SJN4WVe2A=
github.com/Shopify/sarama v1.38.1/go.mod h1:iwv9a67Ha8VNa+TifujYoWGxWnu2kNVAQdSdZ4X2o5g=
github.com/Shopify/toxiproxy/v2 v2.5.0 h1:i4LPT+qrSlKNtQf5QliVjdP08GyAH8+BUIc9gT0eahc=
github.com/Shopify/toxiproxy/v2 v2.5.0/go.mod h1:yhM2epWtAmel9CB8r2+L+PCmhH6yH2pITaPAo7jxJl0=
github.com/ThreeDotsLabs/watermill v1.2.0/go.mod h1:IuVxGk/kgCN0cex2S94BLglUiB0PwOm8hbUhm6g2Nx4=
github.com/ThreeDotsLabs/watermill v1.3.5 h1:50JEPEhMGZQMh08ct0tfO1PsgMOAOhV3zxK2WofkbXg=
github.com/ThreeDotsLabs/watermill v1.3.5/go.mod h1:O/u/Ptyrk5MPTxSeWM5vzTtZcZfxXfO9PK9eXTYiFZY=
Expand Down
4 changes: 3 additions & 1 deletion components/ledger/libs/httpserver/serverport.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"net"
"net/http"
"strconv"
"time"

"github.com/formancehq/stack/libs/go-libs/logging"

Expand Down Expand Up @@ -80,7 +81,8 @@ func (s *server) StartServer(ctx context.Context, handler http.Handler, options
StartedServer(ctx, s.listener)

srv := &http.Server{
Handler: handler,
Handler: handler,
ReadHeaderTimeout: 10 * time.Second,
}
for _, option := range options {
option(srv)
Expand Down
3 changes: 2 additions & 1 deletion components/ledger/libs/migrations/migrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import (
"context"
"database/sql"
"fmt"
"github.com/lib/pq"
"time"

"github.com/lib/pq"

"github.com/pkg/errors"
"github.com/uptrace/bun"
)
Expand Down
3 changes: 2 additions & 1 deletion components/ledger/libs/pgtesting/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import (
"context"
"database/sql"
"fmt"
"github.com/formancehq/stack/libs/go-libs/bun/bunconnect"
"os"
"strconv"
"sync"
"testing"
"time"

"github.com/formancehq/stack/libs/go-libs/bun/bunconnect"

"github.com/google/uuid"
_ "github.com/lib/pq"
"github.com/ory/dockertest/v3"
Expand Down
3 changes: 2 additions & 1 deletion components/ledger/libs/publish/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package publish
import (
"context"
"encoding/json"
"time"

"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/propagation"
"go.opentelemetry.io/otel/trace"
"time"

"github.com/ThreeDotsLabs/watermill/message"
"github.com/google/uuid"
Expand Down
1 change: 1 addition & 0 deletions components/ledger/libs/publish/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package publish

import (
"context"

"github.com/ThreeDotsLabs/watermill"
"github.com/ThreeDotsLabs/watermill/message"
"github.com/ThreeDotsLabs/watermill/pubsub/gochannel"
Expand Down
9 changes: 5 additions & 4 deletions components/ledger/libs/publish/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ package publish
import (
"context"
"fmt"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/propagation"
tracesdk "go.opentelemetry.io/otel/sdk/trace"
"go.opentelemetry.io/otel/trace"
"io"
"os"
"testing"
"time"

"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/propagation"
tracesdk "go.opentelemetry.io/otel/sdk/trace"
"go.opentelemetry.io/otel/trace"

"github.com/IBM/sarama"
"github.com/ThreeDotsLabs/watermill/message"
"github.com/formancehq/stack/libs/go-libs/logging"
Expand Down
5 changes: 3 additions & 2 deletions components/ledger/libs/service/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package service

import (
"context"
"io"
"os"

"github.com/formancehq/stack/libs/go-libs/logging"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"go.uber.org/fx"
"io"
"os"
)

const DebugFlag = "debug"
Expand Down
12 changes: 0 additions & 12 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
module github.com/formancehq/stack

go 1.20

require (
github.com/pkg/errors v0.9.1
github.com/xeipuuv/gojsonschema v1.2.0
golang.org/x/mod v0.12.0
gopkg.in/yaml.v3 v3.0.1
)

require (
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
)
22 changes: 0 additions & 22 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,22 +0,0 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c=
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0=
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Loading