Closed jeffy-mathew closed 2 months ago
API Changes
--- prev.txt 2024-09-17 08:19:37.439154968 +0000
+++ current.txt 2024-09-17 08:19:34.303139953 +0000
@@ -5188,12 +5188,6 @@
TYPES
-type AccessLogsConfig struct {
- // Enable the transaction logs. Default: false
- Enabled bool `json:"enabled"`
-}
- AccessLogsConfig defines the type of transactions logs printed to stdout
-
type AnalyticsConfigConfig struct {
// Set empty for a Self-Managed installation or `rpc` for multi-cloud.
Type string `json:"type"`
@@ -5643,10 +5637,6 @@
// If not set or left empty, it will default to `standard`.
LogFormat string `json:"log_format"`
- // You can configure the transaction logs to be turned on
- // If not set or left empty, it will default to 'false'
- AccessLogs AccessLogsConfig `json:"access_logs"`
-
// Section for configuring OpenTracing support
// Deprecated: use OpenTelemetry instead.
Tracer Tracer `json:"tracing"`
@@ -11326,12 +11316,6 @@
CONSTANTS
const (
- HashSha256 = crypto.HashSha256
- HashMurmur32 = crypto.HashMurmur32
- HashMurmur64 = crypto.HashMurmur64
- HashMurmur128 = crypto.HashMurmur128
-)
-const (
// DefaultConn is the default connection type. Not analytics and Not cache.
DefaultConn = "default"
// CacheConn is the cache connection type
@@ -11339,26 +11323,26 @@
// AnalyticsConn is the analytics connection type
AnalyticsConn = "analytics"
)
+const B64JSONPrefix = "ey"
+ `{"` in base64
+
+const MongoBsonIdLength = 24
VARIABLES
var (
- HashStr = crypto.HashStr
- HashKey = crypto.HashKey
-)
-var (
- GenerateToken = crypto.GenerateToken
- TokenHashAlgo = crypto.TokenHashAlgo
- TokenID = crypto.TokenID
- TokenOrg = crypto.TokenOrg
-)
-var (
// ErrRedisIsDown is returned when we can't communicate with redis
ErrRedisIsDown = errors.New("storage: Redis is either down or was not configured")
// ErrStorageConn is returned when we can't get a connection from the ConnectionHandler
ErrStorageConn = fmt.Errorf("Error trying to get singleton instance: %w", ErrRedisIsDown)
)
+var (
+ HashSha256 = "sha256"
+ HashMurmur32 = "murmur32"
+ HashMurmur64 = "murmur64"
+ HashMurmur128 = "murmur128"
+)
var ErrKeyNotFound = errors.New("key not found")
ErrKeyNotFound is a standard error for when a key is not found in the
storage engine
@@ -11367,9 +11351,19 @@
FUNCTIONS
+func GenerateToken(orgID, keyID, hashAlgorithm string) (string, error)
+ If hashing algorithm is empty, use legacy key generation
+
+func HashKey(in string, hashKey bool) string
+func HashStr(in string, withAlg ...string) string
func NewConnector(connType string, conf config.Config) (model.Connector, error)
NewConnector creates a new storage connection.
+func TokenHashAlgo(token string) string
+func TokenID(token string) (id string, err error)
+ TODO: add checks
+
+func TokenOrg(token string) string
TYPES
β±οΈ Estimated effort to review: 3 π΅π΅π΅βͺβͺ |
π§ͺ No relevant tests |
π No security concerns identified |
β‘ Key issues to review Error Handling The function `GenerateToken` in `storage/storage.go` does not handle the error from `hashFunction` properly. It defaults to `defaultHashAlgorithm` without logging or handling the initial error, which could lead to silent failures or unexpected behavior in token generation. Function Complexity The function `TokenOrg` in `storage/storage.go` has multiple nested conditions and returns, making it complex and hard to maintain. Consider refactoring to simplify the logic and improve readability. |
No code suggestions found for the PR.
Failed conditions
C Reliability Rating on New Code (required β₯ A)
See analysis details on SonarCloud
Catch issues before they fail your Quality Gate with our IDE extension SonarLint
/release to release-5.6
Working on it! Note that it can take a few minutes.
@jeffy-mathew Succesfully merged PR
/release to release-5.6.0
Working on it! Note that it can take a few minutes.
@jeffy-mathew Succesfully merged PR
User description
Reverts TykTechnologies/tyk#6354 with QA failure
PR Type
enhancement, bug fix
Description
AccessLogsConfig
struct and related access log configurations from the codebase.crypto
tostorage
, consolidating related functionality.Changes walkthrough π
8 files
config.go
Remove access logs configuration from analytics settings
config/config.go
AccessLogsConfig
struct and its usage.middleware.go
Remove access log recording function from middleware
gateway/middleware.go - Removed `recordAccessLog` function.
hash.go
Remove crypto hashing functions
internal/crypto/hash.go - Deleted the entire file related to hashing functions.
token.go
Remove token generation and parsing functions
internal/crypto/token.go - Deleted the entire file related to token generation and parsing.
access_log.go
Remove access log record functionality
internal/httputil/accesslog/access_log.go - Deleted the entire file related to access log records.
alias.go
Remove storage alias for crypto functions
storage/alias.go
storage.go
Integrate hashing and token functions into storage
storage/storage.go - Moved hashing and token functions from `crypto` to `storage`.
schema.json
Remove access logs configuration from schema
cli/linter/schema.json - Removed `access_logs` configuration from the schema.
2 files
handler_error.go
Remove transaction log printing in error handler
gateway/handler_error.go - Removed transaction log printing for error situations.
handler_success.go
Remove transaction log printing in success handler
gateway/handler_success.go - Removed transaction log printing for successful requests.
3 files
handler_error_test.go
Remove access logs benchmark tests from error handler tests
gateway/handler_error_test.go - Removed benchmark tests related to access logs.
handler_success_test.go
Remove access logs benchmark tests from success handler tests
gateway/handler_success_test.go - Removed benchmark tests related to access logs.
access_log_test.go
Remove access log tests
internal/httputil/accesslog/access_log_test.go - Deleted the entire file related to access log tests.
1 files
Taskfile.yml
Update test command in Taskfile
internal/httputil/Taskfile.yml - Updated test command to remove specific coverage package.