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
[TT-11755] fix lint errors (staticcheck.bug.err) #6196
base: master
Are you sure you want to change the base?
Conversation
API Changes --- prev.txt 2024-03-28 16:37:10.004026636 +0000
+++ current.txt 2024-03-28 16:37:07.176011555 +0000
@@ -4692,7 +4692,7 @@
func WriteConf(path string, conf *Config) error
func WriteDefault(path string, conf *Config) error
- writeDefault will set conf to the default config and write it to disk in
+ WriteDefault will set conf to the default config and write it to disk in
path, if the path is non-empty.
|
💥 CI tests failed 🙈git-statediff --git a/ci/tests/plugin-compiler/testdata/basic-plugin/test_goplugin.go b/ci/tests/plugin-compiler/testdata/basic-plugin/test_goplugin.go
index 5e401ff..fc0091d 100644
--- a/ci/tests/plugin-compiler/testdata/basic-plugin/test_goplugin.go
+++ b/ci/tests/plugin-compiler/testdata/basic-plugin/test_goplugin.go
@@ -6,7 +6,6 @@ import (
"encoding/base64"
"encoding/json"
"io"
- "io/ioutil"
"net/http"
"github.com/buger/jsonparser"
diff --git a/ci/tests/plugin-compiler/testdata/complex-plugin/plugin/plugin.go b/ci/tests/plugin-compiler/testdata/complex-plugin/plugin/plugin.go
index 12ec662..4492b65 100644
--- a/ci/tests/plugin-compiler/testdata/complex-plugin/plugin/plugin.go
+++ b/ci/tests/plugin-compiler/testdata/complex-plugin/plugin/plugin.go
@@ -3,7 +3,7 @@ package plugin
import (
"bytes"
"encoding/json"
- "io/ioutil"
+ "io"
"net/http"
"github.com/TykTechnologies/tyk/ctx"
diff --git a/cli/bundler/bundler_test.go b/cli/bundler/bundler_test.go
index 8d9b2c8..da075b6 100644
--- a/cli/bundler/bundler_test.go
+++ b/cli/bundler/bundler_test.go
@@ -8,9 +8,10 @@ import (
"strings"
"testing"
- "github.com/TykTechnologies/tyk/apidef"
"github.com/stretchr/testify/assert"
+ "github.com/TykTechnologies/tyk/apidef"
+
kingpin "github.com/alecthomas/kingpin/v2"
)
diff --git a/gateway/coprocess.go b/gateway/coprocess.go
index 6cc7445..4645a9f 100644
--- a/gateway/coprocess.go
+++ b/gateway/coprocess.go
@@ -19,7 +19,6 @@ import (
"errors"
"fmt"
- "io/ioutil"
"net/http"
)
diff --git a/gateway/coprocess_id_extractor.go b/gateway/coprocess_id_extractor.go
index 19c43c3..96900e0 100644
--- a/gateway/coprocess_id_extractor.go
+++ b/gateway/coprocess_id_extractor.go
@@ -4,7 +4,7 @@ import (
"crypto/md5"
"errors"
"fmt"
- "io/ioutil"
+ "io"
"net/http"
"strings"
"time"
diff --git a/gateway/coprocess_lua.go b/gateway/coprocess_lua.go
index 07fa3fd..f05d799 100644
--- a/gateway/coprocess_lua.go
+++ b/gateway/coprocess_lua.go
@@ -70,6 +70,7 @@ import (
"encoding/json"
"errors"
"io/ioutil"
+ "os"
"path/filepath"
"unsafe"
diff --git a/gateway/event_handler_webhooks.go b/gateway/event_handler_webhooks.go
index 0cccefc..bb53128 100644
--- a/gateway/event_handler_webhooks.go
+++ b/gateway/event_handler_webhooks.go
@@ -6,7 +6,7 @@ import (
"encoding/hex"
"encoding/json"
htmlTemplate "html/template"
- "io/ioutil"
+ "io"
"net/http"
"net/url"
"path/filepath"
diff --git a/gateway/gateway_test.go b/gateway/gateway_test.go
index 5b80e1a..979dc39 100644
--- a/gateway/gateway_test.go
+++ b/gateway/gateway_test.go
@@ -5,7 +5,7 @@ import (
"context"
"encoding/json"
"fmt"
- "io/ioutil"
+ "io"
"net"
"net/http"
"net/http/httptest"
diff --git a/gateway/grpc_test.go b/gateway/grpc_test.go
index 2fa452d..64c1700 100644
--- a/gateway/grpc_test.go
+++ b/gateway/grpc_test.go
@@ -16,9 +16,10 @@ import (
"testing"
"time"
- "github.com/TykTechnologies/tyk/certs"
"google.golang.org/grpc/credentials/insecure"
+ "github.com/TykTechnologies/tyk/certs"
+
"github.com/TykTechnologies/tyk/config"
"google.golang.org/grpc/metadata"
diff --git a/gateway/handler_error.go b/gateway/handler_error.go
index 26d092a..0b3382d 100644
--- a/gateway/handler_error.go
+++ b/gateway/handler_error.go
@@ -6,7 +6,6 @@ import (
"errors"
htmlTemplate "html/template"
"io"
- "io/ioutil"
"net/http"
"strconv"
"strings"
diff --git a/gateway/handler_success.go b/gateway/handler_success.go
index ab85108..abcba2c 100644
--- a/gateway/handler_success.go
+++ b/gateway/handler_success.go
@@ -4,7 +4,6 @@ import (
"bytes"
"encoding/base64"
"io"
- "io/ioutil"
"net/http"
"strconv"
"strings"
diff --git a/gateway/middleware.go b/gateway/middleware.go
index 21c7b50..16001f6 100644
--- a/gateway/middleware.go
+++ b/gateway/middleware.go
@@ -7,7 +7,6 @@ import (
"errors"
"fmt"
"io"
- "io/ioutil"
"net/http"
"strconv"
"time"
diff --git a/gateway/middleware_test.go b/gateway/middleware_test.go
index 26ca8d8..9457fda 100644
--- a/gateway/middleware_test.go
+++ b/gateway/middleware_test.go
@@ -3,7 +3,7 @@ package gateway
import (
"encoding/json"
"fmt"
- "io/ioutil"
+ "io"
"net/http"
"testing"
"time"
diff --git a/gateway/mw_basic_auth.go b/gateway/mw_basic_auth.go
index 781277b..576a70e 100644
--- a/gateway/mw_basic_auth.go
+++ b/gateway/mw_basic_auth.go
@@ -4,7 +4,7 @@ import (
"bytes"
"encoding/base64"
"errors"
- "io/ioutil"
+ "io"
"net/http"
"strings"
diff --git a/gateway/mw_go_plugin.go b/gateway/mw_go_plugin.go
index 46ddc0c..f00d358 100644
--- a/gateway/mw_go_plugin.go
+++ b/gateway/mw_go_plugin.go
@@ -5,7 +5,7 @@ import (
"context"
"errors"
"fmt"
- "io/ioutil"
+ "io"
"net/http"
"time"
diff --git a/gateway/mw_transform.go b/gateway/mw_transform.go
index f0e81d2..61ad61b 100644
--- a/gateway/mw_transform.go
+++ b/gateway/mw_transform.go
@@ -5,7 +5,6 @@ import (
"encoding/json"
"fmt"
"io"
- "io/ioutil"
"net/http"
"github.com/clbanning/mxj"
diff --git a/gateway/mw_transform_jq.go b/gateway/mw_transform_jq.go
index 21aa23f..640eeab 100644
--- a/gateway/mw_transform_jq.go
+++ b/gateway/mw_transform_jq.go
@@ -8,7 +8,6 @@ import (
"encoding/json"
"errors"
"io"
- "io/ioutil"
"net/http"
"github.com/sirupsen/logrus"
diff --git a/gateway/mw_transform_test.go b/gateway/mw_transform_test.go
index 9351b78..cc0fe05 100644
--- a/gateway/mw_transform_test.go
+++ b/gateway/mw_transform_test.go
@@ -2,7 +2,7 @@ package gateway
import (
"encoding/base64"
- "io/ioutil"
+ "io"
"net/http"
"strings"
"testing"
diff --git a/gateway/mw_url_rewrite.go b/gateway/mw_url_rewrite.go
index 9b1e2dc..4080ae1 100644
--- a/gateway/mw_url_rewrite.go
+++ b/gateway/mw_url_rewrite.go
@@ -2,7 +2,7 @@ package gateway
import (
"fmt"
- "io/ioutil"
+ "io"
"net/http"
"net/textproto"
"net/url"
diff --git a/gateway/mw_validate_json.go b/gateway/mw_validate_json.go
index 5ff72ff..82d041b 100644
--- a/gateway/mw_validate_json.go
+++ b/gateway/mw_validate_json.go
@@ -3,7 +3,7 @@ package gateway
import (
"errors"
"fmt"
- "io/ioutil"
+ "io"
"net/http"
"github.com/TykTechnologies/gojsonschema"
diff --git a/gateway/mw_virtual_endpoint.go b/gateway/mw_virtual_endpoint.go
index 2bdde8a..f422f79 100644
--- a/gateway/mw_virtual_endpoint.go
+++ b/gateway/mw_virtual_endpoint.go
@@ -7,7 +7,6 @@ import (
"errors"
"fmt"
"io"
- "io/ioutil"
"net/http"
"net/url"
"os"
diff --git a/gateway/policy.go b/gateway/policy.go
index a8e9211..9a5b8d8 100644
--- a/gateway/policy.go
+++ b/gateway/policy.go
@@ -3,7 +3,7 @@ package gateway
import (
"encoding/json"
"errors"
- "io/ioutil"
+ "io"
"net/http"
"os"
"path/filepath"
diff --git a/gateway/proxy_muxer_test.go b/gateway/proxy_muxer_test.go
index 74729b5..16d70f0 100644
--- a/gateway/proxy_muxer_test.go
+++ b/gateway/proxy_muxer_test.go
@@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"io"
- "io/ioutil"
"net"
"net/http"
"net/http/httptest"
diff --git a/gateway/res_handler_jq_transform.go b/gateway/res_handler_jq_transform.go
index 3d31b2a..69d55d8 100644
--- a/gateway/res_handler_jq_transform.go
+++ b/gateway/res_handler_jq_transform.go
@@ -6,7 +6,7 @@ package gateway
import (
"bytes"
"encoding/json"
- "io/ioutil"
+ "io"
"net/http"
"strconv"
diff --git a/gateway/res_handler_transform.go b/gateway/res_handler_transform.go
index 294bbb1..11485b3 100644
--- a/gateway/res_handler_transform.go
+++ b/gateway/res_handler_transform.go
@@ -6,7 +6,6 @@ import (
"compress/gzip"
"encoding/json"
"io"
- "io/ioutil"
"net/http"
"strconv"
diff --git a/gateway/service_discovery.go b/gateway/service_discovery.go
index b565aa7..16be34b 100644
--- a/gateway/service_discovery.go
+++ b/gateway/service_discovery.go
@@ -1,7 +1,7 @@
package gateway
import (
- "io/ioutil"
+ "io"
"net/http"
"strconv"
"strings"
diff --git a/gateway/tracing_test.go b/gateway/tracing_test.go
index c695fe8..91dfc74 100644
--- a/gateway/tracing_test.go
+++ b/gateway/tracing_test.go
@@ -1,7 +1,7 @@
package gateway
import (
- "io/ioutil"
+ "io"
"net/http"
"testing"
diff --git a/go.mod b/go.mod
index 1f22b54..a255b10 100644
--- a/go.mod
+++ b/go.mod
@@ -35,7 +35,7 @@ require (
github.com/gocraft/health v0.0.0-20170925182251-8675af27fef0
github.com/gofrs/uuid v4.4.0+incompatible
github.com/golang-jwt/jwt/v4 v4.5.0
- github.com/golang/protobuf v1.5.3
+ github.com/golang/protobuf v1.5.3 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/mux v1.8.1
github.com/gorilla/websocket v1.5.1
diff --git a/test/goplugins/test_goplugin.go b/test/goplugins/test_goplugin.go
index 4d55cb1..3ef1074 100644
--- a/test/goplugins/test_goplugin.go
+++ b/test/goplugins/test_goplugin.go
@@ -5,7 +5,7 @@ import (
"bytes"
"encoding/base64"
"encoding/json"
- "io/ioutil"
+ "io"
"net/http"
"github.com/buger/jsonparser" Please look at the run or in the Checks tab. |
PR Description updated to latest commit (e137cbb) |
PR Review
Code feedback:
✨ Review tool usage guide:Overview: The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on any PR.
See the review usage page for a comprehensive guide on using this tool. |
PR Code Suggestions
✨ Improve tool usage guide:Overview:
See the improve usage page for a comprehensive guide on using this tool. |
@@ -415,7 +415,7 @@ | |||
// fallback to file | |||
if err != nil { | |||
// Try read from file | |||
rawCert, err = ioutil.ReadFile(id) | |||
rawCert, err = os.ReadFile(id) |
Check failure
Code scanning / CodeQL
Uncontrolled data used in path expression High
user-provided value
@@ -939,7 +938,7 @@ | |||
return apiError("Marshalling failed"), http.StatusInternalServerError | |||
} | |||
|
|||
if err := ioutil.WriteFile(polFilePath, asByte, 0644); err != nil { | |||
if err := os.WriteFile(polFilePath, asByte, 0644); err != nil { |
Check failure
Code scanning / CodeQL
Uncontrolled data used in path expression High
user-provided value
@@ -1266,7 +1265,7 @@ | |||
return errors.New("marshalling failed"), http.StatusInternalServerError | |||
} | |||
|
|||
if err := ioutil.WriteFile(defFilePath, asByte, 0644); err != nil { | |||
if err := os.WriteFile(defFilePath, asByte, 0644); err != nil { |
Check failure
Code scanning / CodeQL
Uncontrolled data used in path expression High
user-provided value
This path depends on a
User description
Description
Related Issue
Motivation and Context
How This Has Been Tested
Screenshots (if appropriate)
Types of changes
Checklist
Type
enhancement
Changes walkthrough
60 files
notifications.go
Replace deprecated ioutil with io package in notifications.go
apidef/notifications.go
ioutil
withio
forReadAll
method.root_test.go
Remove unnecessary break statement in root_test.go
apidef/oas/root_test.go
break
statement in a switch case.manager.go
Replace deprecated ioutil with os package in manager.go
certs/manager.go
ioutil
withos
forReadFile
method.manager_test.go
Use os package for file operations in manager_test.go
certs/manager_test.go
ioutil
withos
for temporary directory creation and filewriting.
test_goplugin.go
Replace deprecated ioutil with io package in test_goplugin.go
ci/tests/plugin-compiler/testdata/basic-plugin/test_goplugin.go
ioutil
withio
forNopCloser
method.plugin.go
Replace deprecated ioutil with io package in plugin.go
ci/tests/plugin-compiler/testdata/complex-plugin/plugin/plugin.go
ioutil
withio
forNopCloser
method.bundler.go
Use os package for file operations in bundler.go
cli/bundler/bundler.go
ioutil
withos
for file operations.bundler_test.go
Use os package and improve error checking in bundler_test.go
cli/bundler/bundler_test.go
ioutil
withos
for file writing and temporary directorycreation.
assert.NoError
for error checking.cli.go
Replace deprecated ioutil with os package in cli.go
cli/cli.go
ioutil
withos
for reading files.linter_test.go
Use os package for file operations in linter_test.go
cli/linter/linter_test.go
ioutil
withos
for file operations.config.go
Replace deprecated ioutil with os package in config.go
config/config.go
ioutil
withos
for file writing.config_test.go
Use os package and improve error checking in config_test.go
config/config_test.go
ioutil
withos
for file operations.assert.NoError
for error checking.coprocess_test.go
Update session creation method in coprocess_test.go
coprocess/coprocess_test.go
CreateSession
withCreateSession
and keyID return in tests.coprocess_grpc_test.go
Update session creation and replace deprecated ioutil in
coprocess_grpc_test.go
coprocess/grpc/coprocess_grpc_test.go
ioutil
withio
for reading response body.CreateSession
withCreateSession
and keyID return in tests.coprocess_python_test.go
Update session creation method in coprocess_python_test.go
coprocess/python/coprocess_python_test.go
CreateSession
withCreateSession
and keyID return in tests.analytics.go
Use thread-safe rand instance in analytics.go
gateway/analytics.go
mathRand.Seed
with newrand
instance for thread safety.api.go
Replace deprecated ioutil with io and os packages in api.go
gateway/api.go
ioutil
withio
for reading and closing request body.ioutil
withos
for file writing.api_definition.go
Replace deprecated ioutil with io package in api_definition.go
gateway/api_definition.go
ioutil
withio
for reading response body.api_definition_test.go
Use os package for file operations in api_definition_test.go
gateway/api_definition_test.go
ioutil
withos
for reading files.api_test.go
Replace deprecated ioutil with io package in api_test.go
gateway/api_test.go
ioutil
withio
for reading response body.batch_requests.go
Replace deprecated ioutil with io package in batch_requests.go
gateway/batch_requests.go
ioutil
withio
for reading response body.batch_requests_test.go
Replace deprecated ioutil with io package in batch_requests_test.go
gateway/batch_requests_test.go
ioutil
withio
for reading response body.cert.go
Replace deprecated ioutil with io package in cert.go
gateway/cert.go
ioutil
withio
for reading request body.cert_test.go
Use os package for file operations in cert_test.go
gateway/cert_test.go
ioutil
withos
for temporary directory creation and filewriting.
coprocess.go
Replace deprecated ioutil with io package in coprocess.go
gateway/coprocess.go
ioutil
withio
for reading request and response body.coprocess_bundle.go
Replace deprecated ioutil with io package in coprocess_bundle.go
gateway/coprocess_bundle.go
ioutil
withio
for reading response body.coprocess_grpc.go
Use secure gRPC credentials in coprocess_grpc.go
gateway/coprocess_grpc.go
grpc.WithInsecure()
withgrpc.WithTransportCredentials(insecure.NewCredentials())
.coprocess_id_extractor.go
Replace deprecated ioutil with io package in coprocess_id_extractor.go
gateway/coprocess_id_extractor.go
ioutil
withio
for reading request body.coprocess_lua.go
Use os package for file operations in coprocess_lua.go
gateway/coprocess_lua.go
ioutil
withos
for reading files.coprocess_python.go
Update protobuf import path in coprocess_python.go
gateway/coprocess_python.go
github.com/golang/protobuf/proto
withgoogle.golang.org/protobuf/proto
.event_handler_webhooks.go
Replace deprecated ioutil with io package in event_handler_webhooks.go
gateway/event_handler_webhooks.go
ioutil
withio
for reading response body.gateway_test.go
Replace deprecated ioutil with io package in gateway_test.go
gateway/gateway_test.go
ioutil
withio
for reading response body.grpc_streaming_server_test.go
Update protobuf import path in grpc_streaming_server_test.go
gateway/grpc_streaming_server_test.go
github.com/golang/protobuf/proto
withgoogle.golang.org/protobuf/proto
.grpc_test.go
Update gRPC credentials and replace deprecated ioutil in grpc_test.go
gateway/grpc_test.go
ioutil
withio
for reading response body.grpc.WithInsecure()
withgrpc.WithTransportCredentials(insecure.NewCredentials())
.handler_error.go
Replace deprecated ioutil with io package in handler_error.go
gateway/handler_error.go
ioutil
withio
for creatingNopCloser
.handler_error_test.go
Use os package for file operations in handler_error_test.go
gateway/handler_error_test.go
ioutil
withos
for file writing.handler_success.go
Replace deprecated ioutil with io package in handler_success.go
gateway/handler_success.go
ioutil
withio
for creatingNopCloser
.host_checker.go
Use thread-safe rand instance in host_checker.go
gateway/host_checker.go
mathRand.Seed
with newrand
instance for thread safety.middleware.go
Replace deprecated ioutil with io package in middleware.go
gateway/middleware.go
ioutil
withio
for creatingNopCloser
.middleware_test.go
Replace deprecated ioutil with io package in middleware_test.go
gateway/middleware_test.go
ioutil
withio
for reading response body.mw_basic_auth.go
Replace deprecated ioutil with io package in mw_basic_auth.go
gateway/mw_basic_auth.go
ioutil
withio
for creatingNopCloser
.mw_go_plugin.go
Replace deprecated ioutil with io package in mw_go_plugin.go
gateway/mw_go_plugin.go
ioutil
withio
for creatingNopCloser
.mw_js_plugin.go
Replace deprecated ioutil with io package in mw_js_plugin.go
gateway/mw_js_plugin.go
ioutil
withio
for reading request body and creatingNopCloser
.mw_js_plugin_test.go
Replace deprecated ioutil with io package in mw_js_plugin_test.go
gateway/mw_js_plugin_test.go
ioutil
withio
for reading request body.mw_jwt.go
Improve string comparison in mw_jwt.go
gateway/mw_jwt.go
strings.EqualFold
for case-insensitive string comparison.mw_redis_cache.go
Replace deprecated ioutil with io package in mw_redis_cache.go
gateway/mw_redis_cache.go
ioutil
withio
for reading request body.mw_transform.go
Replace deprecated ioutil with io package in mw_transform.go
gateway/mw_transform.go
ioutil
withio
for reading request body.mw_transform_jq.go
Replace deprecated ioutil with io package in mw_transform_jq.go
gateway/mw_transform_jq.go
ioutil
withio
for creatingNopCloser
.mw_transform_test.go
Replace deprecated ioutil with io package in mw_transform_test.go
gateway/mw_transform_test.go
ioutil
withio
for reading request body.mw_url_rewrite.go
Improve string comparison in mw_url_rewrite.go
gateway/mw_url_rewrite.go
strings.EqualFold
for case-insensitive string comparison.mw_validate_json.go
Replace deprecated ioutil with io package in mw_validate_json.go
gateway/mw_validate_json.go
ioutil
withio
for reading request body.mw_virtual_endpoint.go
Replace deprecated ioutil with io package in mw_virtual_endpoint.go
gateway/mw_virtual_endpoint.go
ioutil
withio
for reading request body and creatingNopCloser
.policy.go
Replace deprecated ioutil with io package in policy.go
gateway/policy.go
ioutil
withio
for reading response body.proxy_muxer_test.go
Replace deprecated ioutil with io package in proxy_muxer_test.go
gateway/proxy_muxer_test.go
ioutil
withio
for reading response body.redis_signal_handle_config.go
Use os package for file operations in redis_signal_handle_config.go
gateway/redis_signal_handle_config.go
ioutil
withos
for file writing.reverse_proxy.go
Replace deprecated ioutil and improve string comparison in
reverse_proxy.go
gateway/reverse_proxy.go
ioutil
withio
for creatingNopCloser
.strings.EqualFold
for case-insensitive string comparison.reverse_proxy_test.go
Replace deprecated ioutil with io package in reverse_proxy_test.go
gateway/reverse_proxy_test.go
ioutil
withio
for creatingNopCloser
.server.go
Replace deprecated ioutil with io package in server.go
gateway/server.go
ioutil
withio
for discarding log output.service_discovery.go
Replace deprecated ioutil with io package in service_discovery.go
gateway/service_discovery.go
ioutil
withio
for reading response body.testutil.go
Use os package for file operations in testutil.go
gateway/testutil.go
ioutil
withos
for temporary directory creation and filewriting.