Skip to content

Commit

Permalink
make sure to close connections after testing (#2343)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahrav committed Jan 26, 2024
1 parent f078df4 commit 41cfec4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/detectors/rabbitmq/rabbitmq.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 41cfec4

Please sign in to comment.