Commit b332caa4 authored by Oswaldo Ferreira's avatar Oswaldo Ferreira

Backport "Track repository pushes as audit events"

parent ab2d5fdd
...@@ -21,6 +21,10 @@ class AuditEventService ...@@ -21,6 +21,10 @@ class AuditEventService
log_security_event_to_database log_security_event_to_database
end end
def log_security_event_to_file
file_logger.info(base_payload.merge(formatted_details))
end
private private
def base_payload def base_payload
...@@ -39,10 +43,6 @@ class AuditEventService ...@@ -39,10 +43,6 @@ class AuditEventService
@details.merge(@details.slice(:from, :to).transform_values(&:to_s)) @details.merge(@details.slice(:from, :to).transform_values(&:to_s))
end end
def log_security_event_to_file
file_logger.info(base_payload.merge(formatted_details))
end
def log_security_event_to_database def log_security_event_to_database
SecurityEvent.create(base_payload.merge(details: @details)) SecurityEvent.create(base_payload.merge(details: @details))
end end
......
...@@ -102,6 +102,7 @@ ...@@ -102,6 +102,7 @@
- [create_github_webhook, 2] - [create_github_webhook, 2]
- [geo, 1] - [geo, 1]
- [repository_update_mirror, 1] - [repository_update_mirror, 1]
- [repository_push_audit_event, 1]
- [new_epic, 2] - [new_epic, 2]
- [project_import_schedule, 1] - [project_import_schedule, 1]
- [project_update_repository_storage, 1] - [project_update_repository_storage, 1]
......
...@@ -47,4 +47,16 @@ describe AuditEventService do ...@@ -47,4 +47,16 @@ describe AuditEventService do
expect(details[:target_id]).to eq(1) expect(details[:target_id]).to eq(1)
end end
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 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