Files
codeql/python/ql/test/query-tests/Security/CWE-943-NoSqlInjection/PoC/populate.py
Rasmus Lerchedahl Petersen 114984bd8c Python: Added tests based on security analysis
currently we do not:
- recognize the pattern
   `{'author': {"$eq": author}}` as protected
- recognize arguements to `$where` (and friends)
   as vulnerable
2023-09-07 10:22:37 +02:00

17 lines
345 B
Python

from pymongo import MongoClient
client = MongoClient()
db = client.test_database
import datetime
post = {
"author": "Mike",
"text": "My first blog post!",
"tags": ["mongodb", "python", "pymongo"],
"date": datetime.datetime.now(tz=datetime.timezone.utc),
}
posts = db.posts
post_id = posts.insert_one(post).inserted_id
post_id