Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mongo_secure

Sanitize selected function arguments by replacing MongoDB operators.

Installation

pip install mongo_secure

Usage

from mongo_secure import sanitize


@sanitize("name", "place")
def hello_world(name, place):
    print(name)
    print(place)

hello_world("$toInt", "$gt")
#<= _toInt
#<= _gt

Nested objects are sanitized recursively

from mongo_secure import replace_blocked_mongo_operators


payload = {
    "$set": {
        "age": "$toInt",
        "tags": ["safe", "$where"]
    }
}


print(replace_blocked_mongo_operators(payload))
#<= {"_set": {"age": "_toInt", "tags": ["safe", "_where"]}}

License

MIT

About

Sanitize MongoDB operator strings in selected function arguments.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages