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

[0000] exp/semgrep: Update from LSC semgrep rule #6380

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

buger
Copy link
Member

@buger buger commented Jun 27, 2024

Triggered by: titpetric

Semgrep version: 1.76.0
Errors reported: 0
Path scanned: 297
Results: 137

- file: gateway/api.go
  line: 722
  message: Replacing apiLog prefix with logger (autofix)
  check: host.rules.tyk.log.apiLog.remove.prefix.from.Fields
  example: |
    	log.WithFields(logrus.Fields{
		"prefix": "api",
		"status": "ok",
	}).Info("Retrieved key list.")

- file: gateway/api.go
  line: 1030
  message: Replacing apiLog prefix with logger (autofix)
  check: host.rules.tyk.log.apiLog.remove.prefix.from.Fields
  example: |
    	log.WithFields(logrus.Fields{
		"prefix": "api",
		"apiID":  fmt.Sprintf("%q", apiID),
	}).Error("API doesn't exist.")

- file: gateway/api.go
  line: 1914
  message: Replacing apiLog prefix with logger (autofix)
  check: host.rules.tyk.log.apiLog.remove.prefix.from.Fields
  example: |
    	log.WithFields(logrus.Fields{
		"prefix": "api",
		"status": "ok",
	}).Info("Group reload accepted.")

- file: gateway/api.go
  line: 1922
  message: Replacing apiLog prefix with logger (autofix)
  check: host.rules.tyk.log.apiLog.remove.withFields
  example: |
    	log.WithFields(logrus.Fields{
		"prefix": "api",
	}).Info("Reloaded URL Structure - Success")

- file: gateway/api.go
  line: 1944
  message: Replacing apiLog prefix with logger (autofix)
  check: host.rules.tyk.log.apiLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "api",
		}).Info("Reload URL Structure - Scheduled")

- file: gateway/api.go
  line: 2164
  message: Replacing apiLog prefix with logger (autofix)
  check: host.rules.tyk.log.apiLog.remove.withFields
  example: |
    	log.WithFields(logrus.Fields{
		"prefix": "api",
	}).Debug("Created storage ID: ", storageID)

- file: gateway/api.go
  line: 2429
  message: Replacing apiLog prefix with logger (autofix)
  check: host.rules.tyk.log.apiLog.remove.prefix.from.Fields
  example: |
    	log.WithFields(logrus.Fields{
		"prefix": "api",
		"apiID":  apiID,
	}).Debug("Looking for refresh token in API Register")

- file: gateway/cert.go
  line: 69
  message: Replacing certLog prefix with logger (autofix)
  check: host.rules.tyk.log.certLog.remove.withField
  example: |
    var certLog = log.WithField("prefix", "certs")

- file: gateway/coprocess.go
  line: 60
  message: Replacing coprocessLog prefix with logger (autofix)
  check: host.rules.tyk.log.coprocessLog.remove.withFields
  example: |
    	log.WithFields(logrus.Fields{
		"prefix": "coprocess",
	}).Info("Reloading middlewares")

- file: gateway/coprocess.go
  line: 254
  message: Replacing coprocessLog prefix with logger (autofix)
  check: host.rules.tyk.log.coprocessLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "coprocess",
		}).Info("Rich plugins are disabled")

- file: gateway/coprocess.go
  line: 265
  message: Replacing coprocessLog prefix with logger (autofix)
  check: host.rules.tyk.log.coprocessLog.remove.withFields
  example: |
    			log.WithFields(logrus.Fields{
				"prefix": "coprocess",
			}).Info("gRPC dispatcher was initialized")

- file: gateway/coprocess.go
  line: 269
  message: Replacing coprocessLog prefix with logger (autofix)
  check: host.rules.tyk.log.coprocessLog.remove.withFields
  example: |
    			log.WithFields(logrus.Fields{
				"prefix": "coprocess",
			}).WithError(err).Error("Couldn't load gRPC dispatcher")

- file: gateway/coprocess.go
  line: 281
  message: Replacing coprocessLog prefix with logger (autofix)
  check: host.rules.tyk.log.coprocessLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "coprocess",
		}).Error("Your API specifies a CP custom middleware, either Tyk wasn't build with CP support or CP is not enabled in your Tyk configuration file!")

- file: gateway/coprocess.go
  line: 295
  message: Replacing coprocessLog prefix with logger (autofix)
  check: host.rules.tyk.log.coprocessLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "coprocess",
		}).Errorf("Unsupported driver '%s'", m.Spec.CustomMiddleware.Driver)

- file: gateway/coprocess.go
  line: 302
  message: Replacing coprocessLog prefix with logger (autofix)
  check: host.rules.tyk.log.coprocessLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "coprocess",
		}).Errorf("Driver '%s' isn't loaded", m.Spec.CustomMiddleware.Driver)

- file: gateway/coprocess.go
  line: 308
  message: Replacing coprocessLog prefix with logger (autofix)
  check: host.rules.tyk.log.coprocessLog.remove.withFields
  example: |
    	log.WithFields(logrus.Fields{
		"prefix": "coprocess",
	}).Debug("Enabling CP middleware.")

- file: gateway/coprocess.go
  line: 555
  message: Replacing coprocessLog prefix with logger (autofix)
  check: host.rules.tyk.log.coprocessLog.remove.withFields
  example: |
    	log.WithFields(logrus.Fields{
		"prefix": "coprocess",
	}).Debugf("Response hook '%s' is called", h.mw.Name())

