Class: Contrast::Components::Protect::Interface

Inherits:
Object
  • Object
show all
Includes:
ComponentBase, Interface
Defined in:
lib/contrast/components/protect.rb

Overview

A wrapper build around the Common Agent Configuration project to allow for access of the values contained in its parent_configuration_spec.yaml. Specifically, this allows for querying the state of the Protect product.

Instance Method Summary collapse

Methods included from Interface

included

Methods included from ComponentBase

included

Instance Method Details

#enabled?Boolean

Returns:

  • (Boolean)


18
19
20
21
22
23
24
# File 'lib/contrast/components/protect.rb', line 18

def enabled?
  # config overrides if forcibly set
  return false if forcibly_disabled?
  return true  if forcibly_enabled?

  SETTINGS.protect_enabled?
end

#forcibly_disabled?Boolean

Returns:

  • (Boolean)


58
59
60
61
# File 'lib/contrast/components/protect.rb', line 58

def forcibly_disabled?
  @_forcibly_disabled = false?(CONFIG.root.protect.enable) if @_forcibly_disabled.nil?
  @_forcibly_disabled
end

#report_any_command_execution?Boolean

Returns:

  • (Boolean)


42
43
44
45
46
47
48
# File 'lib/contrast/components/protect.rb', line 42

def report_any_command_execution?
  if @_report_any_command_execution.nil?
    ctrl = rule_config[Contrast::Agent::Protect::Rule::CmdInjection::NAME]
    @_report_any_command_execution = true?(ctrl.disable_system_commands)
  end
  @_report_any_command_execution
end

#report_custom_code_sysfile_access?Boolean

Returns:

  • (Boolean)


50
51
52
53
54
55
56
# File 'lib/contrast/components/protect.rb', line 50

def report_custom_code_sysfile_access?
  if @_report_custom_code_sysfile_access.nil?
    ctrl = rule_config[Contrast::Agent::Protect::Rule::PathTraversal::NAME]
    @_report_custom_code_sysfile_access = true?(ctrl.detect_custom_code_accessing_system_files)
  end
  @_report_custom_code_sysfile_access
end

#rule(name) ⇒ Object



38
39
40
# File 'lib/contrast/components/protect.rb', line 38

def rule name
  SETTINGS.protect_rules[name]
end

#rule_configObject



26
27
28
# File 'lib/contrast/components/protect.rb', line 26

def rule_config
  CONFIG.root.protect.rules
end

#rule_mode(rule_id) ⇒ Object



34
35
36
# File 'lib/contrast/components/protect.rb', line 34

def rule_mode rule_id
  CONFIG.root.protect.rules[rule_id]&.mode || SETTINGS.modes_by_id[rule_id] || :NO_ACTION
end

#rulesObject



30
31
32
# File 'lib/contrast/components/protect.rb', line 30

def rules
  SETTINGS.protect_rules
end