Skip to main content

Sanitize MongoDB operator strings in selected function arguments.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mongo_secure-0.1.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mongo_secure-0.1.0-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file mongo_secure-0.1.0.tar.gz.

File metadata

  • Download URL: mongo_secure-0.1.0.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.13

File hashes

Hashes for mongo_secure-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4e6e454315354bfe24f494193634557a44c38806371494deaa4b766dbcd42d8d
MD5 4077cdf48de4ef87d9f3f7b08d55768a
BLAKE2b-256 a8e26e97763e3f7e85c7083f793bc021712357ef06425df8f063057337875ae5

See more details on using hashes here.

File details

Details for the file mongo_secure-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mongo_secure-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.13

File hashes

Hashes for mongo_secure-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d726deda39a700d34363070c6ab4b37ac830fe6161fda14f09b11fc38b42dd0d
MD5 069df46e577de4c4a5f46d6328c0e320
BLAKE2b-256 25408c229684d50038ac8ffbda526436d4b10297f29e8f6783f202d7a5f7fe9a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page