Class: Claws::Rule::GlobalPermissionsBlock

Inherits:
BaseRule
  • Object
show all
Defined in:
lib/claws/rule/global_permissions_block.rb

Instance Attribute Summary

Attributes inherited from BaseRule

#configuration, #on_job, #on_step, #on_workflow

Instance Method Summary collapse

Methods inherited from BaseRule

#data, description, extract_value, #initialize, #inspect, #name, name, on_job, on_step, on_workflow, parse_rule, #to_s

Constructor Details

This class inherits a constructor from BaseRule

Instance Method Details

#test_root_level_permissions(workflow:, job:, step:) ⇒ Object

rubocop:disable Lint/UnusedMethodArgument



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/claws/rule/global_permissions_block.rb', line 20

def test_root_level_permissions(workflow:, job:, step:) # rubocop:disable Lint/UnusedMethodArgument
  root_permission_block_line = workflow.keys.filter { |x| x == "permissions" }.first&.line
  return if root_permission_block_line.nil?

  job_count = workflow["jobs"]&.count || 0
  return if job_count < 2

  Violation.new(
    line: root_permission_block_line,
    description:
  )
end