Pass security manager to QUERY_LOGGER (#6548)

* Pass security manager to log_query

* Fix lint
This commit is contained in:
Beto Dealmeida 2018-12-18 10:55:58 -08:00 committed by GitHub
parent fe994900ec
commit 672c470e79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 2 deletions

View File

@ -285,7 +285,14 @@ BACKUP_COUNT = 30
# Custom logger for auditing queries. This can be used to send ran queries to a
# structured immutable store for auditing purposes. The function is called for
# every query ran, in both SQL Lab and charts/dashboards.
# def QUERY_LOGGER(database, query, schema=None, user=None, client=None):
# def QUERY_LOGGER(
# database,
# query,
# schema=None,
# user=None,
# client=None,
# security_manager=None,
# ):
# pass
# Set this API key to enable Mapbox visualizations

View File

@ -813,7 +813,7 @@ class Database(Model, AuditMixinNullable, ImportMixin):
def _log_query(sql):
if log_query:
log_query(engine.url, sql, schema, username, __name__)
log_query(engine.url, sql, schema, username, __name__, security_manager)
with closing(engine.raw_connection()) as conn:
with closing(conn.cursor()) as cursor:

View File

@ -189,6 +189,7 @@ def execute_sql(
query.schema,
user_name,
__name__,
security_manager,
)
db_engine_spec.execute(cursor, query.executed_sql, async_=True)
logging.info('Handling cursor')