make sure to close connections after testing (#2343)

This commit is contained in:
ahrav 2024-01-26 09:24:06 -08:00 committed by GitHub
parent f078df43eb
commit 41cfec4e1c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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 {