Class MongoUtil
java.lang.Object
dk.cloudcreate.essentials.components.foundation.mongo.MongoUtil
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcheckIsValidCollectionName(String collectionName) Validates if the provided collection name is valid and safe to use.
The method provided is designed as an initial layer of defense against users providing unsafe collection names, by applying naming conventions intended to reduce the risk of malicious input.
However, Essentials components as well ascheckIsValidCollectionName(String)does not offer exhaustive protection, nor does it assure the complete security of the resulting MongoDB configuration and associated Queries/Updates/etc..
The responsibility for implementing protective measures against malicious input lies exclusively with the users/developers using the Essentials components and its supporting classes.
Users must ensure thorough sanitization and validation of API input parameters, collection names.
Insufficient attention to these practices may leave the application vulnerable to attacks, potentially endangering the security and integrity of the database.
-
Field Details
-
MAX_LENGTH
public static final int MAX_LENGTH- See Also:
-
-
Constructor Details
-
MongoUtil
public MongoUtil()
-
-
Method Details
-
checkIsValidCollectionName
Validates if the provided collection name is valid and safe to use.
The method provided is designed as an initial layer of defense against users providing unsafe collection names, by applying naming conventions intended to reduce the risk of malicious input.
However, Essentials components as well ascheckIsValidCollectionName(String)does not offer exhaustive protection, nor does it assure the complete security of the resulting MongoDB configuration and associated Queries/Updates/etc..
The responsibility for implementing protective measures against malicious input lies exclusively with the users/developers using the Essentials components and its supporting classes.
Users must ensure thorough sanitization and validation of API input parameters, collection names.
Insufficient attention to these practices may leave the application vulnerable to attacks, potentially endangering the security and integrity of the database.
The method checks if the
collectionName:- Is not null, empty, and does not consist solely of whitespace.
- Does not start with "system." (case-insensitive check).
- Does not start with $, or contains the null character.
- Contains only characters valid for Mongo collection names: letters, digits, and underscores
- Parameters:
collectionName- The collection name to validate.- Throws:
InvalidCollectionNameException- in case the collectionName violates the rules
-