Skip to content
This repository was archived by the owner on Jan 15, 2023. It is now read-only.

Commit e1d00b7

Browse files
authored
Merge pull request #7 from renanbastos93/master
chore: fixed gosec and update fiber version
2 parents 58ce29b + dfbb54f commit e1d00b7

9 files changed

Lines changed: 39 additions & 21 deletions

File tree

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.14
44

55
require (
66
github.com/fasthttp/session/v2 v2.1.0
7-
github.com/gofiber/fiber v1.10.1
7+
github.com/gofiber/fiber v1.11.0
88
github.com/google/uuid v1.1.1
9-
github.com/valyala/fasthttp v1.13.1
9+
github.com/valyala/fasthttp v1.14.0
1010
)

go.sum

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ github.com/go-redis/redis/v8 v8.0.0-beta.2 h1:9S28J9QMBotgI3tGgXbX1Wk9i8QYC3Orw4
2626
github.com/go-redis/redis/v8 v8.0.0-beta.2/go.mod h1:o1M7JtsgfDYyv3o+gBn/jJ1LkqpnCrmil7PSppZGBak=
2727
github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
2828
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
29-
github.com/gofiber/fiber v1.10.1 h1:sfxWGvNOYoK8gNciZVfJ0XS7UTPz3+Zlb/fYGWsywNY=
30-
github.com/gofiber/fiber v1.10.1/go.mod h1:8083zyrwS9acYIAgpYPbXPW80m57uc8WPzPF3wt1qNk=
31-
github.com/gofiber/utils v0.0.3 h1:nNQKfZbZAGmOHqTOYplJwwOvX1Mg/NsTjfFO4/wTGrU=
32-
github.com/gofiber/utils v0.0.3/go.mod h1:pacRFtghAE3UoknMOUiXh2Io/nLWSUHtQCi/3QASsOc=
29+
github.com/gofiber/fiber v1.11.0 h1:7mk1bOs0HQ3x3GPwmLfr4/um/MHPaj98jNFUk1jDj2M=
30+
github.com/gofiber/fiber v1.11.0/go.mod h1:yFeAjCJH91bgsVXSRuJ8phno0O6/PcGHvjndFw91Vxs=
31+
github.com/gofiber/utils v0.0.6 h1:lWuJfXQ06aFPVA2/y7lUw9ahS4TuXhbwXnxKl1D/fuY=
32+
github.com/gofiber/utils v0.0.6/go.mod h1:pacRFtghAE3UoknMOUiXh2Io/nLWSUHtQCi/3QASsOc=
3333
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
3434
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
3535
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
@@ -82,6 +82,8 @@ github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6Kllzaw
8282
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
8383
github.com/valyala/fasthttp v1.13.1 h1:Z7kVhKP9NZz+tCSY7AVhCMPPAk7b+e5fq0l/BfdTlFc=
8484
github.com/valyala/fasthttp v1.13.1/go.mod h1:ol1PCaL0dX20wC0htZ7sYCsvCYmrouYra0zHzaclZhE=
85+
github.com/valyala/fasthttp v1.14.0 h1:67bfuW9azCMwW/Jlq/C+VeihNpAuJMWkYPBig1gdi3A=
86+
github.com/valyala/fasthttp v1.14.0/go.mod h1:ol1PCaL0dX20wC0htZ7sYCsvCYmrouYra0zHzaclZhE=
8587
github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio=
8688
go.opentelemetry.io/otel v0.5.0 h1:tdIR1veg/z+VRJaw/6SIxz+QX3l+m+BDleYLTs+GC1g=
8789
go.opentelemetry.io/otel v0.5.0/go.mod h1:jzBIgIzK43Iu1BpDAXwqOd6UPsSAk+ewVZ5ofSXw4Ek=

provider/memcache/memcache.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
package memcache
77

88
import (
9-
"fmt"
109
"time"
1110

1211
memcache "github.com/fasthttp/session/v2/providers/memcache"
12+
utils "github.com/gofiber/session/provider"
1313
)
1414

1515
// Config memcache options
@@ -44,7 +44,7 @@ func New(config ...Config) *memcache.Provider {
4444
MaxIdleConns: cfg.MaxIdleConns,
4545
})
4646
if err != nil {
47-
fmt.Errorf("session: memcache %v", err)
47+
utils.ErrorProvider("memcache", err)
4848
}
4949
return provider
5050
}

