Skip to content
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

MongoDB pattern does not capture connection string options #1512

Closed
rgmz opened this issue Jul 19, 2023 · 0 comments · Fixed by #1550
Closed

MongoDB pattern does not capture connection string options #1512

rgmz opened this issue Jul 19, 2023 · 0 comments · Fixed by #1550

Comments

@rgmz
Copy link
Contributor

rgmz commented Jul 19, 2023

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

The MongoDB regex only captures the Connection String protocol, username, password, host, and port. It does not capture the defaultauthdb or ?options, which could lead to valid secrets failing verification.

keyPat = regexp.MustCompile(`\b(mongodb(\+srv)?://[\S]{3,50}:([\S]{3,50})@[-.%\w\/:]+)\b`)

For example, the CosmoDB connection string shown in #1511 only partially matches.

https://regex101.com/r/2tl5VU/1

Problem to be Addressed

Improve false-negative detections of MongoDB connection strings.

Description of the Preferred Solution

The preferred solution would be to improve the regex to capture valid Connection Strings,

https://www.mongodb.com/docs/manual/reference/connection-string/

Additional Context

I've created an example regex that matches options. Disclaimer: It's a POC and not well-tested.

https://regex101.com/r/2tl5VU/7

References

N/A

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

1 participant