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
add rabbitmq detector #936
add rabbitmq detector #936
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks for the contribution!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few nit comments, otherwise LGTM. Thanks for the contribution.
var _ detectors.Detector = (*Scanner)(nil) | ||
|
||
var ( | ||
keyPat = regexp.MustCompile(`\b(?:amqp:)?\/\/[\S]{3,50}:([\S]{3,50})@[-.%\w\/:]+\b`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: There look to be a few redundant \
in there for escaping that we can get rid of.
Ex: \b(?:amqp:)?//\S{3,50}:(\S{3,50})@[-.%\w/:]+\b
matches := keyPat.FindAllStringSubmatch(dataStr, -1) | ||
|
||
for _, match := range matches { | ||
urlMatch := match[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: We should add a len check here for match to prevent any IOOR panics.
if len(match) < 3 {
continue
}
} | ||
|
||
if verify { | ||
_, err := amqp.Dial(urlMatch) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: We can inline this if check since the first return val is unused.
if _, err := amqp.dial(urlmatch); err == nil {
s.Verified = true
}
Closes #935
This PR adds a detector for RabbitMQ, where it detects the uri amqp://username:password@host:port
In writing this RabbitMQ detector, I referenced the URI detector code. Feel free to let me know if there's any changes to be made/added!