refactor(model/log): pull allowed action types into constant
This commit is contained in:
parent
d0aaaaa1ef
commit
20c4d971c4
1 changed files with 5 additions and 1 deletions
|
@ -11,6 +11,8 @@ from data.model import config, user, DataModelException
|
|||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
ACTIONS_ALLOWED_WITHOUT_AUDIT_LOGGING = ['pull_repo']
|
||||
|
||||
def _logs_query(selections, start_time, end_time, performer=None, repository=None, namespace=None,
|
||||
ignore=None):
|
||||
joined = (LogEntry
|
||||
|
@ -121,10 +123,12 @@ def log_action(kind_name, user_or_organization_name, performer=None, repository=
|
|||
'metadata_json': metadata_json,
|
||||
'datetime': timestamp
|
||||
}
|
||||
|
||||
try:
|
||||
LogEntry.create(**log_data)
|
||||
except PeeweeException as ex:
|
||||
if kind_name is 'pull_repo' and config.app_config.get('ALLOW_PULLS_WITHOUT_STRICT_LOGGING'):
|
||||
strict_logging_disabled = config.app_config.get('ALLOW_PULLS_WITHOUT_STRICT_LOGGING')
|
||||
if strict_logging_disabled and kind_name in ACTIONS_ALLOWED_WITHOUT_AUDIT_LOGGING:
|
||||
logger.exception('log_action failed', extra=({'exception': ex}).update(log_data))
|
||||
else:
|
||||
raise
|
||||
|
|
Reference in a new issue