Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git_audit_event.rb « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b8365bdf41f621dd327877b1edad65aa1bcbe59e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# frozen_string_literal: true

module Gitlab
  class GitAuditEvent # rubocop:disable Gitlab/NamespacedClass
    attr_reader :project, :user, :author

    def initialize(player, project)
      @project = project
      @author = player.is_a?(::API::Support::GitAccessActor) ? player.deploy_key_or_user : player
      @user = player.is_a?(::API::Support::GitAccessActor) ? player.user : player
    end

    def send_audit_event(msg)
      return if user.blank? || project.blank?

      audit_context = {
        name: 'repository_git_operation',
        stream_only: true,
        author: author,
        scope: project,
        target: project,
        message: msg
      }

      ::Gitlab::Audit::Auditor.audit(audit_context)
    end
  end
end