Merge branch 'osw-record-repo-push-events' into 'master'
Backport EE "Track repository pushes as audit events" See merge request gitlab-org/gitlab-ce!32304
This commit is contained in:
commit
39d52cfba2
3 changed files with 17 additions and 4 deletions
|
@ -21,6 +21,10 @@ class AuditEventService
|
|||
log_security_event_to_database
|
||||
end
|
||||
|
||||
def log_security_event_to_file
|
||||
file_logger.info(base_payload.merge(formatted_details))
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def base_payload
|
||||
|
@ -39,10 +43,6 @@ class AuditEventService
|
|||
@details.merge(@details.slice(:from, :to).transform_values(&:to_s))
|
||||
end
|
||||
|
||||
def log_security_event_to_file
|
||||
file_logger.info(base_payload.merge(formatted_details))
|
||||
end
|
||||
|
||||
def log_security_event_to_database
|
||||
SecurityEvent.create(base_payload.merge(details: @details))
|
||||
end
|
||||
|
|
|
@ -102,6 +102,7 @@
|
|||
- [create_github_webhook, 2]
|
||||
- [geo, 1]
|
||||
- [repository_update_mirror, 1]
|
||||
- [repository_push_audit_event, 1]
|
||||
- [new_epic, 2]
|
||||
- [project_import_schedule, 1]
|
||||
- [project_update_repository_storage, 1]
|
||||
|
|
|
@ -47,4 +47,16 @@ describe AuditEventService do
|
|||
expect(details[:target_id]).to eq(1)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#log_security_event_to_file' do
|
||||
it 'logs security event to file' do
|
||||
expect(service).to receive(:file_logger).and_return(logger)
|
||||
expect(logger).to receive(:info).with(author_id: user.id,
|
||||
entity_type: 'Project',
|
||||
entity_id: project.id,
|
||||
action: :destroy)
|
||||
|
||||
service.log_security_event_to_file
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue