Class: Contrast::Components::Agent::Interface
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 Agent.
Constant Summary
collapse
- CANON_NAME =
'agent'
- CONFIG_VALUES =
%w[enabled? omit_body?].cs__freeze
ComponentBase::ENABLE
Contrast::Config::Diagnostics::Tools::CHECK
Contrast::Config::Diagnostics::SingletonTools::API_CREDENTIALS, Contrast::Config::Diagnostics::SingletonTools::CONTRAST_MARK
Instance Attribute Summary collapse
Instance Method Summary
collapse
#false?, #file_exists?, #stringify_array, #true?, #valid_cert?
#add_effective_config_values, #add_single_effective_value
#flatten_settings, #to_config_values, #update_config, #value_to_s
Constructor Details
#initialize(hsh = {}) ⇒ Interface
Returns a new instance of Interface.
Instance Attribute Details
#canon_name ⇒ String
24
25
26
|
# File 'lib/contrast/components/agent.rb', line 24
def canon_name
@canon_name
end
|
#config_values ⇒ Array
26
27
28
|
# File 'lib/contrast/components/agent.rb', line 26
def config_values
@config_values
end
|
#enable ⇒ Boolean
28
29
30
|
# File 'lib/contrast/components/agent.rb', line 28
def enable
@enable
end
|
#omit_body ⇒ Boolean
30
31
32
|
# File 'lib/contrast/components/agent.rb', line 30
def omit_body
@omit_body
end
|
Instance Method Details
#disable_agent! ⇒ Object
108
109
110
|
# File 'lib/contrast/components/agent.rb', line 108
def disable_agent!
@_enable = false
end
|
#disabled? ⇒ Boolean
82
83
84
|
# File 'lib/contrast/components/agent.rb', line 82
def disabled?
!enabled?
end
|
86
87
88
|
# File 'lib/contrast/components/agent.rb', line 86
def enable!
@_enable = true
end
|
#enabled? ⇒ Boolean
77
78
79
80
|
# File 'lib/contrast/components/agent.rb', line 77
def enabled?
@_enable = !false?(::Contrast::CONFIG.enable) if @_enable.nil?
@_enable
end
|
#exception_control ⇒ Object
112
113
114
115
116
117
118
|
# File 'lib/contrast/components/agent.rb', line 112
def exception_control
@_exception_control ||= {
enable: true?(ruby.exceptions.capture),
status: ruby.exceptions.override_status || 403,
message: ruby.exceptions.override_message || Contrast::Utils::ObjectShare::OVERRIDE_MESSAGE
}
end
|
#insert_middleware(app) ⇒ Object
Insert ourselves into the application, keeping our middleware at the outermost layer of the onion
127
128
129
|
# File 'lib/contrast/components/agent.rb', line 127
def insert_middleware app
app.middleware.insert_before(0, Contrast::Agent::Middleware)
end
|
#omit_body? ⇒ Boolean
104
105
106
|
# File 'lib/contrast/components/agent.rb', line 104
def omit_body?
true?(@_omit_body)
end
|
#patch_yield? ⇒ Boolean
100
101
102
|
# File 'lib/contrast/components/agent.rb', line 100
def patch_yield?
!false?(ruby.propagate_yield)
end
|
96
97
98
|
# File 'lib/contrast/components/agent.rb', line 96
def ruleset
@_ruleset ||= Contrast::Agent::RuleSet.new(retrieve_protect_ruleset.values)
end
|
#skip_instrumentation?(loaded_module_name) ⇒ Boolean
120
121
122
123
124
|
# File 'lib/contrast/components/agent.rb', line 120
def skip_instrumentation? loaded_module_name
return true unless loaded_module_name
loaded_module_name.start_with?(*::Contrast::CONFIG.agent.ruby.uninstrument_namespace)
end
|
#to_effective_config(effective_config) ⇒ Object
Converts current configuration to effective config values class and appends them to EffectiveConfig class.
139
140
141
142
143
144
145
146
|
# File 'lib/contrast/components/agent.rb', line 139
def to_effective_config effective_config
super
logger&.to_effective_config(effective_config)
security_logger&.to_effective_config(effective_config)
ruby&.to_effective_config(effective_config)
heap_dump&.to_effective_config(effective_config)
polling&.to_effective_config(effective_config)
end
|