- file: gateway/coprocess_api.go
  line: 91
  message: Replacing pythonLog prefix with logger (autofix)
  check: host.rules.tyk.log.pythonLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "python",
		}).Debug(message)

- file: gateway/coprocess_api.go
  line: 95
  message: Replacing pythonLog prefix with logger (autofix)
  check: host.rules.tyk.log.pythonLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "python",
		}).Error(message)

- file: gateway/coprocess_api.go
  line: 99
  message: Replacing pythonLog prefix with logger (autofix)
  check: host.rules.tyk.log.pythonLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "python",
		}).Warning(message)

- file: gateway/coprocess_api.go
  line: 103
  message: Replacing pythonLog prefix with logger (autofix)
  check: host.rules.tyk.log.pythonLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "python",
		}).Info(message)

- file: gateway/coprocess_bundle.go
  line: 45
  message: Replacing mainLog prefix with logger (autofix)
  check: host.rules.tyk.log.mainLog.remove.withFields
  example: |
    	log.WithFields(logrus.Fields{
		"prefix": "main",
	}).Info("----> Verifying bundle: ", b.Spec.CustomMiddlewareBundle)

- file: gateway/coprocess_bundle.go
  line: 111
  message: Replacing coprocessLog prefix with logger (autofix)
  check: host.rules.tyk.log.coprocessLog.remove.withFields
  example: |
    			log.WithFields(logrus.Fields{
				"prefix": "coprocess",
			}).WithError(err).Error("Couldn't load Python dispatcher")

- file: gateway/coprocess_bundle.go
  line: 116
  message: Replacing coprocessLog prefix with logger (autofix)
  check: host.rules.tyk.log.coprocessLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "coprocess",
		}).Info("Python dispatcher was initialized")

- file: gateway/coprocess_bundle.go
  line: 226
  message: Replacing mainLog prefix with logger (autofix)
  check: host.rules.tyk.log.mainLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "main",
		}).Warning("Bundle downloader is disabled.")

- file: gateway/coprocess_bundle.go
  line: 308
  message: Replacing mainLog prefix with logger (autofix)
  check: host.rules.tyk.log.mainLog.remove.withFields
  example: |
    	log.WithFields(logrus.Fields{
		"prefix": "main",
	}).Info("----> Loading bundle: ", spec.CustomMiddlewareBundle)

- file: gateway/coprocess_bundle.go
  line: 320
  message: Replacing mainLog prefix with logger (autofix)
  check: host.rules.tyk.log.mainLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "main",
		}).Info("----> Couldn't unmarshal the manifest file for bundle: ", spec.CustomMiddlewareBundle)

- file: gateway/coprocess_bundle.go
  line: 331
  message: Replacing mainLog prefix with logger (autofix)
  check: host.rules.tyk.log.mainLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "main",
		}).Info("----> Bundle verification failed: ", spec.CustomMiddlewareBundle)

- file: gateway/coprocess_bundle.go
  line: 372
  message: Replacing mainLog prefix with logger (autofix)
  check: host.rules.tyk.log.mainLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "main",
		}).Info("Loading existing bundle: ", spec.CustomMiddlewareBundle)

- file: gateway/coprocess_bundle.go
  line: 385
  message: Replacing mainLog prefix with logger (autofix)
  check: host.rules.tyk.log.mainLog.remove.withFields
  example: |
    			log.WithFields(logrus.Fields{
				"prefix": "main",
			}).Info("----> Couldn't load bundle: ", spec.CustomMiddlewareBundle, " ", err)

- file: gateway/coprocess_bundle.go
  line: 390
  message: Replacing mainLog prefix with logger (autofix)
  check: host.rules.tyk.log.mainLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "main",
		}).Info("----> Using bundle: ", spec.CustomMiddlewareBundle)

- file: gateway/coprocess_bundle.go
  line: 399
  message: Replacing mainLog prefix with logger (autofix)
  check: host.rules.tyk.log.mainLog.remove.withFields
  example: |
    	log.WithFields(logrus.Fields{
		"prefix": "main",
	}).Info("----> Fetching Bundle: ", spec.CustomMiddlewareBundle)

- file: gateway/coprocess_bundle.go
  line: 416
  message: Replacing mainLog prefix with logger (autofix)
  check: host.rules.tyk.log.mainLog.remove.withFields
  example: |
    	log.WithFields(logrus.Fields{
		"prefix": "main",
	}).Debug("----> Saving Bundle: ", spec.CustomMiddlewareBundle)

- file: gateway/coprocess_bundle.go
  line: 432
  message: Replacing mainLog prefix with logger (autofix)
  check: host.rules.tyk.log.mainLog.remove.withFields
  example: |
    	log.WithFields(logrus.Fields{
		"prefix": "main",
	}).Info("----> Bundle is valid, adding to spec: ", spec.CustomMiddlewareBundle)

- file: gateway/coprocess_grpc.go
  line: 30
  message: Replacing coprocessLog prefix with logger (autofix)
  check: host.rules.tyk.log.coprocessLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "coprocess",
		}).Error(err)

- file: gateway/coprocess_grpc.go
  line: 38
  message: Replacing coprocessLog prefix with logger (autofix)
  check: host.rules.tyk.log.coprocessLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "coprocess",
		}).Error(errString)

