Skip to content

Find, verify, and analyze leaked credentials

make sure to close connections after testing (#2343)

ahrav41cfec4e1cb5
diff --git a/pkg/detectors/rabbitmq/rabbitmq.go b/pkg/detectors/rabbitmq/rabbitmq.go
index 9e6bfb032..6526252fc 100644
--- a/pkg/detectors/rabbitmq/rabbitmq.go
+++ b/pkg/detectors/rabbitmq/rabbitmq.go
@@ -2,10 +2,11 @@ package rabbitmq
import (
"context"
- regexp "github.com/wasilibs/go-re2"
"net/url"
"strings"
+ regexp "github.com/wasilibs/go-re2"
+
amqp "github.com/rabbitmq/amqp091-go"
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors"
@@ -59,10 +60,13 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
}
if verify {
- _, err := amqp.Dial(urlMatch)
+ conn, err := amqp.Dial(urlMatch)
if err == nil {
s.Verified = true
}
+ if conn != nil {
+ conn.Close()
+ }
}
if !s.Verified {