provider/mysql/mysql.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
package mysql
77

88
import (
9-
"fmt"
109
"time"
1110

1211
mysql "github.com/fasthttp/session/v2/providers/mysql"
12+
utils "github.com/gofiber/session/provider"
1313
)
1414

1515
// Config MySQL options
@@ -94,7 +94,7 @@ func New(config ...Config) *mysql.Provider {
9494
ConnMaxLifetime: cfg.ConnMaxLifetime,
9595
})
9696
if err != nil {
97-
fmt.Errorf("session: mysql %v", err)
97+
utils.ErrorProvider("mysql", err)
9898
}
9999
return provider
100100
}

provider/postgres/postgres.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
package postgres
77

88
import (
9-
"fmt"
109
"time"
1110

1211
postgres "github.com/fasthttp/session/v2/providers/postgre"
12+
utils "github.com/gofiber/session/provider"
1313
)
1414

1515
// Config Postgres options
@@ -72,7 +72,7 @@ func New(config ...Config) *postgres.Provider {
7272
ConnMaxLifetime: cfg.ConnMaxLifetime,
7373
})
7474
if err != nil {
75-
fmt.Errorf("session: postgres %v", err)
75+
utils.ErrorProvider("postgres", err)
7676
}
7777
return provider
7878
}

provider/redis/redis.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ package redis
77

88
import (
99
"crypto/tls"
10-
"fmt"
1110
"time"
1211

1312
"github.com/fasthttp/session/v2/providers/redis"
13+
utils "github.com/gofiber/session/provider"
1414
)
1515

1616
// Config Redis options
@@ -77,7 +77,7 @@ func New(config ...Config) *redis.Provider {
7777
// Limiter cfg.Limiter,
7878
})
7979
if err != nil {
80-
fmt.Errorf("session: redis %v", err)
80+
utils.ErrorProvider("redis", err)
8181
}
8282
return provider
8383
}

provider/sqlite3/sqlite3.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
package sqlite3
77

88
import (
9-
"fmt"
109
"time"
1110

1211
sqlite3 "github.com/fasthttp/session/v2/providers/sqlite3"
12+
utils "github.com/gofiber/session/provider"
1313
)
1414

1515
// Config redis options
@@ -50,7 +50,7 @@ func New(config ...Config) *sqlite3.Provider {
5050
ConnMaxLifetime: cfg.ConnMaxLifetime,
5151
})
5252
if err != nil {
53-
fmt.Errorf("session: sqlite3 %v", err)
53+
utils.ErrorProvider("sqlite3", err)
5454
}
5555
return provider
5656
}

provider/utils.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package provider
2+
3+
import (
4+
"fmt"
5+
"log"
6+
)
7+
8+
// ErrorProvider ...
9+
func ErrorProvider(provider string, err error) {
10+
if e := fmt.Errorf("session: %v %v", provider, err); e != nil {
11+
log.Printf("session error: %v; provider: %v;", e, provider)
12+
}
13+
}

store.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,14 @@ func (s *Store) ID() string {
2323
}
2424

2525
// Save storage before response
26-
func (s *Store) Save() {
27-
s.sess.core.Save(s.ctx.Fasthttp, s.core)
26+
func (s *Store) Save() error {
27+
if err := s.sess.core.Save(s.ctx.Fasthttp, s.core); err != nil {
28+
return err
29+
}
2830
if s.sess.config.noCookie {
2931
s.ctx.Fasthttp.Response.Header.Del("Set-Cookie")
3032
}
33+
return nil
3134
}
3235

3336
// Get get data by key
@@ -47,11 +50,11 @@ func (s *Store) Delete(key string) {
4750

4851
// Destroy session and cookies
4952
func (s *Store) Destroy() {
50-
s.sess.core.Destroy(s.ctx.Fasthttp)
53+
_ = s.sess.core.Destroy(s.ctx.Fasthttp)
5154
}
5255

5356
// Regenerate session id
54-
func (s *Store) Regenerate() {
57+
func (s *Store) Regenerate() error {
5558
// https://github.com/fasthttp/session/blob/master/session.go#L205
56-
s.sess.core.Regenerate(s.ctx.Fasthttp)
59+
return s.sess.core.Regenerate(s.ctx.Fasthttp)
5760
}

0 commit comments

Comments
 (0)