Skip to content

Commit

Permalink
Address security issues
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanCoding committed Dec 2, 2024
1 parent 4d09ba1 commit 8b1f9be
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ansible_base/lib/utils/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ def advisory_lock(*args, lock_session_timeout_milliseconds=0, **kwargs):
with connection.cursor() as cur:
idle_in_transaction_session_timeout = cur.execute("SHOW idle_in_transaction_session_timeout").fetchone()[0]
idle_session_timeout = cur.execute("SHOW idle_session_timeout").fetchone()[0]
cur.execute(f"SET idle_in_transaction_session_timeout = '{lock_session_timeout_milliseconds}'")
cur.execute(f"SET idle_session_timeout = '{lock_session_timeout_milliseconds}'")
cur.execute(f"SET idle_in_transaction_session_timeout = %s", (lock_session_timeout_milliseconds,))
cur.execute(f"SET idle_session_timeout = %s", (lock_session_timeout_milliseconds,))
with django_pglocks_advisory_lock(*args, **kwargs) as internal_lock:
yield internal_lock
if lock_session_timeout_milliseconds > 0:
with connection.cursor() as cur:
cur.execute(f"SET idle_in_transaction_session_timeout = '{idle_in_transaction_session_timeout}'")
cur.execute(f"SET idle_session_timeout = '{idle_session_timeout}'")
cur.execute(f"SET idle_in_transaction_session_timeout = %s", (idle_in_transaction_session_timeout,))
cur.execute(f"SET idle_session_timeout = %s", (idle_session_timeout,))
else:
yield True

0 comments on commit 8b1f9be

Please sign in to comment.