- file: gateway/coprocess_grpc.go
  line: 61
  message: Replacing coprocessLog prefix with logger (autofix)
  check: host.rules.tyk.log.coprocessLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "coprocess",
		}).Error(err)

- file: gateway/coprocess_grpc.go
  line: 105
  message: Replacing coprocessLog prefix with logger (autofix)
  check: host.rules.tyk.log.coprocessLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "coprocess",
		}).Error(err)

- file: gateway/coprocess_helpers.go
  line: 141
  message: Replacing coprocessLog prefix with logger (autofix)
  check: host.rules.tyk.log.coprocessLog.remove.withFields
  example: |
    					log.WithFields(logrus.Fields{
						"prefix": "coprocess",
					}).WithError(err).Error("Couldn't encode session metadata")

- file: gateway/coprocess_lua.go
  line: 93
  message: Replacing coprocessLog prefix with logger (autofix)
  check: host.rules.tyk.log.coprocessLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "coprocess",
		}).Info("Lua dispatcher was initialized")

- file: gateway/coprocess_lua.go
  line: 97
  message: Replacing coprocessLog prefix with logger (autofix)
  check: host.rules.tyk.log.coprocessLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "coprocess",
		}).WithError(err).Error("Couldn't load Lua dispatcher")

- file: gateway/coprocess_lua.go
  line: 177
  message: Replacing coprocessLog prefix with logger (autofix)
  check: host.rules.tyk.log.coprocessLog.remove.withFields
  example: |
    			log.WithFields(logrus.Fields{
				"prefix": "coprocess",
			}).Error("Failed to read middleware file: ", err)

- file: gateway/coprocess_lua.go
  line: 193
  message: Replacing coprocessLog prefix with logger (autofix)
  check: host.rules.tyk.log.coprocessLog.remove.withFields
  example: |
    			log.WithFields(logrus.Fields{
				"prefix": "coprocess",
			}).Error("Failed to read bundle file: ", err)

- file: gateway/coprocess_lua.go
  line: 201
  message: Replacing coprocessLog prefix with logger (autofix)
  check: host.rules.tyk.log.coprocessLog.remove.withFields
  example: |
    	log.WithFields(logrus.Fields{
		"prefix": "coprocess",
	}).Info("Loading Tyk/Lua modules.")

- file: gateway/coprocess_lua.go
  line: 216
  message: Replacing coprocessLog prefix with logger (autofix)
  check: host.rules.tyk.log.coprocessLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "coprocess",
		}).Error("Failed to read bundle file: ", err)

- file: gateway/coprocess_python.go
  line: 53
  message: Replacing pythonLog prefix with logger (autofix)
  check: host.rules.tyk.log.pythonLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "python",
		}).Fatal(err)

- file: gateway/coprocess_python.go
  line: 63
  message: Replacing pythonLog prefix with logger (autofix)
  check: host.rules.tyk.log.pythonLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "python",
		}).Fatal(err)

- file: gateway/coprocess_python.go
  line: 73
  message: Replacing pythonLog prefix with logger (autofix)
  check: host.rules.tyk.log.pythonLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "python",
		}).Fatal(err)

- file: gateway/coprocess_python.go
  line: 84
  message: Replacing pythonLog prefix with logger (autofix)
  check: host.rules.tyk.log.pythonLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "python",
		}).Error(err)

- file: gateway/coprocess_python.go
  line: 96
  message: Replacing pythonLog prefix with logger (autofix)
  check: host.rules.tyk.log.pythonLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "python",
		}).Error(err)

- file: gateway/coprocess_python.go
  line: 106
  message: Replacing pythonLog prefix with logger (autofix)
  check: host.rules.tyk.log.pythonLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "python",
		}).Error(err)

- file: gateway/coprocess_python.go
  line: 116
  message: Replacing pythonLog prefix with logger (autofix)
  check: host.rules.tyk.log.pythonLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "python",
		}).Error(err)

- file: gateway/coprocess_python.go
  line: 129
  message: Replacing pythonLog prefix with logger (autofix)
  check: host.rules.tyk.log.pythonLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "python",
		}).Error(err)

- file: gateway/coprocess_python.go
  line: 158
  message: Replacing pythonLog prefix with logger (autofix)
  check: host.rules.tyk.log.pythonLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "python",
		}).Error(err)

- file: gateway/coprocess_python.go
  line: 166
  message: Replacing pythonLog prefix with logger (autofix)
  check: host.rules.tyk.log.pythonLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "python",
		}).Error(err)

- file: gateway/coprocess_python.go
  line: 175
  message: Replacing pythonLog prefix with logger (autofix)
  check: host.rules.tyk.log.pythonLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "python",
		}).Error(err)

- file: gateway/coprocess_python.go
  line: 191
  message: Replacing coprocessLog prefix with logger (autofix)
  check: host.rules.tyk.log.coprocessLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "coprocess",
		}).Fatalf("Couldn't initialize Python - %s", err.Error())

- file: gateway/coprocess_python.go
  line: 196
  message: Replacing coprocessLog prefix with logger (autofix)
  check: host.rules.tyk.log.coprocessLog.remove.withFields
  example: |
    	log.WithFields(logrus.Fields{
		"prefix": "coprocess",
	}).Infof("Python version '%s' loaded", ver)

- file: gateway/coprocess_python.go
  line: 208
  message: Replacing coprocessLog prefix with logger (autofix)
  check: host.rules.tyk.log.coprocessLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "coprocess",
		}).Fatalf("Couldn't initialize Python dispatcher")

