Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
b332caa4
Commit
b332caa4
authored
Aug 27, 2019
by
Oswaldo Ferreira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Backport "Track repository pushes as audit events"
parent
ab2d5fdd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
4 deletions
+17
-4
app/services/audit_event_service.rb
app/services/audit_event_service.rb
+4
-4
config/sidekiq_queues.yml
config/sidekiq_queues.yml
+1
-0
spec/services/audit_event_service_spec.rb
spec/services/audit_event_service_spec.rb
+12
-0
No files found.
app/services/audit_event_service.rb
View file @
b332caa4
...
@@ -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
...
...
config/sidekiq_queues.yml
View file @
b332caa4
...
@@ -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]
...
...
spec/services/audit_event_service_spec.rb
View file @
b332caa4
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment