aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Erik Dubbelboer <erik@dubbelboer.com> 2023-08-26 12:49:17 +0200
committerGravatar GitHub <noreply@github.com> 2023-08-26 12:49:17 +0200
commit0e99e64ee836adc5a3c4b35a0d8148900c2e7898 (patch)
tree74ed52ccb6d24a75f6e25d0f52b62e3050bef387
parentfix round2_32, split round2 tests because they depend on sizeof int at compil... (diff)
downloadfasthttp-0e99e64ee836adc5a3c4b35a0d8148900c2e7898.tar.gz
fasthttp-0e99e64ee836adc5a3c4b35a0d8148900c2e7898.tar.bz2
fasthttp-0e99e64ee836adc5a3c4b35a0d8148900c2e7898.zip
Update golangci-lint and gosec (#1609)v1.49.0
-rw-r--r--.github/workflows/lint.yml2
-rw-r--r--.github/workflows/security.yml2
-rw-r--r--b2s_old.go1
-rw-r--r--client.go1
-rw-r--r--fasthttpadaptor/b2s_new.go12
-rw-r--r--fasthttpadaptor/b2s_old.go15
-rw-r--r--fasthttpadaptor/request.go6
-rw-r--r--headers.go2
-rw-r--r--lbclient.go2
-rw-r--r--s2b_old.go2
10 files changed, 32 insertions, 13 deletions
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index c73bf09..cb93f25 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -16,5 +16,5 @@ jobs:
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
with:
- version: v1.51.1
+ version: v1.54.2
args: --enable=nolintlint,gochecknoinits,bodyclose,gofumpt --verbose
diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml
index bf0b4b3..5c592ad 100644
--- a/.github/workflows/security.yml
+++ b/.github/workflows/security.yml
@@ -16,6 +16,6 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Run Gosec Security Scanner
- uses: securego/gosec@v2.14.0
+ uses: securego/gosec@v2.17.0
with:
args: '-exclude=G104,G304,G402 ./...'
diff --git a/b2s_old.go b/b2s_old.go
index f1d3228..6b9f799 100644
--- a/b2s_old.go
+++ b/b2s_old.go
@@ -11,6 +11,5 @@ import "unsafe"
// Note it may break if string and/or slice header will change
// in the future go versions.
func b2s(b []byte) string {
- /* #nosec G103 */
return *(*string)(unsafe.Pointer(&b))
}
diff --git a/client.go b/client.go
index 5223031..ae005d7 100644
--- a/client.go
+++ b/client.go
@@ -581,6 +581,7 @@ func (c *Client) mCleaner(m map[string]*HostClient) {
c.mLock.Lock()
for k, v := range m {
v.connsLock.Lock()
+ /* #nosec G601 */
if v.connsCount == 0 && atomic.LoadInt32(&v.pendingClientRequests) == 0 {
delete(m, k)
}
diff --git a/fasthttpadaptor/b2s_new.go b/fasthttpadaptor/b2s_new.go
new file mode 100644
index 0000000..09ef72a
--- /dev/null
+++ b/fasthttpadaptor/b2s_new.go
@@ -0,0 +1,12 @@
+//go:build go1.20
+// +build go1.20
+
+package fasthttpadaptor
+
+import "unsafe"
+
+// b2s converts byte slice to a string without memory allocation.
+// See https://groups.google.com/forum/#!msg/Golang-Nuts/ENgbUzYvCuU/90yGx7GUAgAJ .
+func b2s(b []byte) string {
+ return unsafe.String(unsafe.SliceData(b), len(b))
+}
diff --git a/fasthttpadaptor/b2s_old.go b/fasthttpadaptor/b2s_old.go
new file mode 100644
index 0000000..08e2ac6
--- /dev/null
+++ b/fasthttpadaptor/b2s_old.go
@@ -0,0 +1,15 @@
+//go:build !go1.20
+// +build !go1.20
+
+package fasthttpadaptor
+
+import "unsafe"
+
+// b2s converts byte slice to a string without memory allocation.
+// See https://groups.google.com/forum/#!msg/Golang-Nuts/ENgbUzYvCuU/90yGx7GUAgAJ .
+//
+// Note it may break if string and/or slice header will change
+// in the future go versions.
+func b2s(b []byte) string {
+ return *(*string)(unsafe.Pointer(&b))
+}
diff --git a/fasthttpadaptor/request.go b/fasthttpadaptor/request.go
index 827ab92..62a8523 100644
--- a/fasthttpadaptor/request.go
+++ b/fasthttpadaptor/request.go
@@ -5,7 +5,6 @@ import (
"io"
"net/http"
"net/url"
- "unsafe"
"github.com/valyala/fasthttp"
)
@@ -65,8 +64,3 @@ func ConvertRequest(ctx *fasthttp.RequestCtx, r *http.Request, forServer bool) e
return nil
}
-
-func b2s(b []byte) string {
- /* #nosec G103 */
- return *(*string)(unsafe.Pointer(&b))
-}
diff --git a/headers.go b/headers.go
index 676a0da..9d6d0a3 100644
--- a/headers.go
+++ b/headers.go
@@ -136,7 +136,7 @@ const (
// WebSockets
HeaderSecWebSocketAccept = "Sec-WebSocket-Accept"
- HeaderSecWebSocketExtensions = "Sec-WebSocket-Extensions"
+ HeaderSecWebSocketExtensions = "Sec-WebSocket-Extensions" /* #nosec G101 */
HeaderSecWebSocketKey = "Sec-WebSocket-Key"
HeaderSecWebSocketProtocol = "Sec-WebSocket-Protocol"
HeaderSecWebSocketVersion = "Sec-WebSocket-Version"
diff --git a/lbclient.go b/lbclient.go
index 6be2dc9..7fd8a93 100644
--- a/lbclient.go
+++ b/lbclient.go
@@ -138,7 +138,7 @@ func (cc *LBClient) get() *lbClient {
minT := atomic.LoadUint64(&minC.total)
for _, c := range cs[1:] {
n := c.PendingRequests()
- t := atomic.LoadUint64(&c.total)
+ t := atomic.LoadUint64(&c.total) /* #nosec G601 */
if n < minN || (n == minN && t < minT) {
minC = c
minN = n
diff --git a/s2b_old.go b/s2b_old.go
index 4cc141c..d269cba 100644
--- a/s2b_old.go
+++ b/s2b_old.go
@@ -13,9 +13,7 @@ import (
// Note it may break if string and/or slice header will change
// in the future go versions.
func s2b(s string) (b []byte) {
- /* #nosec G103 */
bh := (*reflect.SliceHeader)(unsafe.Pointer(&b))
- /* #nosec G103 */
sh := (*reflect.StringHeader)(unsafe.Pointer(&s))
bh.Data = sh.Data
bh.Cap = sh.Len