MongoDB Security Access Control FAQ

Connect with

18. Which of the following audit filters will allow us to monitor the creation of collections on databases that begin with “university”?

Check all that apply:

a. { atype: "createCollection", "param.ns": /university/ }
b. { atype: "createCollection", "param.ns": /university.*/ }
c. { atype: "createCollection", "param.ns": /^university/ }
d. { atype: "createCollection", "param.ns": /^university.*/ }

Ans: a and d

Answer

For this quiz it’s most helpful to see what is wrong with the incorrect answers first.

{ atype: "createCollection", "param.ns": /university/ }

This answer is incorrect because it will match any database that contains the string “university” rather than just databases that begin with “university”.

{ atype: "createCollection", "param.ns": /university.*/ }

This answer is effectively the same as the answer before it. It will match any string that contains “university” and is followed by zero or more characters as signified by the .*.

{ atype: "createCollection", "param.ns": /^university/ }

This is the most elegant solution which uses the ^ to signify that the string must begin with “university”.

{ atype: "createCollection", "param.ns": /^university.*/ }

This answer is effectively the same as the answer above, but add a superfulous .* to match zero or more characters. While this solution isn’t as elegant as the solution above, some people would argue that the intent of the regex is more clear.


Connect with

Leave a Comment

Your email address will not be published. Required fields are marked *