- file: gateway/coprocess_python.go
  line: 216
  message: Replacing coprocessLog prefix with logger (autofix)
  check: host.rules.tyk.log.coprocessLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "coprocess",
		}).Fatalf("Couldn't initialize Python dispatcher")

- file: gateway/coprocess_python.go
  line: 231
  message: Replacing pythonLog prefix with logger (autofix)
  check: host.rules.tyk.log.pythonLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "python",
		}).Fatal(err)

- file: gateway/coprocess_python.go
  line: 237
  message: Replacing pythonLog prefix with logger (autofix)
  check: host.rules.tyk.log.pythonLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "python",
		}).Error(err)

- file: gateway/coprocess_python.go
  line: 245
  message: Replacing pythonLog prefix with logger (autofix)
  check: host.rules.tyk.log.pythonLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "python",
		}).Error(err)

- file: gateway/coprocess_python.go
  line: 280
  message: Replacing coprocessLog prefix with logger (autofix)
  check: host.rules.tyk.log.coprocessLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "coprocess",
		}).Debugf("Python path prefix isn't set, using '%s'", workDir)

- file: gateway/coprocess_python.go
  line: 309
  message: Replacing coprocessLog prefix with logger (autofix)
  check: host.rules.tyk.log.coprocessLog.remove.withFields
  example: |
    			log.WithFields(logrus.Fields{
				"prefix": "coprocess",
			}).Error(err)

- file: gateway/dashboard_register.go
  line: 16
  message: Replacing dashLog prefix with logger (autofix)
  check: host.rules.tyk.log.dashLog.remove.withField
  example: |
    var dashLog = log.WithField("prefix", "dashboard")

- file: gateway/distributed_rate_limiter.go
  line: 88
  message: Replacing pubSubLog prefix with logger (autofix)
  check: host.rules.tyk.log.pubSubLog.remove.prefix.from.Fields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix":  "pub-sub",
			"payload": string(payload),
		}).Error("Failed unmarshal server data: ", err)

- file: gateway/event_handler_webhooks.go
  line: 59
  message: Replacing webhookLog prefix with logger (autofix)
  check: host.rules.tyk.log.webhookLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "webhooks",
		}).Error("Problem getting configuration, skipping. ", err)

- file: gateway/event_handler_webhooks.go
  line: 66
  message: Replacing webhookLog prefix with logger (autofix)
  check: host.rules.tyk.log.webhookLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "webhooks",
		}).Infof("skipping disabled webhook %s", w.conf.Name)

- file: gateway/event_handler_webhooks.go
  line: 79
  message: Replacing webhookLog prefix with logger (autofix)
  check: host.rules.tyk.log.webhookLog.remove.prefix.from.Fields
  example: |
    			log.WithFields(logrus.Fields{
				"prefix": "webhooks",
				"target": w.conf.TargetPath,
			}).Warning("Custom template load failure, using default: ", err)

- file: gateway/event_handler_webhooks.go
  line: 93
  message: Replacing webhookLog prefix with logger (autofix)
  check: host.rules.tyk.log.webhookLog.remove.prefix.from.Fields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "webhooks",
			"target": w.conf.TargetPath,
		}).Info("Loading default template.")

- file: gateway/event_handler_webhooks.go
  line: 100
  message: Replacing webhookLog prefix with logger (autofix)
  check: host.rules.tyk.log.webhookLog.remove.withFields
  example: |
    			log.WithFields(logrus.Fields{
				"prefix": "webhooks",
			}).Error("Could not load the default template: ", err)

- file: gateway/event_handler_webhooks.go
  line: 108
  message: Replacing webhookLog prefix with logger (autofix)
  check: host.rules.tyk.log.webhookLog.remove.withFields
  example: |
    	log.WithFields(logrus.Fields{
		"prefix": "webhooks",
	}).Debug("Timeout set to: ", w.conf.EventTimeout)

- file: gateway/event_handler_webhooks.go
  line: 113
  message: Replacing webhookLog prefix with logger (autofix)
  check: host.rules.tyk.log.webhookLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "webhooks",
		}).Error("Init failed for this webhook, invalid URL, URL must be absolute")

- file: gateway/event_handler_webhooks.go
  line: 130
  message: Replacing webhookLog prefix with logger (autofix)
  check: host.rules.tyk.log.webhookLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "webhooks",
		}).Debug("Event can fire, no duplicates found")

- file: gateway/event_handler_webhooks.go
  line: 141
  message: Replacing webhookLog prefix with logger (autofix)
  check: host.rules.tyk.log.webhookLog.remove.withFields
  example: |
    	log.WithFields(logrus.Fields{
		"prefix": "webhooks",
	}).Debug("Setting Webhook Checksum: ", checksum)

- file: gateway/event_handler_webhooks.go
  line: 156
  message: Replacing webhookLog prefix with logger (autofix)
  check: host.rules.tyk.log.webhookLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "webhooks",
		}).Warning("Method must be one of GET, PUT, POST, DELETE or PATCH, defaulting to GET")

- file: gateway/event_handler_webhooks.go
  line: 164
  message: Replacing webhookLog prefix with logger (autofix)
  check: host.rules.tyk.log.webhookLog.remove.withFields
  example: |
    	log.WithFields(logrus.Fields{
		"prefix": "webhooks",
	}).Debug("Checking URL: ", r)

