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.3.tar.gz (4.0 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.3-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mongo_secure-0.1.3.tar.gz
  • Upload date:
  • Size: 4.0 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.3.tar.gz
Algorithm Hash digest
SHA256 f2583a9de9756590049204addb00ff924360fd3c9ba5f501c1c4cede29dc2efb
MD5 5f0a962a24705fc5da50d261b2d200f1
BLAKE2b-256 abae5ee39307e3b9a9aa65f43bd608cda0a02c0b84711b68ae72ae072d98af16

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mongo_secure-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 3.9 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 bb218bd360a4e2e494900c84177679b243adeb4c87cc397c740ff835151eb1e7
MD5 023e2e5b45519f5fc52bed4f759cc4b4
BLAKE2b-256 2a38bee48cc2df52ec0b13c759314d75035bf3d154ceec5dd6b418bdd8d9de1b

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