Class: Contrast::Components::Protect::Interface
- 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
- #enabled? ⇒ Boolean
- #forcibly_disabled? ⇒ Boolean
- #report_any_command_execution? ⇒ Boolean
- #report_custom_code_sysfile_access? ⇒ Boolean
- #rule(name) ⇒ Object
- #rule_config ⇒ Object
- #rule_mode(rule_id) ⇒ Object
- #rules ⇒ Object
Methods included from Interface
Methods included from ComponentBase
Instance Method Details
#enabled? ⇒ 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
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
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
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_config ⇒ Object
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 |
#rules ⇒ Object
30 31 32 |
# File 'lib/contrast/components/protect.rb', line 30 def rules SETTINGS.protect_rules end |