- file: gateway/event_handler_webhooks.go
  line: 168
  message: Replacing webhookLog prefix with logger (autofix)
  check: host.rules.tyk.log.webhookLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "webhooks",
		}).Error("Failed to parse URL! ", err, r)

- file: gateway/event_handler_webhooks.go
  line: 187
  message: Replacing webhookLog prefix with logger (autofix)
  check: host.rules.tyk.log.webhookLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "webhooks",
		}).Error("Failed to create request object: ", err)

- file: gateway/event_handler_webhooks.go
  line: 250
  message: Replacing webhookLog prefix with logger (autofix)
  check: host.rules.tyk.log.webhookLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "webhooks",
		}).Error("Webhook request failed: ", err)

- file: gateway/event_handler_webhooks.go
  line: 258
  message: Replacing webhookLog prefix with logger (autofix)
  check: host.rules.tyk.log.webhookLog.remove.prefix.from.Fields
  example: |
    				log.WithFields(logrus.Fields{
					"prefix":       "webhooks",
					"responseCode": resp.StatusCode,
				}).Debug(string(content))

- file: gateway/event_handler_webhooks.go
  line: 263
  message: Replacing webhookLog prefix with logger (autofix)
  check: host.rules.tyk.log.webhookLog.remove.withFields
  example: |
    				log.WithFields(logrus.Fields{
					"prefix": "webhooks",
				}).Error(err)

- file: gateway/event_handler_webhooks.go
  line: 269
  message: Replacing webhookLog prefix with logger (autofix)
  check: host.rules.tyk.log.webhookLog.remove.prefix.from.Fields
  example: |
    			log.WithFields(logrus.Fields{
				"prefix":       "webhooks",
				"responseCode": resp.StatusCode,
			}).Error("Request to webhook failed")

- file: gateway/host_checker_manager.go
  line: 103
  message: Replacing hostCheckLog prefix with logger (autofix)
  check: host.rules.tyk.log.hostCheckLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "host-check-mgr",
		}).Debug("Stopping uptime tests")

- file: gateway/host_checker_manager.go
  line: 121
  message: Replacing hostCheckLog prefix with logger (autofix)
  check: host.rules.tyk.log.hostCheckLog.remove.withFields
  example: |
    				log.WithFields(logrus.Fields{
					"prefix": "host-check-mgr",
				}).Info("Starting Poller")

- file: gateway/host_checker_manager.go
  line: 128
  message: Replacing hostCheckLog prefix with logger (autofix)
  check: host.rules.tyk.log.hostCheckLog.remove.withFields
  example: |
    			log.WithFields(logrus.Fields{
				"prefix": "host-check-mgr",
			}).Debug("New master found, no tests running")

- file: gateway/host_checker_manager.go
  line: 141
  message: Replacing hostCheckLog prefix with logger (autofix)
  check: host.rules.tyk.log.hostCheckLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "host-check-mgr",
		}).Error("No storage instance set for uptime tests! Disabling poller...")

- file: gateway/host_checker_manager.go
  line: 153
  message: Replacing hostCheckLog prefix with logger (autofix)
  check: host.rules.tyk.log.hostCheckLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "host-check-mgr",
		}).Debug("No Primary instance found, assuming control")

- file: gateway/host_checker_manager.go
  line: 164
  message: Replacing hostCheckLog prefix with logger (autofix)
  check: host.rules.tyk.log.hostCheckLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "host-check-mgr",
		}).Debug("Primary instance set, I am master")

- file: gateway/host_checker_manager.go
  line: 174
  message: Replacing hostCheckLog prefix with logger (autofix)
  check: host.rules.tyk.log.hostCheckLog.remove.withFields
  example: |
    	log.WithFields(logrus.Fields{
		"prefix": "host-check-mgr",
	}).Debug("Active Instance is: ", activeInstance)

- file: gateway/host_checker_manager.go
  line: 177
  message: Replacing hostCheckLog prefix with logger (autofix)
  check: host.rules.tyk.log.hostCheckLog.remove.withFields
  example: |
    	log.WithFields(logrus.Fields{
		"prefix": "host-check-mgr",
	}).Debug("--- I am: ", hc.Id)

- file: gateway/host_checker_manager.go
  line: 185
  message: Replacing hostCheckLog prefix with logger (autofix)
  check: host.rules.tyk.log.hostCheckLog.remove.withFields
  example: |
    	log.WithFields(logrus.Fields{
		"prefix": "host-check-mgr",
	}).Debug("---> Initialising checker")

- file: gateway/host_checker_manager.go
  line: 207
  message: Replacing hostCheckLog prefix with logger (autofix)
  check: host.rules.tyk.log.hostCheckLog.remove.withFields
  example: |
    	log.WithFields(logrus.Fields{
		"prefix": "host-check-mgr",
	}).Debug("---> Starting checker")

- file: gateway/host_checker_manager.go
  line: 211
  message: Replacing hostCheckLog prefix with logger (autofix)
  check: host.rules.tyk.log.hostCheckLog.remove.withFields
  example: |
    	log.WithFields(logrus.Fields{
		"prefix": "host-check-mgr",
	}).Debug("---> Checker started.")

- file: gateway/host_checker_manager.go
  line: 235
  message: Replacing hostCheckLog prefix with logger (autofix)
  check: host.rules.tyk.log.hostCheckLog.remove.withFields
  example: |
    	log.WithFields(logrus.Fields{
		"prefix": "host-check-mgr",
	}).Debug("Update key: ", key)

