audit-logs: use specific web/api calls.
- also normalized action_data to specs.
This commit is contained in:
parent
8ae7a08fd3
commit
8a3441e96e
10 changed files with 26 additions and 29 deletions
|
|
@ -1179,11 +1179,10 @@ def delete_repo(request, apiuser, repoid, forks=Optional('')):
|
|||
repo = audit_logger.RepoWrap(repo_id=None,
|
||||
repo_name=repo.repo_name)
|
||||
|
||||
audit_logger.store(
|
||||
audit_logger.store_api(
|
||||
action='repo.delete',
|
||||
action_data={'repo_data': repo_data,
|
||||
'source': audit_logger.SOURCE_API},
|
||||
user=apiuser, repo=repo, commit=False)
|
||||
action_data={'data': repo_data},
|
||||
user=apiuser, repo=repo)
|
||||
|
||||
ScmModel().mark_for_invalidation(repo_name, delete=True)
|
||||
Session().commit()
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ class LoginView(BaseAppView):
|
|||
username=self.request.params.get('username'),
|
||||
ip_addr=self.request.remote_addr)
|
||||
action_data = {'user_agent': self.request.user_agent}
|
||||
audit_logger.store(
|
||||
audit_logger.store_web(
|
||||
action='user.login.success', action_data=action_data,
|
||||
user=audit_user, commit=True)
|
||||
|
||||
|
|
@ -191,7 +191,7 @@ class LoginView(BaseAppView):
|
|||
username=self.request.params.get('username'),
|
||||
ip_addr=self.request.remote_addr)
|
||||
action_data = {'user_agent': self.request.user_agent}
|
||||
audit_logger.store(
|
||||
audit_logger.store_web(
|
||||
action='user.login.failure', action_data=action_data,
|
||||
user=audit_user, commit=True)
|
||||
return render_ctx
|
||||
|
|
@ -211,7 +211,7 @@ class LoginView(BaseAppView):
|
|||
log.info('Deleting session for user: `%s`', auth_user)
|
||||
|
||||
action_data = {'user_agent': self.request.user_agent}
|
||||
audit_logger.store(
|
||||
audit_logger.store_web(
|
||||
action='user.logout', action_data=action_data,
|
||||
user=auth_user, commit=True)
|
||||
self.session.delete()
|
||||
|
|
@ -364,9 +364,10 @@ class LoginView(BaseAppView):
|
|||
|
||||
action_data = {'email': user_email,
|
||||
'user_agent': self.request.user_agent}
|
||||
audit_logger.store(action='user.password.reset_request',
|
||||
action_data=action_data,
|
||||
user=self._rhodecode_user, commit=True)
|
||||
audit_logger.store_web(
|
||||
action='user.password.reset_request',
|
||||
action_data=action_data,
|
||||
user=self._rhodecode_user, commit=True)
|
||||
return HTTPFound(self.request.route_path('reset_password'))
|
||||
|
||||
except formencode.Invalid as errors:
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ class RepoSettingsPermissionsView(RepoAppView):
|
|||
'updated': changes['updated'],
|
||||
'deleted': changes['deleted'],
|
||||
}
|
||||
audit_logger.store(
|
||||
audit_logger.store_web(
|
||||
'repo.edit.permissions', action_data=action_data,
|
||||
user=self._rhodecode_user, repo=self.db_repo)
|
||||
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ class RepoSettingsView(RepoAppView):
|
|||
RepoModel().update(self.db_repo, **validated_updates)
|
||||
ScmModel().mark_for_invalidation(new_repo_name)
|
||||
|
||||
audit_logger.store(
|
||||
audit_logger.store_web(
|
||||
'repo.edit', action_data={'old_data': old_values},
|
||||
user=self._rhodecode_user, repo=self.db_repo)
|
||||
|
||||
|
|
|
|||
|
|
@ -99,11 +99,10 @@ class RepoSettingsView(RepoAppView):
|
|||
|
||||
repo = audit_logger.RepoWrap(repo_id=None,
|
||||
repo_name=self.db_repo.repo_name)
|
||||
audit_logger.store(
|
||||
audit_logger.store_web(
|
||||
action='repo.delete',
|
||||
action_data={'repo_data': repo_data,
|
||||
'source': audit_logger.SOURCE_WEB},
|
||||
user=self._rhodecode_user, repo=repo, commit=False)
|
||||
action_data={'data': repo_data},
|
||||
user=self._rhodecode_user, repo=repo)
|
||||
|
||||
ScmModel().mark_for_invalidation(self.db_repo_name, delete=True)
|
||||
h.flash(
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ class StripView(RepoAppView):
|
|||
commit['rev'], c.repo_info.repo_name, user))
|
||||
data[commit['rev']] = True
|
||||
|
||||
audit_logger.store(
|
||||
audit_logger.store_web(
|
||||
action='repo.commit.strip',
|
||||
action_data={'commit_id': commit['rev']},
|
||||
repo=self.db_repo,
|
||||
|
|
|
|||
|
|
@ -189,9 +189,9 @@ class RepoGroupsController(BaseController):
|
|||
repo_group_data = repo_group.get_api_data()
|
||||
_new_group_name = form_result['group_name_full']
|
||||
|
||||
audit_logger.store(
|
||||
audit_logger.store_web(
|
||||
action='repo_group.create',
|
||||
action_data={'repo_group_data': repo_group_data},
|
||||
action_data={'data': repo_group_data},
|
||||
user=c.rhodecode_user, commit=True)
|
||||
|
||||
repo_group_url = h.link_to(
|
||||
|
|
@ -251,7 +251,7 @@ class RepoGroupsController(BaseController):
|
|||
gr_name = form_result['group_name']
|
||||
new_gr = RepoGroupModel().update(group_name, form_result)
|
||||
|
||||
audit_logger.store(
|
||||
audit_logger.store_web(
|
||||
'repo_group.edit', action_data={'old_data': old_values},
|
||||
user=c.rhodecode_user)
|
||||
|
||||
|
|
@ -303,10 +303,9 @@ class RepoGroupsController(BaseController):
|
|||
old_values = gr.get_api_data()
|
||||
RepoGroupModel().delete(group_name)
|
||||
|
||||
audit_logger.store(
|
||||
audit_logger.store_web(
|
||||
'repo_group.delete',
|
||||
action_data={'old_data': old_values,
|
||||
'source': audit_logger.SOURCE_WEB},
|
||||
action_data={'old_data': old_values},
|
||||
user=c.rhodecode_user)
|
||||
|
||||
Session().commit()
|
||||
|
|
@ -395,9 +394,8 @@ class RepoGroupsController(BaseController):
|
|||
'added': changes['added'],
|
||||
'updated': changes['updated'],
|
||||
'deleted': changes['deleted'],
|
||||
'source': audit_logger.SOURCE_WEB
|
||||
}
|
||||
audit_logger.store(
|
||||
audit_logger.store_web(
|
||||
'repo_group.edit.permissions', action_data=action_data,
|
||||
user=c.rhodecode_user)
|
||||
|
||||
|
|
|
|||
|
|
@ -814,7 +814,7 @@ class FilesController(BaseRepoController):
|
|||
archive = cached_archive_path
|
||||
|
||||
# store download action
|
||||
audit_logger.store(
|
||||
audit_logger.store_web(
|
||||
action='repo.archive.download',
|
||||
action_data={'user_agent': request.user_agent,
|
||||
'archive_name': archive_name,
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ def store(action, user, action_data=None, user_data=None, ip_addr=None,
|
|||
audit_logger.store(
|
||||
action='repo.edit', user=self._rhodecode_user)
|
||||
audit_logger.store(
|
||||
action='repo.delete', action_data={'repo_data': repo_data},
|
||||
action='repo.delete', action_data={'data': repo_data},
|
||||
user=audit_logger.UserWrap(username='itried-login', ip_addr='8.8.8.8'))
|
||||
|
||||
# repo action
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ def create_repo(form_data, cur_user):
|
|||
repo_id = repo.repo_id
|
||||
repo_data = repo.get_api_data()
|
||||
|
||||
audit_logger.store(
|
||||
audit_logger.store_web(
|
||||
action='repo.create',
|
||||
action_data={'data': repo_data},
|
||||
user=cur_user,
|
||||
|
|
@ -274,7 +274,7 @@ def create_repo_fork(form_data, cur_user):
|
|||
|
||||
repo_id = repo.repo_id
|
||||
repo_data = repo.get_api_data()
|
||||
audit_logger.store(
|
||||
audit_logger.store_web(
|
||||
action='repo.fork',
|
||||
action_data={'data': repo_data},
|
||||
user=cur_user,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue