Skip to content

Find, verify, and analyze leaked credentials

fix prefix check when returning early (#2503)

Dustin Decker2d2ca4d3d6cc
diff --git a/pkg/detectors/jdbc/mysql.go b/pkg/detectors/jdbc/mysql.go
index 29543c722..c3a631ebe 100644
--- a/pkg/detectors/jdbc/mysql.go
+++ b/pkg/detectors/jdbc/mysql.go
@@ -53,12 +53,12 @@ func isMySQLErrorDeterminate(err error) bool {
func parseConnStr(connStr string) (hostAndDB, params string, err error) {
// expected form: [subprotocol:]//[user:password@]HOST[/DB][?key=val[&key=val]]
hostAndDB, params, found := strings.Cut(connStr, "?")
- if !found {
- return hostAndDB, "", nil
- }
if !strings.HasPrefix(hostAndDB, "//") {
return "", "", errors.New("expected host to start with //")
}
+ if !found {
+ return hostAndDB, "", nil
+ }
splitParams := strings.Split(params, "&")
for i, param := range splitParams {
if strings.Contains(strings.ToLower(param), "allowallfiles") {