- file: gateway/host_checker_manager.go
  line: 245
  message: Replacing hostCheckLog prefix with logger (autofix)
  check: host.rules.tyk.log.hostCheckLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "host-check-mgr",
		}).Warning("[HOST CHECKER MANAGER] Event can't fire for API that doesn't exist")

- file: gateway/host_checker_manager.go
  line: 256
  message: Replacing hostCheckLog prefix with logger (autofix)
  check: host.rules.tyk.log.hostCheckLog.remove.withFields
  example: |
    	log.WithFields(logrus.Fields{
		"prefix": "host-check-mgr",
	}).Warning("[HOST CHECKER MANAGER] Host is DOWN: ", report.CheckURL)

- file: gateway/host_checker_manager.go
  line: 269
  message: Replacing hostCheckLog prefix with logger (autofix)
  check: host.rules.tyk.log.hostCheckLog.remove.withFields
  example: |
    				log.WithFields(logrus.Fields{
					"prefix": "host-check-mgr",
				}).Printf("[HOST CHECKER MANAGER] Resetting test host list in %v seconds for API: %v", spec.UptimeTests.Config.RecheckWait, apiID)

- file: gateway/host_checker_manager.go
  line: 282
  message: Replacing hostCheckLog prefix with logger (autofix)
  check: host.rules.tyk.log.hostCheckLog.remove.withFields
  example: |
    	log.WithFields(logrus.Fields{
		"prefix": "host-check-mgr",
	}).Debug("Delete key: ", key)

- file: gateway/host_checker_manager.go
  line: 289
  message: Replacing hostCheckLog prefix with logger (autofix)
  check: host.rules.tyk.log.hostCheckLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "host-check-mgr",
		}).Warning("[HOST CHECKER MANAGER] Event can't fire for API that doesn't exist")

- file: gateway/host_checker_manager.go
  line: 299
  message: Replacing hostCheckLog prefix with logger (autofix)
  check: host.rules.tyk.log.hostCheckLog.remove.withFields
  example: |
    	log.WithFields(logrus.Fields{
		"prefix": "host-check-mgr",
	}).Warning("[HOST CHECKER MANAGER] Host is UP:   ", report.CheckURL)

- file: gateway/host_checker_manager.go
  line: 307
  message: Replacing hostCheckLog prefix with logger (autofix)
  check: host.rules.tyk.log.hostCheckLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "host-check-mgr",
		}).Error(err)

- file: gateway/host_checker_manager.go
  line: 312
  message: Replacing hostCheckLog prefix with logger (autofix)
  check: host.rules.tyk.log.hostCheckLog.remove.withFields
  example: |
    	log.WithFields(logrus.Fields{
		"prefix": "host-check-mgr",
	}).Debug("Key is: ", PoolerHostSentinelKeyPrefix+u.Host)

- file: gateway/host_checker_manager.go
  line: 333
  message: Replacing hostCheckLog prefix with logger (autofix)
  check: host.rules.tyk.log.hostCheckLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "host-check-mgr",
		}).Error(err)

- file: gateway/host_checker_manager.go
  line: 344
  message: Replacing hostCheckLog prefix with logger (autofix)
  check: host.rules.tyk.log.hostCheckLog.remove.withFields
  example: |
    			log.WithFields(logrus.Fields{
				"prefix": "host-check-mgr",
			}).Error("Failed to load blob data: ", err)

- file: gateway/host_checker_manager.go
  line: 372
  message: Replacing hostCheckLog prefix with logger (autofix)
  check: host.rules.tyk.log.hostCheckLog.remove.withFields
  example: |
    	log.WithFields(logrus.Fields{
		"prefix": "host-check-mgr",
	}).Debug("--- Setting tracking list up")

- file: gateway/host_checker_manager.go
  line: 383
  message: Replacing hostCheckLog prefix with logger (autofix)
  check: host.rules.tyk.log.hostCheckLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "host-check-mgr",
		}).Debug("Reset initiated")

- file: gateway/host_checker_manager.go
  line: 392
  message: Replacing hostCheckLog prefix with logger (autofix)
  check: host.rules.tyk.log.hostCheckLog.remove.withFields
  example: |
    	log.WithFields(logrus.Fields{
		"prefix": "host-check-mgr",
	}).Debug("--- Setting tracking list up for ID: ", apiId)

- file: gateway/host_checker_manager.go
  line: 412
  message: Replacing hostCheckLog prefix with logger (autofix)
  check: host.rules.tyk.log.hostCheckLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "host-check-mgr",
		}).Debug("Reset initiated")

- file: gateway/host_checker_manager.go
  line: 418
  message: Replacing hostCheckLog prefix with logger (autofix)
  check: host.rules.tyk.log.hostCheckLog.remove.withFields
  example: |
    	log.WithFields(logrus.Fields{
		"prefix": "host-check-mgr",
	}).Info("--- Queued tracking list update for API: ", apiId)

- file: gateway/host_checker_manager.go
  line: 433
  message: Replacing hostCheckLog prefix with logger (autofix)
  check: host.rules.tyk.log.hostCheckLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "host-check-mgr",
		}).Error("[HOST CHECKER MANAGER] Failed to retrieve host list: ", err)

