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.1.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.1-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mongo_secure-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 f52025916663cad80a8531a201232c368b117ad0b24bf8584c243f9b3a5a56d7
MD5 8d663b7783d0ec07142fe55eda2347b8
BLAKE2b-256 5f270c7b5dae40213da1d3c6a38dfcd061f9a59dfdfd6014ea1450631d6300cc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mongo_secure-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f9b859a73ff99fd0a17feebf95ffc13faa9bc8ad7e4f6c3d34fa630ec770f813
MD5 3e2348f174f6ba0f8275feb8ca9b00ef
BLAKE2b-256 0c11f38b0bdce50614636ef0ce2c6bd5fb8c59e355e4d83ac3c2d46026a35d5a

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