Class: Gitlab::Audit::CiRunnerTokenAuthor

Inherits:
NullAuthor
  • Object
show all
Defined in:
lib/gitlab/audit/ci_runner_token_author.rb

Instance Attribute Summary

Attributes inherited from NullAuthor

#id, #name

Instance Method Summary collapse

Methods inherited from NullAuthor

#current_sign_in_ip, for

Constructor Details

#initialize(audit_event) ⇒ CiRunnerTokenAuthor

Represents a CI Runner token (registration or authentication)

Parameters:

  • audit_event (AuditEvent)

    event representing a runner registration/un-registration operation



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/gitlab/audit/ci_runner_token_author.rb', line 9

def initialize(audit_event)
  if audit_event.details.include?(:runner_authentication_token)
    token = audit_event.details[:runner_authentication_token]
    name = "Authentication token: #{token}"
  elsif audit_event.details.include?(:runner_registration_token)
    token = audit_event.details[:runner_registration_token]
    name = "Registration token: #{token}"
  else
    raise ArgumentError, 'Runner token missing'
  end

  super(id: -1, name: name)

  @entity_type = audit_event.entity_type
  @entity_path = audit_event.entity_path
end

Instance Method Details

#full_pathObject



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/gitlab/audit/ci_runner_token_author.rb', line 26

def full_path
  url_helpers = ::Gitlab::Routing.url_helpers

  case @entity_type
  when 'Group'
    url_helpers.group_settings_ci_cd_path(@entity_path, anchor: 'js-runners-settings')
  when 'Project'
    project = Project.find_by_full_path(@entity_path)
    url_helpers.project_settings_ci_cd_path(project, anchor: 'js-runners-settings') if project
  else
    url_helpers.admin_runners_path
  end
end