- file: gateway/host_checker_manager.go
  line: 443
  message: Replacing hostCheckLog prefix with logger (autofix)
  check: host.rules.tyk.log.hostCheckLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "host-check-mgr",
		}).Error("[HOST CHECKER MANAGER] Decoder failed: ", err)

- file: gateway/host_checker_manager.go
  line: 453
  message: Replacing hostCheckLog prefix with logger (autofix)
  check: host.rules.tyk.log.hostCheckLog.remove.withFields
  example: |
    			log.WithFields(logrus.Fields{
				"prefix": "host-check-mgr",
			}).Error("[HOST CHECKER MANAGER] failed to convert to HostData", err)

- file: gateway/host_checker_manager.go
  line: 464
  message: Replacing hostCheckLog prefix with logger (autofix)
  check: host.rules.tyk.log.hostCheckLog.remove.withFields
  example: |
    	log.WithFields(logrus.Fields{
		"prefix": "host-check-mgr",
	}).Debug("[HOST CHECKER MANAGER] Getting data from service")

- file: gateway/host_checker_manager.go
  line: 472
  message: Replacing hostCheckLog prefix with logger (autofix)
  check: host.rules.tyk.log.hostCheckLog.remove.withFields
  example: |
    	log.WithFields(logrus.Fields{
		"prefix": "host-check-mgr",
	}).Debug("[HOST CHECKER MANAGER] Data was: \n", hostData)

- file: gateway/host_checker_manager.go
  line: 475
  message: Replacing hostCheckLog prefix with logger (autofix)
  check: host.rules.tyk.log.hostCheckLog.remove.withFields
  example: |
    	log.WithFields(logrus.Fields{
		"prefix": "host-check-mgr",
	}).Info("[HOST CHECKER MANAGER] Refreshing uptime tests from service for API: ", apiID)

- file: gateway/host_checker_manager.go
  line: 524
  message: Replacing hostCheckLog prefix with logger (autofix)
  check: host.rules.tyk.log.hostCheckLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "host-check-mgr",
		}).Error("Error encoding uptime data:", err)

- file: gateway/host_checker_manager.go
  line: 530
  message: Replacing hostCheckLog prefix with logger (autofix)
  check: host.rules.tyk.log.hostCheckLog.remove.withFields
  example: |
    	log.WithFields(logrus.Fields{
		"prefix": "host-check-mgr",
	}).Debug("Recording uptime stat")

- file: gateway/host_checker_manager.go
  line: 549
  message: Replacing hostCheckLog prefix with logger (autofix)
  check: host.rules.tyk.log.hostCheckLog.remove.withFields
  example: |
    	log.WithFields(logrus.Fields{
		"prefix": "host-check-mgr",
	}).Info("Loading uptime tests...")

- file: gateway/host_checker_manager.go
  line: 560
  message: Replacing hostCheckLog prefix with logger (autofix)
  check: host.rules.tyk.log.hostCheckLog.remove.withFields
  example: |
    					log.WithFields(logrus.Fields{
						"prefix": "host-check-mgr",
					}).WithFields(logrus.Fields{

- file: gateway/host_checker_manager.go
  line: 572
  message: Replacing hostCheckLog prefix with logger (autofix)
  check: host.rules.tyk.log.hostCheckLog.remove.withFields
  example: |
    					log.WithFields(logrus.Fields{
						"prefix": "host-check-mgr",
					}).Info("---> Adding uptime test: ", checkItem.CheckURL)

- file: gateway/host_checker_manager.go
  line: 576
  message: Replacing hostCheckLog prefix with logger (autofix)
  check: host.rules.tyk.log.hostCheckLog.remove.withFields
  example: |
    					log.WithFields(logrus.Fields{
						"prefix": "host-check-mgr",
					}).Warning("---> Adding uptime test failed: ", checkItem.CheckURL)

- file: gateway/host_checker_manager.go
  line: 579
  message: Replacing hostCheckLog prefix with logger (autofix)
  check: host.rules.tyk.log.hostCheckLog.remove.withFields
  example: |
    					log.WithFields(logrus.Fields{
						"prefix": "host-check-mgr",
					}).Warning("--------> Error was: ", err)

- file: gateway/redis_signal_handle_config.go
  line: 52
  message: Replacing pubSubLog prefix with logger (autofix)
  check: host.rules.tyk.log.pubSubLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "pub-sub",
		}).Error("Failed to decode configuration payload: ", err)

- file: gateway/redis_signal_handle_config.go
  line: 60
  message: Replacing pubSubLog prefix with logger (autofix)
  check: host.rules.tyk.log.pubSubLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "pub-sub",
		}).Info("Configuration update received, no NodeID/Hostname match found")

- file: gateway/redis_signal_handle_config.go
  line: 67
  message: Replacing pubSubLog prefix with logger (autofix)
  check: host.rules.tyk.log.pubSubLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "pub-sub",
		}).Warning("Ignoring new config: Remote configuration is not allowed for this node.")

- file: gateway/redis_signal_handle_config.go
  line: 74
  message: Replacing pubSubLog prefix with logger (autofix)
  check: host.rules.tyk.log.pubSubLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "pub-sub",
		}).Error("Failed to backup existing configuration: ", err)

- file: gateway/redis_signal_handle_config.go
  line: 81
  message: Replacing pubSubLog prefix with logger (autofix)
  check: host.rules.tyk.log.pubSubLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "pub-sub",
		}).Error("Failed to write new configuration: ", err)

