Commit 39d52cfb authored by James Lopez's avatar James Lopez

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
parents 12e0fee2 b332caa4
......@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment