bpo-43762: Add audit events for loading of sqlite3 extensions (GH-25246)

This commit is contained in:
Erlend Egeberg Aasland 2021-04-27 01:16:46 +02:00 committed by GitHub
parent 52cd6d5e1b
commit 7244c0060d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 86 additions and 0 deletions

View file

@ -359,6 +359,27 @@ def test_http_client():
conn.close()
def test_sqlite3():
import sqlite3
def hook(event, *args):
if event.startswith("sqlite3."):
print(event, *args)
sys.addaudithook(hook)
cx = sqlite3.connect(":memory:")
# Configured without --enable-loadable-sqlite-extensions
if hasattr(sqlite3.Connection, "enable_load_extension"):
cx.enable_load_extension(False)
try:
cx.load_extension("test")
except sqlite3.OperationalError:
pass
else:
raise RuntimeError("Expected sqlite3.load_extension to fail")
if __name__ == "__main__":
from test.support import suppress_msvcrt_asserts