- file: gateway/redis_signal_handle_config.go
  line: 87
  message: Replacing pubSubLog prefix with logger (autofix)
  check: host.rules.tyk.log.pubSubLog.remove.withFields
  example: |
    	log.WithFields(logrus.Fields{
		"prefix": "pub-sub",
	}).Info("Initiating configuration reload")

- file: gateway/redis_signal_handle_config.go
  line: 147
  message: Replacing pubSubLog prefix with logger (autofix)
  check: host.rules.tyk.log.pubSubLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "pub-sub",
		}).Error("Failed unmarshal request: ", err)

- file: gateway/redis_signal_handle_config.go
  line: 155
  message: Replacing pubSubLog prefix with logger (autofix)
  check: host.rules.tyk.log.pubSubLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "pub-sub",
		}).Debug("Configuration request received, no NodeID/Hostname match found, ignoring")

- file: gateway/redis_signal_handle_config.go
  line: 163
  message: Replacing pubSubLog prefix with logger (autofix)
  check: host.rules.tyk.log.pubSubLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "pub-sub",
		}).Error("Failed to get existing configuration: ", err)

- file: gateway/redis_signal_handle_config.go
  line: 178
  message: Replacing pubSubLog prefix with logger (autofix)
  check: host.rules.tyk.log.pubSubLog.remove.withFields
  example: |
    		log.WithFields(logrus.Fields{
			"prefix": "pub-sub",
		}).Error("Failed to get marshal configuration: ", err)

- file: gateway/redis_signal_handle_config.go
  line: 191
  message: Replacing pubSubLog prefix with logger (autofix)
  check: host.rules.tyk.log.pubSubLog.remove.withFields
  example: |
    	log.WithFields(logrus.Fields{
		"prefix": "pub-sub",
	}).Debug("Configuration request responded.")

- file: gateway/server.go
  line: 74
  message: Replacing mainLog prefix with logger (autofix)
  check: host.rules.tyk.log.mainLog.remove.withField
  example: |
    	mainLog   = log.WithField("prefix", "main")

- file: gateway/server.go
  line: 75
  message: Replacing pubSubLog prefix with logger (autofix)
  check: host.rules.tyk.log.pubSubLog.remove.withField
  example: |
    	pubSubLog = log.WithField("prefix", "pub-sub")

Checks by occurence:

  • 40 host.rules.tyk.log.hostCheckLog.remove.withFields
  • 28 host.rules.tyk.log.coprocessLog.remove.withFields
  • 18 host.rules.tyk.log.pythonLog.remove.withFields
  • 13 host.rules.tyk.log.webhookLog.remove.withFields
  • 11 host.rules.tyk.log.mainLog.remove.withFields
  • 11 host.rules.tyk.log.pubSubLog.remove.withFields
  • 4 host.rules.tyk.log.apiLog.remove.prefix.from.Fields
  • 4 host.rules.tyk.log.webhookLog.remove.prefix.from.Fields
  • 3 host.rules.tyk.log.apiLog.remove.withFields
  • 1 host.rules.tyk.log.mainLog.remove.withField
  • 1 host.rules.tyk.log.dashLog.remove.withField
  • 1 host.rules.tyk.log.pubSubLog.remove.prefix.from.Fields
  • 1 host.rules.tyk.log.pubSubLog.remove.withField
  • 1 host.rules.tyk.log.certLog.remove.withField
Steps performed
task: [pull] docker pull semgrep/semgrep -q
docker.io/semgrep/semgrep:latest
task: [default] docker run --rm -v /home/runner/work/exp/exp/lsc/semgrep/src:/src -v /home/runner/work/exp/exp/lsc/semgrep:/host semgrep/semgrep semgrep scan --metrics=off --config /host/rules/tyk/ --autofix --json -o /host/reports/semgrep.tyk.json || true
METRICS: Using configs from the Registry (like --config=p/ci) reports pseudonymous rule metrics to semgrep.dev.
To disable Registry rule metrics, use "--metrics=off".
Using configs only from local files (like --config=xyz.yml) does not enable metrics.

More information: https://semgrep.dev/docs/metrics

             
             
┌─────────────┐
│ Scan Status │
└─────────────┘
Scanning 829 files tracked by git with 32 Code rules:
Scanning 297 files with 32 go rules.
successfully modified 15 files.
              
              
┌──────────────┐
│ Scan Summary │
└──────────────┘
Some files were skipped or only partially analyzed.
Scan was limited to files tracked by git.
Scan skipped: 221 files matching .semgrepignore patterns
For a full list of skipped files, run semgrep with the --verbose flag.

Ran 32 rules on 297 files: 137 findings.

JIRA: https://tyktech.atlassian.net/browse/0000

@buger buger requested a review from a team as a code owner June 27, 2024 12:35
Copy link
Contributor

API Changes

no api changes detected

Copy link
Contributor

PR Reviewer Guide 🔍

⏱️ Estimated effort to review [1-5] 1
🧪 Relevant tests No
🔒 Security concerns No
⚡ Key issues to review None

Copy link
Contributor

Failed to generate code suggestions for PR

@buger buger force-pushed the update/0000/semgrep-check branch from 651d825 to 676457e Compare June 27, 2024 13:07
@buger buger force-pushed the update/0000/semgrep-check branch from 676457e to 3be72f8 Compare June 27, 2024 14:21
Copy link

sonarcloud bot commented Jun 27, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarCloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants