diff --git a/generic/mongodb-insecure-transport.sh b/generic/mongodb-insecure-transport.sh index c55c63e..2617a57 100644 --- a/generic/mongodb-insecure-transport.sh +++ b/generic/mongodb-insecure-transport.sh @@ -6,8 +6,48 @@ mongo "mongodb://user:pass@db0.example.com,db1.example.com,db2.example.com/" # ruleid: mongodb-insecure-transport mongo "mongodb://user:pass@db0.example.com,db1.example.com,db2.example.com/?tls=true&tlsAllowInvalidCertificates=true" +# ruleid: mongodb-insecure-transport +mongo "mongodb://user:pass@db0.example.com,db1.example.com,db2.example.com/?tls=true&tlsAllowInvalidCertificates=true&something=else" + +# we want to be lenient here +# ruleid: mongodb-insecure-transport +mongo "mongodb://user:pass@db0.example.com,db1.example.com,db2.example.com/?tls=true&tlsAllowInvalidCertificates=truebutbug" + +# ruleid: mongodb-insecure-transport +mongo "mongodb://user:pass@db0.example.com,db1.example.com,db2.example.com/?tls=true&tlsAllowInvalidCertificates=truebutbug&something=else" + +# we want to be strict here +# ruleid: mongodb-insecure-transport +mongo "mongodb://user:pass@db0.example.com,db1.example.com,db2.example.com/?tls=truebutbug" + +# ruleid: mongodb-insecure-transport +mongo "mongodb://user:pass@db0.example.com,db1.example.com,db2.example.com/?tls=truebutbug&something=else" + # ok: mongodb-insecure-transport mongo "mongodb://user:pass@db0.example.com,db1.example.com,db2.example.com/?tls=true" +# ok: mongodb-insecure-transport +mongo "mongodb://user:pass@db0.example.com,db1.example.com,db2.example.com/?tls=true&something=else" + # ok: mongodb-insecure-transport mongo "mongodb://user:pass@db0.example.com,db1.example.com,db2.example.com/?ssl=true" + +echo ' +# ok: mongodb-insecure-transport +mongodb://user:pass@db0.example.com,db1.example.com,db2.example.com/?ssl=true +' + +echo ' +# ruleid: mongodb-insecure-transport +mongodb://user:pass@db0.example.com,db1.example.com,db2.example.com/?ssl=truebutbug +' + +echo ' +# ok: mongodb-insecure-transport +mongodb://user:pass@db0.example.com,db1.example.com,db2.example.com/?ssl=true&something=else +' + +echo ' +# ruleid: mongodb-insecure-transport +mongodb://user:pass@db0.example.com,db1.example.com,db2.example.com/?ssl=truebutbug&something=else +' diff --git a/generic/mongodb-insecure-transport.yaml b/generic/mongodb-insecure-transport.yaml index 78e20eb..9d61baf 100644 --- a/generic/mongodb-insecure-transport.yaml +++ b/generic/mongodb-insecure-transport.yaml @@ -17,9 +17,9 @@ rules: - https://www.mongodb.com/docs/manual/reference/connection-string/#connection-options pattern-either: - patterns: - - pattern-regex: "mongodb://.+$" - - pattern-not-regex: "mongodb://.+[?&]tls=true.*$" - - pattern-not-regex: "mongodb://.+[?&]ssl=true.*$" - - pattern-regex: "mongodb://.+[?&]tlsAllowInvalidCertificates=true.*$" - - pattern-regex: "mongodb://.+[?&]tlsAllowInvalidHostnames=true.*$" - - pattern-regex: "mongodb://.+[?&]tlsInsecure=true.*$" + - pattern-regex: mongodb://.+$ + - pattern-not-regex: (?:(.)?)?mongodb://.+[?&]tls=true(?:\g{1}|$|&).* + - pattern-not-regex: (?:(.)?)?mongodb://.+[?&]ssl=true(?:\g{1}|$|&).* + - pattern-regex: mongodb://.+[?&]tlsAllowInvalidCertificates=true.*$ + - pattern-regex: mongodb://.+[?&]tlsAllowInvalidHostnames=true.*$ + - pattern-regex: mongodb://.+[?&]tlsInsecure=true.*$