contrast-agent 6.7.0 → 6.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -2
- data/.simplecov +0 -1
- data/Rakefile +0 -1
- data/ext/cs__assess_array/cs__assess_array.c +41 -10
- data/ext/cs__assess_array/cs__assess_array.h +4 -1
- data/lib/contrast/agent/assess/policy/trigger_method.rb +3 -3
- data/lib/contrast/agent/assess/policy/trigger_validation/redos_validator.rb +1 -1
- data/lib/contrast/agent/assess/policy/trigger_validation/ssrf_validator.rb +1 -1
- data/lib/contrast/agent/assess/policy/trigger_validation/xss_validator.rb +1 -1
- data/lib/contrast/agent/assess/property/evented.rb +11 -11
- data/lib/contrast/agent/assess.rb +0 -1
- data/lib/contrast/agent/excluder.rb +53 -35
- data/lib/contrast/agent/exclusion_matcher.rb +21 -9
- data/lib/contrast/agent/middleware.rb +12 -6
- data/lib/contrast/agent/patching/policy/after_load_patcher.rb +6 -0
- data/lib/contrast/agent/protect/input_analyzer/input_analyzer.rb +146 -127
- data/lib/contrast/agent/protect/input_analyzer/worth_watching_analyzer.rb +116 -0
- data/lib/contrast/agent/protect/policy/applies_path_traversal_rule.rb +20 -0
- data/lib/contrast/agent/protect/policy/rule_applicator.rb +1 -1
- data/lib/contrast/agent/protect/rule/base.rb +47 -55
- data/lib/contrast/agent/protect/rule/base_service.rb +48 -24
- data/lib/contrast/agent/protect/rule/bot_blocker/bot_blocker_input_classification.rb +98 -0
- data/lib/contrast/agent/protect/rule/bot_blocker.rb +81 -0
- data/lib/contrast/agent/protect/rule/cmd_injection.rb +20 -2
- data/lib/contrast/agent/protect/rule/cmdi/cmdi_backdoors.rb +8 -5
- data/lib/contrast/agent/protect/rule/cmdi/cmdi_base_rule.rb +22 -22
- data/lib/contrast/agent/protect/rule/cmdi/cmdi_chained_command.rb +64 -0
- data/lib/contrast/agent/protect/rule/cmdi/cmdi_dangerous_path.rb +63 -0
- data/lib/contrast/agent/protect/rule/cmdi/cmdi_input_classification.rb +2 -58
- data/lib/contrast/agent/protect/rule/default_scanner.rb +1 -1
- data/lib/contrast/agent/protect/rule/deserialization.rb +3 -14
- data/lib/contrast/agent/protect/rule/http_method_tampering/http_method_tampering_input_classification.rb +2 -2
- data/lib/contrast/agent/protect/rule/http_method_tampering.rb +0 -11
- data/lib/contrast/agent/protect/rule/no_sqli/no_sqli_input_classification.rb +29 -34
- data/lib/contrast/agent/protect/rule/no_sqli.rb +25 -18
- data/lib/contrast/agent/protect/rule/path_traversal/path_traversal_input_classification.rb +61 -0
- data/lib/contrast/agent/protect/rule/path_traversal/path_traversal_semantic_security_bypass.rb +114 -0
- data/lib/contrast/agent/protect/rule/path_traversal.rb +40 -13
- data/lib/contrast/agent/protect/rule/sql_sample_builder.rb +33 -15
- data/lib/contrast/agent/protect/rule/sqli/sqli_base_rule.rb +0 -14
- data/lib/contrast/agent/protect/rule/sqli/sqli_input_classification.rb +2 -62
- data/lib/contrast/agent/protect/rule/sqli.rb +74 -3
- data/lib/contrast/agent/protect/rule/unsafe_file_upload/unsafe_file_upload_input_classification.rb +39 -63
- data/lib/contrast/agent/protect/rule/unsafe_file_upload.rb +6 -33
- data/lib/contrast/agent/protect/rule/xss/reflected_xss_input_classification.rb +58 -0
- data/lib/contrast/agent/protect/rule/xss.rb +15 -20
- data/lib/contrast/agent/protect/rule/xxe.rb +4 -24
- data/lib/contrast/agent/reporting/attack_result/rasp_rule_sample.rb +19 -40
- data/lib/contrast/agent/reporting/attack_result/response_type.rb +9 -9
- data/lib/contrast/agent/reporting/details/ip_denylist_details.rb +10 -2
- data/lib/contrast/agent/reporting/details/virtual_patch_details.rb +8 -2
- data/lib/contrast/agent/reporting/input_analysis/details/bot_blocker_details.rb +27 -0
- data/lib/contrast/agent/reporting/input_analysis/details/protect_rule_details.rb +15 -0
- data/lib/contrast/agent/reporting/input_analysis/input_analysis.rb +1 -2
- data/lib/contrast/agent/reporting/input_analysis/input_analysis_result.rb +16 -2
- data/lib/contrast/agent/reporting/masker/masker.rb +2 -0
- data/lib/contrast/agent/reporting/report.rb +1 -0
- data/lib/contrast/agent/reporting/reporter.rb +35 -14
- data/lib/contrast/agent/reporting/reporter_heartbeat.rb +3 -9
- data/lib/contrast/agent/reporting/reporting_events/application_activity.rb +16 -13
- data/lib/contrast/agent/reporting/reporting_events/application_defend_activity.rb +12 -7
- data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_activity.rb +3 -3
- data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample.rb +1 -2
- data/lib/contrast/agent/reporting/reporting_events/application_inventory_activity.rb +6 -1
- data/lib/contrast/agent/reporting/reporting_events/application_update.rb +0 -2
- data/lib/contrast/agent/reporting/reporting_events/architecture_component.rb +0 -1
- data/lib/contrast/agent/reporting/reporting_events/finding.rb +6 -6
- data/lib/contrast/agent/reporting/reporting_events/finding_event.rb +239 -93
- data/lib/contrast/agent/reporting/reporting_events/finding_event_signature.rb +10 -23
- data/lib/contrast/agent/reporting/reporting_events/finding_event_source.rb +10 -9
- data/lib/contrast/agent/reporting/reporting_events/finding_request.rb +0 -5
- data/lib/contrast/agent/reporting/reporting_events/library_discovery.rb +0 -1
- data/lib/contrast/agent/reporting/reporting_events/observed_route.rb +12 -0
- data/lib/contrast/agent/reporting/reporting_events/poll.rb +1 -11
- data/lib/contrast/agent/reporting/reporting_events/route_discovery.rb +0 -1
- data/lib/contrast/agent/reporting/reporting_events/route_discovery_observation.rb +0 -1
- data/lib/contrast/agent/reporting/reporting_events/server_reporting_event.rb +8 -0
- data/lib/contrast/agent/reporting/reporting_events/server_settings.rb +40 -0
- data/lib/contrast/agent/reporting/reporting_utilities/audit.rb +2 -2
- data/lib/contrast/agent/reporting/reporting_utilities/endpoints.rb +6 -0
- data/lib/contrast/agent/reporting/reporting_utilities/reporter_client.rb +43 -1
- data/lib/contrast/agent/reporting/reporting_utilities/reporter_client_utils.rb +8 -4
- data/lib/contrast/agent/reporting/reporting_utilities/response.rb +1 -1
- data/lib/contrast/agent/reporting/reporting_utilities/response_extractor.rb +58 -4
- data/lib/contrast/agent/reporting/reporting_utilities/response_handler.rb +4 -6
- data/lib/contrast/agent/reporting/reporting_utilities/response_handler_utils.rb +77 -16
- data/lib/contrast/agent/reporting/server_settings_worker.rb +44 -0
- data/lib/contrast/agent/reporting/settings/assess_server_feature.rb +14 -2
- data/lib/contrast/agent/reporting/settings/code_exclusion.rb +6 -1
- data/lib/contrast/agent/reporting/settings/exclusion_base.rb +18 -0
- data/lib/contrast/agent/reporting/settings/exclusions.rb +2 -1
- data/lib/contrast/agent/reporting/settings/helpers.rb +7 -0
- data/lib/contrast/agent/reporting/settings/input_exclusion.rb +9 -3
- data/lib/contrast/agent/reporting/settings/protect.rb +15 -15
- data/lib/contrast/agent/reporting/settings/protect_server_feature.rb +39 -2
- data/lib/contrast/agent/reporting/settings/rule_definition.rb +3 -0
- data/lib/contrast/agent/reporting/settings/security_logger.rb +77 -0
- data/lib/contrast/agent/reporting/settings/server_features.rb +9 -0
- data/lib/contrast/agent/reporting/settings/syslog.rb +34 -5
- data/lib/contrast/agent/request.rb +3 -14
- data/lib/contrast/agent/request_context.rb +6 -9
- data/lib/contrast/agent/request_context_extend.rb +9 -148
- data/lib/contrast/agent/request_handler.rb +5 -10
- data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exception_event.rb +1 -1
- data/lib/contrast/agent/thread_watcher.rb +37 -18
- data/lib/contrast/agent/version.rb +1 -1
- data/lib/contrast/agent.rb +6 -11
- data/lib/contrast/agent_lib/api/command_injection.rb +46 -0
- data/lib/contrast/agent_lib/api/init.rb +101 -0
- data/lib/contrast/agent_lib/api/input_tracing.rb +267 -0
- data/lib/contrast/agent_lib/api/method_tempering.rb +29 -0
- data/lib/contrast/agent_lib/api/panic.rb +87 -0
- data/lib/contrast/agent_lib/api/path_semantic_file_security_bypass.rb +40 -0
- data/lib/contrast/agent_lib/interface.rb +260 -0
- data/lib/contrast/agent_lib/interface_base.rb +118 -0
- data/lib/contrast/agent_lib/return_types/eval_result.rb +44 -0
- data/lib/contrast/agent_lib/test.rb +29 -0
- data/lib/contrast/api/communication/connection_status.rb +20 -5
- data/lib/contrast/components/agent.rb +34 -14
- data/lib/contrast/components/api.rb +23 -0
- data/lib/contrast/components/app_context.rb +23 -5
- data/lib/contrast/components/app_context_extend.rb +0 -25
- data/lib/contrast/components/assess.rb +34 -4
- data/lib/contrast/components/assess_rules.rb +18 -0
- data/lib/contrast/components/base.rb +40 -0
- data/lib/contrast/components/config/sources.rb +95 -0
- data/lib/contrast/components/config.rb +19 -19
- data/lib/contrast/components/heap_dump.rb +10 -0
- data/lib/contrast/components/inventory.rb +15 -2
- data/lib/contrast/components/logger.rb +18 -0
- data/lib/contrast/components/polling.rb +36 -0
- data/lib/contrast/components/protect.rb +52 -2
- data/lib/contrast/components/ruby_component.rb +16 -1
- data/lib/contrast/components/sampling.rb +70 -13
- data/lib/contrast/components/security_logger.rb +13 -0
- data/lib/contrast/components/settings.rb +105 -90
- data/lib/contrast/config/certification_configuration.rb +14 -0
- data/lib/contrast/config/config.rb +46 -0
- data/lib/contrast/config/diagnostics.rb +114 -0
- data/lib/contrast/config/diagnostics_tools.rb +98 -0
- data/lib/contrast/config/effective_config.rb +65 -0
- data/lib/contrast/config/effective_config_value.rb +32 -0
- data/lib/contrast/config/exception_configuration.rb +12 -0
- data/lib/contrast/config/protect_rule_configuration.rb +8 -8
- data/lib/contrast/config/protect_rules_configuration.rb +23 -60
- data/lib/contrast/config/request_audit_configuration.rb +13 -0
- data/lib/contrast/config/server_configuration.rb +41 -2
- data/lib/contrast/configuration.rb +29 -12
- data/lib/contrast/extension/assess/array.rb +9 -0
- data/lib/contrast/extension/assess/erb.rb +1 -1
- data/lib/contrast/extension/delegator.rb +2 -0
- data/lib/contrast/framework/manager.rb +3 -1
- data/lib/contrast/framework/rails/railtie.rb +0 -1
- data/lib/contrast/framework/rails/support.rb +0 -1
- data/lib/contrast/tasks/config.rb +1 -8
- data/lib/contrast/utils/assess/event_limit_utils.rb +31 -9
- data/lib/contrast/utils/assess/trigger_method_utils.rb +5 -4
- data/lib/contrast/utils/duck_utils.rb +1 -0
- data/lib/contrast/utils/hash_digest.rb +2 -2
- data/lib/contrast/utils/input_classification_base.rb +155 -0
- data/lib/contrast/utils/os.rb +0 -20
- data/lib/contrast/utils/reporting/application_activity_batch_utils.rb +81 -0
- data/lib/contrast/utils/response_utils.rb +0 -16
- data/lib/contrast/utils/routes_sent.rb +60 -0
- data/lib/contrast/utils/stack_trace_utils.rb +3 -15
- data/lib/contrast/utils/string_utils.rb +10 -7
- data/lib/contrast/utils/telemetry_client.rb +1 -2
- data/lib/contrast/utils/timer.rb +16 -0
- data/lib/contrast.rb +5 -4
- data/resources/protect/policy.json +1 -2
- data/ruby-agent.gemspec +7 -6
- metadata +69 -130
- data/exe/contrast_service +0 -23
- data/lib/contrast/agent/assess/contrast_event.rb +0 -157
- data/lib/contrast/agent/assess/events/event_factory.rb +0 -34
- data/lib/contrast/agent/assess/events/source_event.rb +0 -46
- data/lib/contrast/agent/protect/rule/cmdi/cmdi_worth_watching.rb +0 -64
- data/lib/contrast/agent/protect/rule/sqli/sqli_worth_watching.rb +0 -118
- data/lib/contrast/agent/protect/rule/unsafe_file_upload/unsafe_file_upload_matcher.rb +0 -45
- data/lib/contrast/agent/reaction_processor.rb +0 -47
- data/lib/contrast/agent/reporting/reporting_events/server_activity.rb +0 -36
- data/lib/contrast/agent/service_heartbeat.rb +0 -35
- data/lib/contrast/api/communication/messaging_queue.rb +0 -128
- data/lib/contrast/api/communication/response_processor.rb +0 -90
- data/lib/contrast/api/communication/service_lifecycle.rb +0 -77
- data/lib/contrast/api/communication/socket.rb +0 -44
- data/lib/contrast/api/communication/socket_client.rb +0 -130
- data/lib/contrast/api/communication/speedracer.rb +0 -138
- data/lib/contrast/api/communication/tcp_socket.rb +0 -32
- data/lib/contrast/api/communication/unix_socket.rb +0 -28
- data/lib/contrast/api/communication.rb +0 -20
- data/lib/contrast/api/decorators/address.rb +0 -59
- data/lib/contrast/api/decorators/agent_startup.rb +0 -56
- data/lib/contrast/api/decorators/application_settings.rb +0 -43
- data/lib/contrast/api/decorators/application_startup.rb +0 -56
- data/lib/contrast/api/decorators/bot_blocker.rb +0 -37
- data/lib/contrast/api/decorators/http_request.rb +0 -137
- data/lib/contrast/api/decorators/input_analysis.rb +0 -18
- data/lib/contrast/api/decorators/instrumentation_mode.rb +0 -35
- data/lib/contrast/api/decorators/ip_denylist.rb +0 -37
- data/lib/contrast/api/decorators/message.rb +0 -67
- data/lib/contrast/api/decorators/rasp_rule_sample.rb +0 -52
- data/lib/contrast/api/decorators/response_type.rb +0 -17
- data/lib/contrast/api/decorators/server_features.rb +0 -25
- data/lib/contrast/api/decorators/user_input.rb +0 -51
- data/lib/contrast/api/decorators/virtual_patch.rb +0 -34
- data/lib/contrast/api/decorators.rb +0 -22
- data/lib/contrast/api/dtm.pb.rb +0 -363
- data/lib/contrast/api/settings.pb.rb +0 -500
- data/lib/contrast/api.rb +0 -16
- data/lib/contrast/components/contrast_service.rb +0 -88
- data/lib/contrast/components/service.rb +0 -55
- data/lib/contrast/tasks/service.rb +0 -84
- data/lib/contrast/utils/input_classification.rb +0 -73
- data/lib/protobuf/code_generator.rb +0 -129
- data/lib/protobuf/decoder.rb +0 -28
- data/lib/protobuf/deprecation.rb +0 -117
- data/lib/protobuf/descriptors/google/protobuf/compiler/plugin.pb.rb +0 -79
- data/lib/protobuf/descriptors/google/protobuf/descriptor.pb.rb +0 -360
- data/lib/protobuf/descriptors.rb +0 -3
- data/lib/protobuf/encoder.rb +0 -11
- data/lib/protobuf/enum.rb +0 -365
- data/lib/protobuf/exceptions.rb +0 -9
- data/lib/protobuf/field/base_field.rb +0 -380
- data/lib/protobuf/field/base_field_object_definitions.rb +0 -504
- data/lib/protobuf/field/bool_field.rb +0 -64
- data/lib/protobuf/field/bytes_field.rb +0 -67
- data/lib/protobuf/field/double_field.rb +0 -25
- data/lib/protobuf/field/enum_field.rb +0 -56
- data/lib/protobuf/field/field_array.rb +0 -102
- data/lib/protobuf/field/field_hash.rb +0 -122
- data/lib/protobuf/field/fixed32_field.rb +0 -25
- data/lib/protobuf/field/fixed64_field.rb +0 -28
- data/lib/protobuf/field/float_field.rb +0 -43
- data/lib/protobuf/field/int32_field.rb +0 -21
- data/lib/protobuf/field/int64_field.rb +0 -34
- data/lib/protobuf/field/integer_field.rb +0 -23
- data/lib/protobuf/field/message_field.rb +0 -51
- data/lib/protobuf/field/sfixed32_field.rb +0 -27
- data/lib/protobuf/field/sfixed64_field.rb +0 -28
- data/lib/protobuf/field/signed_integer_field.rb +0 -29
- data/lib/protobuf/field/sint32_field.rb +0 -21
- data/lib/protobuf/field/sint64_field.rb +0 -21
- data/lib/protobuf/field/string_field.rb +0 -51
- data/lib/protobuf/field/uint32_field.rb +0 -21
- data/lib/protobuf/field/uint64_field.rb +0 -21
- data/lib/protobuf/field/varint_field.rb +0 -77
- data/lib/protobuf/field.rb +0 -74
- data/lib/protobuf/generators/base.rb +0 -85
- data/lib/protobuf/generators/enum_generator.rb +0 -39
- data/lib/protobuf/generators/extension_generator.rb +0 -27
- data/lib/protobuf/generators/field_generator.rb +0 -193
- data/lib/protobuf/generators/file_generator.rb +0 -262
- data/lib/protobuf/generators/group_generator.rb +0 -122
- data/lib/protobuf/generators/message_generator.rb +0 -104
- data/lib/protobuf/generators/option_generator.rb +0 -17
- data/lib/protobuf/generators/printable.rb +0 -160
- data/lib/protobuf/generators/service_generator.rb +0 -50
- data/lib/protobuf/lifecycle.rb +0 -33
- data/lib/protobuf/logging.rb +0 -39
- data/lib/protobuf/message/fields.rb +0 -233
- data/lib/protobuf/message/serialization.rb +0 -85
- data/lib/protobuf/message.rb +0 -241
- data/lib/protobuf/optionable.rb +0 -72
- data/lib/protobuf/tasks/compile.rake +0 -80
- data/lib/protobuf/tasks.rb +0 -1
- data/lib/protobuf/varint.rb +0 -20
- data/lib/protobuf/varint_pure.rb +0 -31
- data/lib/protobuf/version.rb +0 -3
- data/lib/protobuf/wire_type.rb +0 -10
- data/lib/protobuf.rb +0 -91
- data/proto/dynamic_discovery.proto +0 -46
- data/proto/google/protobuf/compiler/plugin.proto +0 -183
- data/proto/google/protobuf/descriptor.proto +0 -911
- data/proto/rpc.proto +0 -71
- data/service_executables/.gitkeep +0 -0
- data/service_executables/VERSION +0 -1
- data/service_executables/linux/contrast-service +0 -0
- data/service_executables/mac/contrast-service +0 -0
@@ -2,12 +2,13 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require 'rubygems/version'
|
5
|
+
require 'contrast/components/base'
|
5
6
|
require 'contrast/agent/rule_set'
|
6
7
|
require 'contrast/components/logger'
|
7
8
|
require 'contrast/components/security_logger'
|
8
9
|
require 'contrast/components/heap_dump'
|
9
|
-
require 'contrast/components/service'
|
10
10
|
require 'contrast/components/ruby_component'
|
11
|
+
require 'contrast/components/polling'
|
11
12
|
|
12
13
|
module Contrast
|
13
14
|
module Components
|
@@ -18,36 +19,38 @@ module Contrast
|
|
18
19
|
class Interface
|
19
20
|
include Contrast::Components::ComponentBase
|
20
21
|
|
22
|
+
# @return [String]
|
23
|
+
attr_reader :canon_name
|
24
|
+
# @return [Array]
|
25
|
+
attr_reader :config_values
|
26
|
+
|
27
|
+
CANON_NAME = 'agent'
|
28
|
+
CONFIG_VALUES = %w[enabled? omit_body?].cs__freeze
|
29
|
+
|
21
30
|
def initialize hsh = {}
|
31
|
+
@config_values = CONFIG_VALUES
|
32
|
+
@canon_name = CANON_NAME
|
22
33
|
return unless hsh
|
23
34
|
|
24
35
|
@_enable = hsh[:enable]
|
25
|
-
@_start_bundled_service = hsh[:start_bundled_service]
|
26
36
|
@_omit_body = hsh[:omit_body]
|
27
|
-
@
|
37
|
+
@_polling = Contrast::Components::Polling::Interface.new(hsh[:polling])
|
28
38
|
@_logger = Contrast::Components::Logger::Interface.new(hsh[:logger])
|
29
39
|
@_security_logger = Contrast::Components::SecurityLogger::Interface.new(hsh[:security_logger])
|
30
40
|
@_ruby = Contrast::Components::Ruby::Interface.new(hsh[:ruby])
|
31
41
|
@_heap_dump = Contrast::Components::HeapDump::Interface.new(hsh[:heap_dump])
|
32
42
|
end
|
33
43
|
|
34
|
-
# @return [Boolean, true]
|
35
|
-
def start_bundled_service?
|
36
|
-
@_start_bundled_service.nil? ? true : @_start_bundled_service
|
37
|
-
end
|
38
|
-
|
39
|
-
def service
|
40
|
-
return @_service unless @_service.nil?
|
41
|
-
|
42
|
-
@_service = Contrast::Components::Service::Interface.new
|
43
|
-
end
|
44
|
-
|
45
44
|
def logger
|
46
45
|
return @_logger unless @_logger.nil?
|
47
46
|
|
48
47
|
@_logger = Contrast::Components::Logger::Interface.new
|
49
48
|
end
|
50
49
|
|
50
|
+
def polling
|
51
|
+
@_polling ||= Contrast::Components::Polling::Interface.new
|
52
|
+
end
|
53
|
+
|
51
54
|
def security_logger
|
52
55
|
return @_security_logger unless @_security_logger.nil?
|
53
56
|
|
@@ -101,6 +104,10 @@ module Contrast
|
|
101
104
|
@_omit_body
|
102
105
|
end
|
103
106
|
|
107
|
+
def disable_agent!
|
108
|
+
@_enable = false
|
109
|
+
end
|
110
|
+
|
104
111
|
def exception_control
|
105
112
|
@_exception_control ||= {
|
106
113
|
enable: true?(ruby.exceptions.capture),
|
@@ -124,6 +131,19 @@ module Contrast
|
|
124
131
|
Contrast::Agent::TracePointHook.enable!
|
125
132
|
end
|
126
133
|
|
134
|
+
# Converts current configuration to effective config values class and appends them to
|
135
|
+
# EffectiveConfig class.
|
136
|
+
#
|
137
|
+
# @param effective_config [Contrast::Agent::DiagnosticsConfig::EffectiveConfig]
|
138
|
+
def to_effective_config effective_config
|
139
|
+
super
|
140
|
+
logger&.to_effective_config(effective_config)
|
141
|
+
security_logger&.to_effective_config(effective_config)
|
142
|
+
ruby&.to_effective_config(effective_config)
|
143
|
+
heap_dump&.to_effective_config(effective_config)
|
144
|
+
polling&.to_effective_config(effective_config)
|
145
|
+
end
|
146
|
+
|
127
147
|
protected
|
128
148
|
|
129
149
|
def retrieve_protect_ruleset
|
@@ -17,6 +17,10 @@ module Contrast
|
|
17
17
|
include Contrast::Components::ComponentBase
|
18
18
|
include Contrast::Config::BaseConfiguration
|
19
19
|
|
20
|
+
CANON_NAME = 'api'
|
21
|
+
PROXY_NAME = "#{ CANON_NAME }.proxy"
|
22
|
+
CONFIG_VALUES = %w[api_key user_name service_key url].cs__freeze
|
23
|
+
|
20
24
|
# @return [String]
|
21
25
|
attr_accessor :api_key
|
22
26
|
# @return [String]
|
@@ -120,8 +124,27 @@ module Contrast
|
|
120
124
|
@_certification_key_file ||= ::Contrast::CONFIG.api.certificate.key_file
|
121
125
|
end
|
122
126
|
|
127
|
+
# Converts current configuration to effective config values class and appends them to
|
128
|
+
# EffectiveConfig class.
|
129
|
+
#
|
130
|
+
# @param effective_config [Contrast::Agent::DiagnosticsConfig::EffectiveConfig]
|
131
|
+
def to_effective_config effective_config
|
132
|
+
add_effective_config_values(effective_config, CONFIG_VALUES, CANON_NAME, CONTRAST)
|
133
|
+
effective_proxy(effective_config)
|
134
|
+
request_audit&.to_effective_config(effective_config)
|
135
|
+
certificate&.to_effective_config(effective_config)
|
136
|
+
end
|
137
|
+
|
123
138
|
private
|
124
139
|
|
140
|
+
# @param effective_config [Contrast::Agent::DiagnosticsConfig::EffectiveConfig]
|
141
|
+
def effective_proxy effective_config
|
142
|
+
add_single_effective_value(effective_config, ENABLE, proxy_enable.to_s, PROXY_NAME, "#{ CONTRAST }.proxy")
|
143
|
+
return unless proxy_url && proxy_enable
|
144
|
+
|
145
|
+
add_single_effective_value(effective_config, 'url', proxy_url, PROXY_NAME, "#{ CONTRAST }.proxy")
|
146
|
+
end
|
147
|
+
|
125
148
|
def certification_truly_enabled? config_path
|
126
149
|
return false unless true?(config_path.enable)
|
127
150
|
return true if file_exists?(certification_ca_file) && valid_cert?(certification_ca_file)
|
@@ -2,8 +2,6 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require 'rubygems/version'
|
5
|
-
require 'contrast/api/decorators/agent_startup'
|
6
|
-
require 'contrast/api/decorators/application_startup'
|
7
5
|
require 'contrast/utils/object_share'
|
8
6
|
require 'contrast/components/app_context_extend'
|
9
7
|
require 'contrast/config/base_configuration'
|
@@ -16,7 +14,7 @@ module Contrast
|
|
16
14
|
# parent_configuration_spec.yaml.
|
17
15
|
# Specifically, this allows for querying the state of the Application,
|
18
16
|
# including the Client, Process, and Server information.
|
19
|
-
class Interface
|
17
|
+
class Interface # rubocop:disable Metrics/ClassLength
|
20
18
|
include Contrast::Components::AppContextExtend
|
21
19
|
include Contrast::Components::ComponentBase
|
22
20
|
include Contrast::Config::BaseConfiguration
|
@@ -25,6 +23,8 @@ module Contrast
|
|
25
23
|
DEFAULT_APP_PATH = '/'
|
26
24
|
DEFAULT_SERVER_NAME = 'localhost'
|
27
25
|
DEFAULT_SERVER_PATH = '/'
|
26
|
+
CANON_NAME = 'application'
|
27
|
+
CONFIG_VALUES = %w[name version language path group tags code metadata session_id session_metadata].cs__freeze
|
28
28
|
|
29
29
|
# @return [String]
|
30
30
|
attr_accessor :version
|
@@ -32,15 +32,20 @@ module Contrast
|
|
32
32
|
attr_accessor :language
|
33
33
|
# @return [String]
|
34
34
|
attr_accessor :group
|
35
|
-
|
36
|
-
attr_accessor :tags
|
35
|
+
attr_writer :tags
|
37
36
|
# @return [String]
|
38
37
|
attr_accessor :code
|
39
38
|
# @return [String]
|
40
39
|
attr_accessor :metadata
|
40
|
+
# @return [String]
|
41
|
+
attr_reader :canon_name
|
42
|
+
# @return [Array]
|
43
|
+
attr_reader :config_values
|
41
44
|
|
42
45
|
def initialize hsh = {}
|
43
46
|
original_pid
|
47
|
+
@config_values = CONFIG_VALUES
|
48
|
+
@canon_name = CANON_NAME
|
44
49
|
return unless hsh
|
45
50
|
|
46
51
|
@_name = hsh[:name]
|
@@ -137,6 +142,10 @@ module Contrast
|
|
137
142
|
end
|
138
143
|
end
|
139
144
|
|
145
|
+
def tags
|
146
|
+
stringify_array(@tags)
|
147
|
+
end
|
148
|
+
|
140
149
|
# Determines if the Process we're currently in matches that of the
|
141
150
|
# Process in which the App Context instance was created.
|
142
151
|
# If it doesn't, that indicates the running context is in a new
|
@@ -149,6 +158,15 @@ module Contrast
|
|
149
158
|
current_pid != original_pid
|
150
159
|
end
|
151
160
|
|
161
|
+
# Converts current configuration to effective config values class and appends them to
|
162
|
+
# EffectiveConfig class.
|
163
|
+
#
|
164
|
+
# @param effective_config [Contrast::Agent::DiagnosticsConfig::EffectiveConfig]
|
165
|
+
def to_effective_config effective_config
|
166
|
+
super
|
167
|
+
Contrast::CONFIG.server.to_effective_config(effective_config)
|
168
|
+
end
|
169
|
+
|
152
170
|
private
|
153
171
|
|
154
172
|
def original_pid
|
@@ -12,23 +12,6 @@ module Contrast
|
|
12
12
|
SUPPORTED_FRAMEWORKS = %w[rails sinatra grape rack].cs__freeze
|
13
13
|
SUPPORTED_SERVERS = %w[passenger puma thin unicorn].cs__freeze
|
14
14
|
|
15
|
-
def build_app_startup_message
|
16
|
-
@_build_app_startup_message ||= Contrast::Api::Dtm::ApplicationCreate.build
|
17
|
-
end
|
18
|
-
|
19
|
-
def build_agent_startup_message
|
20
|
-
msg = Contrast::Api::Dtm::AgentStartup.build(server_name, server_path, server_type)
|
21
|
-
Contrast::CONFIG.proto_logger.info('Application context',
|
22
|
-
server_name: msg.server_name,
|
23
|
-
server_path: msg.server_path,
|
24
|
-
server_type: msg.server_type,
|
25
|
-
application_name: name, # rubocop:disable Security/Module/Name
|
26
|
-
application_path: path,
|
27
|
-
application_language: Contrast::Utils::ObjectShare::RUBY)
|
28
|
-
|
29
|
-
msg
|
30
|
-
end
|
31
|
-
|
32
15
|
def pid
|
33
16
|
Process.pid
|
34
17
|
end
|
@@ -37,14 +20,6 @@ module Contrast
|
|
37
20
|
Process.ppid
|
38
21
|
end
|
39
22
|
|
40
|
-
def pgid
|
41
|
-
Process.getpgid(pid)
|
42
|
-
end
|
43
|
-
|
44
|
-
def client_id
|
45
|
-
@_client_id ||= [name, pgid].join('-') # rubocop:disable Security/Module/Name
|
46
|
-
end
|
47
|
-
|
48
23
|
def app_and_server_information
|
49
24
|
{
|
50
25
|
application_info: find_gem_information(SUPPORTED_FRAMEWORKS),
|
@@ -15,21 +15,36 @@ module Contrast
|
|
15
15
|
class Interface # rubocop:disable Metrics/ClassLength
|
16
16
|
include Contrast::Components::ComponentBase
|
17
17
|
|
18
|
-
# @return [String, nil]
|
19
|
-
attr_accessor :tags
|
20
18
|
# @return [Boolean, nil]
|
21
19
|
attr_accessor :enable
|
22
20
|
# @return [Array, nil]
|
23
|
-
attr_writer :enable_scan_response, :enable_dynamic_sources, :sampling, :rules, :stacktraces
|
21
|
+
attr_writer :enable_scan_response, :enable_dynamic_sources, :sampling, :rules, :stacktraces, :tags
|
22
|
+
# @return [String]
|
23
|
+
attr_reader :canon_name
|
24
|
+
# @return [Array]
|
25
|
+
attr_reader :config_values
|
24
26
|
|
25
27
|
DEFAULT_STACKTRACES = 'ALL'
|
26
28
|
DEFAULT_MAX_SOURCE_EVENTS = 50_000
|
27
29
|
DEFAULT_MAX_PROPAGATION_EVENTS = 50_000
|
28
30
|
DEFAULT_MAX_RULE_REPORTED = 100
|
29
31
|
DEFAULT_MAX_RULE_TIME_THRESHOLD = 300_000
|
30
|
-
|
32
|
+
CANON_NAME = 'assess'
|
33
|
+
CONFIG_VALUES = %w[
|
34
|
+
enabled?
|
35
|
+
tags
|
36
|
+
enable_scan_response
|
37
|
+
enable_original_object
|
38
|
+
stacktraces
|
39
|
+
max_context_source_events
|
40
|
+
max_propagation_events
|
41
|
+
max_rule_reported
|
42
|
+
time_limit_threshold
|
43
|
+
].cs__freeze
|
31
44
|
# rubocop:disable Naming/MemoizedInstanceVariableName
|
32
45
|
def initialize hsh = {}
|
46
|
+
@config_values = CONFIG_VALUES
|
47
|
+
@canon_name = CANON_NAME
|
33
48
|
return unless hsh
|
34
49
|
|
35
50
|
@enable = hsh[:enable]
|
@@ -91,6 +106,11 @@ module Contrast
|
|
91
106
|
@max_context_source_events ||= DEFAULT_MAX_SOURCE_EVENTS
|
92
107
|
end
|
93
108
|
|
109
|
+
# @return [String, nil]
|
110
|
+
def tags
|
111
|
+
stringify_array(@tags)
|
112
|
+
end
|
113
|
+
|
94
114
|
def enabled?
|
95
115
|
# config overrides if forcibly set
|
96
116
|
return false if forcibly_disabled?
|
@@ -187,6 +207,16 @@ module Contrast
|
|
187
207
|
::Contrast::SETTINGS.assess_state.session_id
|
188
208
|
end
|
189
209
|
|
210
|
+
# Converts current configuration to effective config values class and appends them to
|
211
|
+
# EffectiveConfig class.
|
212
|
+
#
|
213
|
+
# @param effective_config [Contrast::Agent::DiagnosticsConfig::EffectiveConfig]
|
214
|
+
def to_effective_config effective_config
|
215
|
+
super
|
216
|
+
sampling&.to_effective_config(effective_config)
|
217
|
+
rules&.to_effective_config(effective_config)
|
218
|
+
end
|
219
|
+
|
190
220
|
# rubocop:enable Naming/MemoizedInstanceVariableName
|
191
221
|
private
|
192
222
|
|
@@ -2,6 +2,8 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require 'contrast/config/base_configuration'
|
5
|
+
require 'contrast/utils/object_share'
|
6
|
+
require 'contrast/components/base'
|
5
7
|
|
6
8
|
module Contrast
|
7
9
|
module Components
|
@@ -10,17 +12,33 @@ module Contrast
|
|
10
12
|
module AssessRules
|
11
13
|
class Interface # :nodoc:
|
12
14
|
include Contrast::Config::BaseConfiguration
|
15
|
+
include Contrast::Components::ComponentBase
|
13
16
|
|
14
17
|
SPEC_KEY = :disabled_rules.cs__freeze
|
18
|
+
CANON_NAME = 'assess.rules'
|
19
|
+
NAME_PREFIX = "#{ CONTRAST }.#{ CANON_NAME }"
|
20
|
+
|
15
21
|
# @return [Array, nil] list of disabled assess rules
|
16
22
|
attr_accessor :disabled_rules
|
23
|
+
# @return [String]
|
24
|
+
attr_reader :canon_name
|
17
25
|
|
18
26
|
def initialize hsh = {}
|
27
|
+
@canon_name = CANON_NAME
|
28
|
+
@disabled_rules = []
|
19
29
|
return unless hsh
|
20
30
|
|
21
31
|
@disabled_rules = cast_disabled_rules(hsh)
|
22
32
|
end
|
23
33
|
|
34
|
+
# Converts current configuration to effective config values class and appends them to
|
35
|
+
# EffectiveConfig class.
|
36
|
+
#
|
37
|
+
# @param effective_config [Contrast::Agent::DiagnosticsConfig::EffectiveConfig]
|
38
|
+
def to_effective_config effective_config
|
39
|
+
add_single_effective_value(effective_config, SPEC_KEY.to_s, disabled_rules, canon_name, NAME_PREFIX)
|
40
|
+
end
|
41
|
+
|
24
42
|
private
|
25
43
|
|
26
44
|
def cast_disabled_rules hsh
|
@@ -1,11 +1,33 @@
|
|
1
1
|
# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
+
require 'contrast/config/diagnostics_tools'
|
5
|
+
require 'contrast/utils/object_share'
|
6
|
+
|
4
7
|
module Contrast
|
5
8
|
module Components
|
6
9
|
# All components should inherit from this,
|
7
10
|
# whether Interfaces, InstanceMethods or ClassMethods.
|
8
11
|
module ComponentBase
|
12
|
+
include Contrast::Agent::DiagnosticsConfig::DiagnosticsTools
|
13
|
+
|
14
|
+
CONTRAST = 'contrast'
|
15
|
+
ENABLE = 'enable'
|
16
|
+
|
17
|
+
# Used for config diagnostics. Override per rule.
|
18
|
+
#
|
19
|
+
# @return [String]
|
20
|
+
def canon_name
|
21
|
+
Contrast::Utils::ObjectShare::EMPTY_STRING
|
22
|
+
end
|
23
|
+
|
24
|
+
# Used for config diagnostics. Override per rule.
|
25
|
+
#
|
26
|
+
# @return [Array]
|
27
|
+
def config_values
|
28
|
+
Contrast::Utils::ObjectShare::EMPTY_ARRAY
|
29
|
+
end
|
30
|
+
|
9
31
|
# use this to determine if the configuration value is literally boolean
|
10
32
|
# false or some form of the word `false`, regardless of case. It should
|
11
33
|
# be used for those values which default to `true` as they should only
|
@@ -58,6 +80,24 @@ module Contrast
|
|
58
80
|
|
59
81
|
File.exist?(path)
|
60
82
|
end
|
83
|
+
|
84
|
+
# Converts current configuration to effective config values class and appends them to
|
85
|
+
# EffectiveConfig class.
|
86
|
+
#
|
87
|
+
# @param effective_config [Contrast::Agent::DiagnosticsConfig::EffectiveConfig]
|
88
|
+
def to_effective_config effective_config
|
89
|
+
add_effective_config_values(effective_config, config_values, canon_name, "#{ CONTRAST }.#{ canon_name }")
|
90
|
+
end
|
91
|
+
|
92
|
+
# attempts to stringifys the config value if it is an array with the join char
|
93
|
+
# @param val[Object] val to stringify
|
94
|
+
# @param join_char[String, ','] join character defaults to ','
|
95
|
+
# @return [String, Object] the stringified val or the object as is
|
96
|
+
def stringify_array val, join_char = ','
|
97
|
+
return val.join(join_char) if val.cs__is_a?(Array)
|
98
|
+
|
99
|
+
val
|
100
|
+
end
|
61
101
|
end
|
62
102
|
end
|
63
103
|
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'contrast/utils/env_configuration_item'
|
5
|
+
require 'ougai'
|
6
|
+
require 'contrast/configuration'
|
7
|
+
|
8
|
+
module Contrast
|
9
|
+
module Components
|
10
|
+
module Config
|
11
|
+
# This component encapsulates storing the source for each entry in the config,
|
12
|
+
# so that we can report on where the value was set from.
|
13
|
+
class Sources
|
14
|
+
ENVIRONMENT = 'ENV'
|
15
|
+
CLI = 'CLI'
|
16
|
+
CONTRASTUI = 'ContrastUI'
|
17
|
+
DEFAULT = 'Default'
|
18
|
+
YAML = 'YAML'
|
19
|
+
|
20
|
+
# @return [Hash]
|
21
|
+
attr_reader :data
|
22
|
+
|
23
|
+
def initialize data = {}
|
24
|
+
@data = data
|
25
|
+
end
|
26
|
+
|
27
|
+
# Retrieves the current config source for the specified config path. If no source is
|
28
|
+
# set then returns the Default value.
|
29
|
+
#
|
30
|
+
# @param path [String] the canonical name for the config entry (such as api.proxy.enable)
|
31
|
+
# @return [String] the source for the entry
|
32
|
+
def get path
|
33
|
+
data.dig(*parts_for(path)) || DEFAULT
|
34
|
+
rescue TypeError
|
35
|
+
DEFAULT
|
36
|
+
end
|
37
|
+
|
38
|
+
# Assigns the config source for a specified config path.
|
39
|
+
#
|
40
|
+
# @param path [String] the canonical name for the config entry (such as api.proxy.enable)
|
41
|
+
# @param [String] the source for the entry
|
42
|
+
# @return [String] the source type for the entry
|
43
|
+
def set path, source
|
44
|
+
assign_value(data, parts_for(path), source)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Finds entries within config source data for the specified type, and returns
|
48
|
+
# them along with the current values for each.
|
49
|
+
#
|
50
|
+
# @param type [String] a source type (ENV, CLI, ContrastUI, YAML)
|
51
|
+
# @return [Hash] the entries for the provided source, along with the associated values
|
52
|
+
def for type
|
53
|
+
deep_select(data.dup, type, [])
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
# @param path [String] the canonical name for a config entry (such as api.proxy.enable)
|
59
|
+
# @return [Array] the path split on periods, and converted to symbols
|
60
|
+
def parts_for path
|
61
|
+
path.split('.').map(&:to_sym)
|
62
|
+
end
|
63
|
+
|
64
|
+
# @param current_level [Hash] all, or some of, the config source information
|
65
|
+
# @param parts [Array] the parts for canonical name of the config entry
|
66
|
+
# @param source [String] the source to be set for the specified entry
|
67
|
+
# @return [Array] the path split on periods, and converted to symbols
|
68
|
+
def assign_value current_level, parts, source
|
69
|
+
parts[0...-1].each do |segment|
|
70
|
+
current_level[segment] ||= {}
|
71
|
+
current_level = current_level[segment]
|
72
|
+
end
|
73
|
+
return unless current_level.cs__is_a?(Hash)
|
74
|
+
|
75
|
+
current_level[parts[-1]] = source
|
76
|
+
end
|
77
|
+
|
78
|
+
# @param sources [Hash] all, or some of, the config source information
|
79
|
+
# @param type [Array] the source type to look for entries of
|
80
|
+
# @param path [String] the entries followed to get to this part of the config
|
81
|
+
# @return [Hash] the entries for the provided source, along with the associated values
|
82
|
+
def deep_select sources, type, path
|
83
|
+
sources.each_with_object({}) do |(k, v), grouping|
|
84
|
+
if v.cs__is_a?(Hash)
|
85
|
+
nested_data = deep_select(v, type, path.dup.append(k.to_sym))
|
86
|
+
grouping[k] = nested_data unless nested_data.empty?
|
87
|
+
elsif v == type
|
88
|
+
grouping[k] = Contrast::CONFIG.config.loaded_config.dig(*path, k)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -4,6 +4,7 @@
|
|
4
4
|
require 'contrast/utils/env_configuration_item'
|
5
5
|
require 'ougai'
|
6
6
|
require 'contrast/configuration'
|
7
|
+
require 'contrast/config/diagnostics'
|
7
8
|
|
8
9
|
module Contrast
|
9
10
|
module Components
|
@@ -26,6 +27,7 @@ module Contrast
|
|
26
27
|
CONTRAST_ENV_MARKER = 'CONTRAST__'
|
27
28
|
CONTRAST_LOG = 'contrast_agent.log'
|
28
29
|
CONTRAST_NAME = 'Contrast Agent'
|
30
|
+
DATE_TIME = '%Y-%m-%dT%H:%M:%S.%L%z'
|
29
31
|
|
30
32
|
class Interface # :nodoc: # rubocop:disable Metrics/ClassLength
|
31
33
|
SESSION_VARIABLES = 'Invalid configuration. '\
|
@@ -50,7 +52,7 @@ module Contrast
|
|
50
52
|
@_proto_logger.progname = CONTRAST_NAME
|
51
53
|
@_proto_logger.level = ::Ougai::Logging::Severity::WARN
|
52
54
|
@_proto_logger.formatter = Contrast::Logger::Format.new
|
53
|
-
@_proto_logger.formatter.datetime_format =
|
55
|
+
@_proto_logger.formatter.datetime_format = DATE_TIME
|
54
56
|
@_proto_logger
|
55
57
|
end
|
56
58
|
end
|
@@ -100,11 +102,6 @@ module Contrast
|
|
100
102
|
@config.protect
|
101
103
|
end
|
102
104
|
|
103
|
-
# @return [Contrast::Components::Service::Interface]
|
104
|
-
def service
|
105
|
-
@config.service
|
106
|
-
end
|
107
|
-
|
108
105
|
def valid?
|
109
106
|
@_valid = validate if @_valid.nil?
|
110
107
|
@_valid
|
@@ -114,6 +111,10 @@ module Contrast
|
|
114
111
|
@config.enable
|
115
112
|
end
|
116
113
|
|
114
|
+
def sources
|
115
|
+
@config.sources
|
116
|
+
end
|
117
|
+
|
117
118
|
def invalid?
|
118
119
|
!valid?
|
119
120
|
end
|
@@ -135,6 +136,11 @@ module Contrast
|
|
135
136
|
application.session_metadata
|
136
137
|
end
|
137
138
|
|
139
|
+
# @return [String, nil] the path to the YAML config file, if any.
|
140
|
+
def config_file_path
|
141
|
+
config.config_file
|
142
|
+
end
|
143
|
+
|
138
144
|
private
|
139
145
|
|
140
146
|
# The config has information about how to construct the logger. If the config is invalid, and you want to know
|
@@ -157,13 +163,10 @@ module Contrast
|
|
157
163
|
true
|
158
164
|
end
|
159
165
|
|
160
|
-
#
|
161
|
-
# configuration values required for that connection.
|
166
|
+
# The agent must have the configuration values required for the connection to TeamServer.
|
162
167
|
#
|
163
168
|
# @return [boolean]
|
164
169
|
def valid_api?
|
165
|
-
return true unless bypass
|
166
|
-
|
167
170
|
msg = []
|
168
171
|
msg << API_URL unless api_url
|
169
172
|
msg << API_KEY unless api_key
|
@@ -220,15 +223,6 @@ module Contrast
|
|
220
223
|
api.user_name
|
221
224
|
end
|
222
225
|
|
223
|
-
# Typically, the following values would be accessed through Contrast::Components::AppContext
|
224
|
-
# and Contrast::Components::API, but we're too early in the initialization of the Agent to use
|
225
|
-
# that mechanism, so we look it up directly for ourselves.
|
226
|
-
#
|
227
|
-
# @return [String, nil]
|
228
|
-
def bypass
|
229
|
-
agent.service.bypass
|
230
|
-
end
|
231
|
-
|
232
226
|
# Typically, the following values would be accessed through Contrast::Components::AppContext
|
233
227
|
# and Contrast::Components::Logger, but we're too early in the initialization of the Agent to use
|
234
228
|
# that mechanism, so we look it up directly for ourselves.
|
@@ -238,6 +232,11 @@ module Contrast
|
|
238
232
|
agent.logger.path
|
239
233
|
end
|
240
234
|
|
235
|
+
# This methods is here to add the proper forward towards @config
|
236
|
+
def enable= value
|
237
|
+
@config.enable = value
|
238
|
+
end
|
239
|
+
|
241
240
|
# Assign the value from an ENV variable to the Contrast::Config::RootConfiguration object, when
|
242
241
|
# appropriate.
|
243
242
|
#
|
@@ -250,6 +249,7 @@ module Contrast
|
|
250
249
|
return unless current_level.nil? == false && current_level.cs__respond_to?(dot_path_array[-1])
|
251
250
|
|
252
251
|
current_level.send("#{ dot_path_array[-1] }=", value)
|
252
|
+
sources.set(dot_path_array.join('.'), Contrast::Components::Config::Sources::ENVIRONMENT)
|
253
253
|
end
|
254
254
|
end
|
255
255
|
end
|
@@ -10,12 +10,22 @@ module Contrast
|
|
10
10
|
# Interface used to build the HeapDump settings and component.
|
11
11
|
class Interface
|
12
12
|
include Contrast::Config::BaseConfiguration
|
13
|
+
include Contrast::Components::ComponentBase
|
14
|
+
|
15
|
+
# @return [String]
|
16
|
+
attr_reader :canon_name
|
17
|
+
# @return [Array]
|
18
|
+
attr_reader :config_values
|
13
19
|
|
14
20
|
DEFAULT_PATH = 'contrast_heap_dumps' # saved
|
15
21
|
DEFAULT_MS = 10_000
|
16
22
|
DEFAULT_COUNT = 5
|
23
|
+
CANON_NAME = 'agent.heap_dump'
|
24
|
+
CONFIG_VALUES = %w[enable path delay_ms window_ms count clean].cs__freeze
|
17
25
|
|
18
26
|
def initialize hsh = {}
|
27
|
+
@config_values = CONFIG_VALUES
|
28
|
+
@canon_name = CANON_NAME
|
19
29
|
return unless hsh
|
20
30
|
|
21
31
|
@_enable = hsh[:enable]
|
@@ -11,10 +11,18 @@ module Contrast
|
|
11
11
|
class Interface
|
12
12
|
include Contrast::Components::ComponentBase
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
CANON_NAME = 'inventory'
|
15
|
+
CONFIG_VALUES = %w[enable analyze_libraries tags].cs__freeze
|
16
|
+
|
17
|
+
attr_writer :tags
|
18
|
+
# @return [String]
|
19
|
+
attr_reader :canon_name
|
20
|
+
# @return [Array]
|
21
|
+
attr_reader :config_values
|
16
22
|
|
17
23
|
def initialize hsh = {}
|
24
|
+
@config_values = CONFIG_VALUES
|
25
|
+
@canon_name = CANON_NAME
|
18
26
|
return unless hsh
|
19
27
|
|
20
28
|
@enable = !false?(hsh[:enable])
|
@@ -31,6 +39,11 @@ module Contrast
|
|
31
39
|
def analyze_libraries
|
32
40
|
@analyze_libraries.nil? ? true : @analyze_libraries
|
33
41
|
end
|
42
|
+
|
43
|
+
# @return [String, nil] tags
|
44
|
+
def tags
|
45
|
+
stringify_array(@tags)
|
46
|
+
end
|
34
47
|
end
|
35
48
|
end
|
36
49
|
end
|