contrast-agent 5.3.0 → 6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/cs__assess_array/cs__assess_array.c +7 -0
- data/ext/cs__assess_basic_object/cs__assess_basic_object.c +19 -5
- data/ext/cs__assess_fiber_track/cs__assess_fiber_track.c +1 -1
- data/ext/cs__assess_hash/cs__assess_hash.c +3 -4
- data/ext/cs__assess_kernel/cs__assess_kernel.c +1 -2
- data/ext/cs__assess_marshal_module/cs__assess_marshal_module.c +26 -12
- data/ext/cs__assess_module/cs__assess_module.c +1 -1
- data/ext/cs__assess_string/cs__assess_string.c +13 -1
- data/ext/cs__common/cs__common.c +12 -11
- data/ext/cs__contrast_patch/cs__contrast_patch.c +54 -43
- data/ext/cs__os_information/cs__os_information.c +13 -10
- data/ext/cs__scope/cs__scope.c +146 -97
- data/lib/contrast/agent/assess/finalizers/hash.rb +2 -0
- data/lib/contrast/agent/assess/policy/policy_node.rb +50 -27
- data/lib/contrast/agent/assess/policy/policy_node_utils.rb +51 -0
- data/lib/contrast/agent/assess/policy/preshift.rb +8 -2
- data/lib/contrast/agent/assess/policy/propagation_method.rb +47 -13
- data/lib/contrast/agent/assess/policy/propagator/buffer.rb +118 -0
- data/lib/contrast/agent/assess/policy/propagator/keep.rb +19 -4
- data/lib/contrast/agent/assess/policy/propagator/remove.rb +18 -2
- data/lib/contrast/agent/assess/policy/propagator/splat.rb +17 -3
- data/lib/contrast/agent/assess/policy/propagator/substitution.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/substitution_utils.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/trim.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator.rb +1 -0
- data/lib/contrast/agent/assess/policy/source_method.rb +7 -7
- data/lib/contrast/agent/assess/policy/trigger_method.rb +3 -1
- data/lib/contrast/agent/assess/property/tagged.rb +1 -1
- data/lib/contrast/agent/assess/rule/response/auto_complete_rule.rb +1 -1
- data/lib/contrast/agent/assess/rule/response/body_rule.rb +3 -3
- data/lib/contrast/agent/assess/rule/response/cache_control_header_rule.rb +1 -1
- data/lib/contrast/agent/assess/rule/response/parameters_pollution_rule.rb +1 -1
- data/lib/contrast/agent/deadzone/policy/deadzone_node.rb +0 -7
- data/lib/contrast/agent/deadzone/policy/policy.rb +0 -6
- data/lib/contrast/agent/exclusion_matcher.rb +3 -3
- data/lib/contrast/agent/middleware.rb +3 -1
- data/lib/contrast/agent/patching/policy/patcher.rb +3 -3
- data/lib/contrast/agent/patching/policy/policy_node.rb +15 -2
- data/lib/contrast/agent/protect/exploitable_collection.rb +38 -0
- data/lib/contrast/agent/protect/input_analyzer/input_analyzer.rb +61 -8
- data/lib/contrast/agent/protect/policy/applies_no_sqli_rule.rb +2 -1
- data/lib/contrast/agent/protect/policy/applies_path_traversal_rule.rb +2 -2
- data/lib/contrast/agent/protect/rule/base.rb +37 -5
- data/lib/contrast/agent/protect/rule/base_service.rb +3 -1
- data/lib/contrast/agent/protect/rule/cmd_injection.rb +13 -0
- data/lib/contrast/agent/protect/rule/cmdi/cmdi_input_classification.rb +83 -0
- data/lib/contrast/agent/protect/rule/cmdi/cmdi_worth_watching.rb +64 -0
- data/lib/contrast/agent/protect/rule/http_method_tampering/http_method_tampering_input_classification.rb +96 -0
- data/lib/contrast/agent/protect/rule/http_method_tampering.rb +8 -0
- data/lib/contrast/agent/protect/rule/no_sqli/no_sqli_input_classification.rb +231 -0
- data/lib/contrast/agent/protect/rule/no_sqli.rb +27 -0
- data/lib/contrast/agent/protect/rule/sqli/sqli_input_classification.rb +18 -54
- data/lib/contrast/agent/protect/rule/sqli/sqli_worth_watching.rb +1 -4
- data/lib/contrast/agent/protect/rule/unsafe_file_upload/unsafe_file_upload_input_classification.rb +82 -0
- data/lib/contrast/agent/protect/rule/unsafe_file_upload/unsafe_file_upload_matcher.rb +45 -0
- data/lib/contrast/agent/protect/rule/unsafe_file_upload.rb +42 -0
- data/lib/contrast/agent/reporting/attack_result/attack_result.rb +63 -0
- data/lib/contrast/agent/reporting/attack_result/rasp_rule_sample.rb +52 -0
- data/lib/contrast/agent/reporting/attack_result/response_type.rb +29 -0
- data/lib/contrast/agent/reporting/attack_result/user_input.rb +87 -0
- data/lib/contrast/agent/reporting/masker/masker.rb +246 -0
- data/lib/contrast/agent/reporting/masker/masker_utils.rb +58 -0
- data/lib/contrast/agent/reporting/report.rb +2 -0
- data/lib/contrast/agent/reporting/reporter.rb +23 -11
- data/lib/contrast/agent/reporting/reporting_events/agent_startup.rb +30 -0
- data/lib/contrast/agent/reporting/reporting_events/application_inventory.rb +7 -3
- data/lib/contrast/agent/reporting/reporting_events/application_startup.rb +40 -0
- data/lib/contrast/agent/reporting/reporting_events/application_startup_instrumentation.rb +27 -0
- data/lib/contrast/agent/reporting/reporting_events/finding.rb +1 -1
- data/lib/contrast/agent/reporting/reporting_events/library_usage_observation.rb +5 -5
- data/lib/contrast/agent/reporting/reporting_events/observed_route.rb +9 -9
- data/lib/contrast/agent/reporting/reporting_events/preflight_message.rb +2 -1
- data/lib/contrast/agent/reporting/reporting_events/reporting_event.rb +2 -1
- data/lib/contrast/agent/reporting/reporting_events/route_coverage.rb +8 -6
- data/lib/contrast/agent/reporting/reporting_utilities/reporter_client.rb +16 -5
- data/lib/contrast/agent/reporting/reporting_utilities/reporter_client_utils.rb +27 -26
- data/lib/contrast/agent/reporting/reporting_utilities/reporting_storage.rb +1 -1
- data/lib/contrast/agent/reporting/reporting_utilities/response_extractor.rb +97 -0
- data/lib/contrast/agent/reporting/reporting_utilities/response_handler.rb +68 -6
- data/lib/contrast/agent/reporting/reporting_utilities/response_handler_mode.rb +63 -0
- data/lib/contrast/agent/reporting/reporting_utilities/response_handler_utils.rb +122 -96
- data/lib/contrast/agent/reporting/settings/application_settings.rb +9 -0
- data/lib/contrast/agent/reporting/settings/assess_server_feature.rb +5 -33
- data/lib/contrast/agent/reporting/settings/protect_server_feature.rb +1 -1
- data/lib/contrast/agent/reporting/settings/sampling.rb +36 -0
- data/lib/contrast/agent/reporting/settings/sensitive_data_masking.rb +110 -0
- data/lib/contrast/agent/reporting/settings/sensitive_data_masking_rule.rb +58 -0
- data/lib/contrast/agent/request_context.rb +1 -1
- data/lib/contrast/agent/request_context_extend.rb +1 -1
- data/lib/contrast/agent/request_handler.rb +4 -0
- data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exception_base.rb +51 -0
- data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exception_event.rb +36 -0
- data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exception_message.rb +97 -0
- data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exception_message_exception.rb +65 -0
- data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exception_stack_frame.rb +47 -0
- data/lib/contrast/agent/{metric_telemetry_event.rb → telemetry/events/metric_telemetry_event.rb} +1 -1
- data/lib/contrast/agent/{startup_metrics_telemetry_event.rb → telemetry/events/startup_metrics_telemetry_event.rb} +3 -3
- data/lib/contrast/agent/{telemetry_event.rb → telemetry/events/telemetry_event.rb} +1 -1
- data/lib/contrast/agent/{telemetry.rb → telemetry/telemetry.rb} +32 -19
- data/lib/contrast/agent/thread_watcher.rb +1 -1
- data/lib/contrast/agent/version.rb +1 -1
- data/lib/contrast/agent.rb +3 -0
- data/lib/contrast/api/communication/speedracer.rb +1 -1
- data/lib/contrast/api/decorators/address.rb +1 -1
- data/lib/contrast/api/decorators/response_type.rb +30 -0
- data/lib/contrast/api/decorators.rb +1 -0
- data/lib/contrast/components/app_context.rb +0 -4
- data/lib/contrast/components/assess.rb +14 -0
- data/lib/contrast/components/protect.rb +2 -2
- data/lib/contrast/components/sampling.rb +7 -11
- data/lib/contrast/components/settings.rb +106 -8
- data/lib/contrast/config/agent_configuration.rb +13 -30
- data/lib/contrast/config/api_configuration.rb +4 -67
- data/lib/contrast/config/api_proxy_configuration.rb +2 -45
- data/lib/contrast/config/application_configuration.rb +9 -84
- data/lib/contrast/config/assess_configuration.rb +10 -69
- data/lib/contrast/config/assess_rules_configuration.rb +9 -38
- data/lib/contrast/config/base_configuration.rb +17 -50
- data/lib/contrast/config/certification_configuration.rb +6 -63
- data/lib/contrast/config/exception_configuration.rb +5 -52
- data/lib/contrast/config/heap_dump_configuration.rb +6 -64
- data/lib/contrast/config/inventory_configuration.rb +2 -49
- data/lib/contrast/config/logger_configuration.rb +0 -36
- data/lib/contrast/config/protect_configuration.rb +17 -7
- data/lib/contrast/config/protect_rule_configuration.rb +12 -30
- data/lib/contrast/config/protect_rules_configuration.rb +21 -26
- data/lib/contrast/config/request_audit_configuration.rb +6 -48
- data/lib/contrast/config/root_configuration.rb +52 -12
- data/lib/contrast/config/ruby_configuration.rb +0 -36
- data/lib/contrast/config/sampling_configuration.rb +1 -57
- data/lib/contrast/config/server_configuration.rb +0 -36
- data/lib/contrast/config/service_configuration.rb +5 -44
- data/lib/contrast/configuration.rb +2 -3
- data/lib/contrast/extension/assess/string.rb +20 -1
- data/lib/contrast/extension/module.rb +0 -1
- data/lib/contrast/framework/manager.rb +2 -2
- data/lib/contrast/logger/application.rb +1 -1
- data/lib/contrast/logger/cef_log.rb +1 -1
- data/lib/contrast/tasks/config.rb +90 -3
- data/lib/contrast/utils/assess/object_store.rb +36 -0
- data/lib/contrast/utils/assess/propagation_method_utils.rb +6 -0
- data/lib/contrast/utils/class_util.rb +3 -12
- data/lib/contrast/utils/input_classification.rb +73 -0
- data/lib/contrast/utils/log_utils.rb +1 -1
- data/lib/contrast/utils/middleware_utils.rb +9 -8
- data/lib/contrast/utils/net_http_base.rb +1 -1
- data/lib/contrast/utils/object_share.rb +2 -1
- data/lib/contrast/utils/os.rb +0 -5
- data/lib/contrast/utils/patching/policy/patch_utils.rb +4 -5
- data/lib/contrast/utils/response_utils.rb +18 -33
- data/lib/contrast/utils/telemetry.rb +1 -1
- data/lib/contrast/utils/telemetry_client.rb +1 -1
- data/lib/contrast/utils/telemetry_identifier.rb +1 -1
- data/resources/assess/policy.json +98 -0
- data/resources/deadzone/policy.json +0 -86
- data/ruby-agent.gemspec +9 -8
- data/service_executables/VERSION +1 -1
- data/service_executables/linux/contrast-service +0 -0
- data/service_executables/mac/contrast-service +0 -0
- metadata +73 -28
@@ -12,21 +12,24 @@ module Contrast
|
|
12
12
|
class BaseConfiguration
|
13
13
|
extend Forwardable
|
14
14
|
|
15
|
-
attr_reader :configuration_map
|
16
|
-
|
17
|
-
alias_method :to_hash, :configuration_map
|
18
|
-
def_delegators :@configuration_map, :empty?, :key?, :delete, :fetch,
|
19
|
-
:[], :[]=, :each, :each_pair, :each_key, :each_value
|
20
|
-
|
21
15
|
EMPTY_VALUE = :EMPTY_VALUE
|
22
16
|
|
23
17
|
def initialize hsh = {}, keys = {}
|
24
18
|
# holds configuration key value pairs
|
25
19
|
# each configuration class can contain nested BaseConfigurations
|
26
|
-
@configuration_map = {}
|
27
20
|
traverse_config(hsh, keys)
|
28
21
|
end
|
29
22
|
|
23
|
+
def to_hash
|
24
|
+
hsh = {}
|
25
|
+
instance_variables.each do |iv|
|
26
|
+
# strip the '@' to get the key
|
27
|
+
key = iv.to_s[1..]
|
28
|
+
hsh[key] = send(key.to_sym)
|
29
|
+
end
|
30
|
+
hsh
|
31
|
+
end
|
32
|
+
|
30
33
|
def assign_value_to_path_array dot_path_array, value
|
31
34
|
current_level = self
|
32
35
|
dot_path_array[0...-1].each do |segment|
|
@@ -40,10 +43,6 @@ module Contrast
|
|
40
43
|
nil
|
41
44
|
end
|
42
45
|
|
43
|
-
def nil?
|
44
|
-
@configuration_map.empty?
|
45
|
-
end
|
46
|
-
|
47
46
|
private
|
48
47
|
|
49
48
|
# Traverse the given entity to build out the configuration graph.
|
@@ -52,51 +51,19 @@ module Contrast
|
|
52
51
|
# traverse, or a value to set or the EMPTY_VALUE symbol, indicating a
|
53
52
|
# leaf node.
|
54
53
|
#
|
55
|
-
# The
|
56
|
-
# configuration.
|
57
|
-
|
58
|
-
def traverse_config values, spec_keys
|
54
|
+
# The spec_key are the Contrast defined keys based on the instance variables of
|
55
|
+
# a given configuration.
|
56
|
+
def traverse_config values, spec_key
|
59
57
|
internal_nodes = values.cs__respond_to?(:has_key?)
|
60
|
-
|
61
|
-
|
62
|
-
define_methods(spec_key, spec_value, user_provided_value)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def define_methods spec_key, spec_value, user_provided_value
|
67
|
-
str_key = spec_key.to_s
|
68
|
-
assign_config_value(str_key, spec_value, user_provided_value)
|
69
|
-
define_getter(str_key)
|
70
|
-
define_setter(str_key)
|
71
|
-
end
|
72
|
-
|
73
|
-
def assign_config_value str_key, spec_value, user_provided_value
|
74
|
-
@configuration_map[str_key] = if spec_value.is_a?(Class) && spec_value <= Contrast::Config::BaseConfiguration
|
75
|
-
spec_value.new(user_provided_value)
|
76
|
-
elsif user_provided_value == EMPTY_VALUE
|
77
|
-
spec_value
|
78
|
-
else
|
79
|
-
user_provided_value
|
80
|
-
end
|
58
|
+
val = internal_nodes ? value_from_key_config(spec_key, values) : nil
|
59
|
+
val == EMPTY_VALUE ? nil : val
|
81
60
|
end
|
82
61
|
|
83
62
|
def value_from_key_config key, config_hash
|
84
63
|
return config_hash[key] if config_hash.key?(key)
|
85
|
-
return config_hash.fetch(key.to_sym,
|
86
|
-
|
87
|
-
config_hash.fetch(key.to_s, EMPTY_VALUE)
|
88
|
-
end
|
64
|
+
return config_hash.fetch(key.to_sym, nil) if key.is_a?(String)
|
89
65
|
|
90
|
-
|
91
|
-
define_singleton_method str_key.to_sym do
|
92
|
-
@configuration_map[str_key] == EMPTY_VALUE ? nil : @configuration_map[str_key]
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
def define_setter str_key
|
97
|
-
define_singleton_method "#{ str_key }=".to_sym do |new_value|
|
98
|
-
@configuration_map[str_key] = new_value
|
99
|
-
end
|
66
|
+
config_hash.fetch(key.to_s, nil)
|
100
67
|
end
|
101
68
|
end
|
102
69
|
end
|
@@ -6,80 +6,23 @@ module Contrast
|
|
6
6
|
# Certificate Configuration
|
7
7
|
class CertificationConfiguration < BaseConfiguration
|
8
8
|
# @return [String] path to CA Cert file
|
9
|
-
|
9
|
+
attr_accessor :ca_file
|
10
10
|
# @return [String] path to Certification file
|
11
|
-
|
11
|
+
attr_accessor :cert_file
|
12
12
|
# @return [String] path to Certification Key file
|
13
|
-
|
13
|
+
attr_accessor :key_file
|
14
|
+
attr_writer :enable
|
14
15
|
|
15
16
|
def initialize hsh = {}
|
16
17
|
@enable = traverse_config(hsh, :enable)
|
17
18
|
@ca_file = traverse_config(hsh, :ca_file)
|
18
19
|
@cert_file = traverse_config(hsh, :cert_file)
|
19
20
|
@key_file = traverse_config(hsh, :key_file)
|
20
|
-
@configuration_map = {}
|
21
|
-
build_configuration_map
|
22
21
|
end
|
23
22
|
|
24
|
-
#
|
25
|
-
|
26
|
-
# @return [Boolean]
|
23
|
+
# @return [Boolean, false]
|
27
24
|
def enable
|
28
|
-
|
29
|
-
|
30
|
-
@enable
|
31
|
-
end
|
32
|
-
|
33
|
-
# SETTERS
|
34
|
-
|
35
|
-
def enable= value
|
36
|
-
self['enable'] = value
|
37
|
-
end
|
38
|
-
|
39
|
-
def ca_file= value
|
40
|
-
self['ca_file'] = value
|
41
|
-
end
|
42
|
-
|
43
|
-
def cert_file= value
|
44
|
-
self['cert_file'] = value
|
45
|
-
end
|
46
|
-
|
47
|
-
def key_file= value
|
48
|
-
self['key_file'] = value
|
49
|
-
end
|
50
|
-
|
51
|
-
# TODO: RUBY-1493 MOVE TO BASE CONFIG
|
52
|
-
|
53
|
-
def []= key, value
|
54
|
-
instance_variable_set("@#{ key }".to_sym, value)
|
55
|
-
@configuration_map[key] = value
|
56
|
-
end
|
57
|
-
|
58
|
-
def [] key
|
59
|
-
send(key.to_sym)
|
60
|
-
end
|
61
|
-
|
62
|
-
# Traverse the given entity to build out the configuration graph.
|
63
|
-
#
|
64
|
-
# The values will be either a hash, indicating internal nodes to
|
65
|
-
# traverse, or a value to set or the EMPTY_VALUE symbol, indicating a
|
66
|
-
# leaf node.
|
67
|
-
#
|
68
|
-
# The spec_key are the Contrast defined keys based on the instance variables of
|
69
|
-
# a given configuration.
|
70
|
-
def traverse_config values, spec_key
|
71
|
-
internal_nodes = values.cs__respond_to?(:has_key?)
|
72
|
-
val = internal_nodes ? value_from_key_config(spec_key, values) : nil
|
73
|
-
val == EMPTY_VALUE ? nil : val
|
74
|
-
end
|
75
|
-
|
76
|
-
def build_configuration_map
|
77
|
-
instance_variables.each do |key|
|
78
|
-
str_key = key.to_s.tr('@', '')
|
79
|
-
next if str_key == 'configuration_map'
|
80
|
-
|
81
|
-
@configuration_map[str_key] = send(str_key.to_sym)
|
82
|
-
end
|
25
|
+
@enable.nil? ? false : @enable
|
83
26
|
end
|
84
27
|
end
|
85
28
|
end
|
@@ -8,67 +8,20 @@ module Contrast
|
|
8
8
|
# and Message when Security Exceptions are raised.
|
9
9
|
class ExceptionConfiguration < BaseConfiguration
|
10
10
|
# @return [Integer] the HTTP status code override
|
11
|
-
|
11
|
+
attr_accessor :override_status
|
12
12
|
# @return [String] the message text override
|
13
|
-
|
13
|
+
attr_accessor :override_message
|
14
|
+
attr_writer :capture
|
14
15
|
|
15
16
|
def initialize hsh = {}
|
16
17
|
@capture = traverse_config(hsh, :capture)
|
17
18
|
@override_status = traverse_config(hsh, :override_status)
|
18
19
|
@override_message = traverse_config(hsh, :override_message)
|
19
|
-
@configuration_map = {}
|
20
|
-
build_configuration_map
|
21
20
|
end
|
22
21
|
|
23
|
-
# @return [Boolean
|
22
|
+
# @return [Boolean, false]
|
24
23
|
def capture
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
def capture= value
|
29
|
-
self['capture'] = value
|
30
|
-
end
|
31
|
-
|
32
|
-
def override_status= value
|
33
|
-
self['override_status'] = value
|
34
|
-
end
|
35
|
-
|
36
|
-
def override_message= value
|
37
|
-
self['override_message'] = value
|
38
|
-
end
|
39
|
-
|
40
|
-
# TODO: RUBY-1493 MOVE TO BASE CONFIG
|
41
|
-
|
42
|
-
def []= key, value
|
43
|
-
instance_variable_set("@#{ key }".to_sym, value)
|
44
|
-
@configuration_map[key] = value
|
45
|
-
end
|
46
|
-
|
47
|
-
def [] key
|
48
|
-
send(key.to_sym)
|
49
|
-
end
|
50
|
-
|
51
|
-
# Traverse the given entity to build out the configuration graph.
|
52
|
-
#
|
53
|
-
# The values will be either a hash, indicating internal nodes to
|
54
|
-
# traverse, or a value to set or the EMPTY_VALUE symbol, indicating a
|
55
|
-
# leaf node.
|
56
|
-
#
|
57
|
-
# The spec_key are the Contrast defined keys based on the instance variables of
|
58
|
-
# a given configuration.
|
59
|
-
def traverse_config values, spec_key
|
60
|
-
internal_nodes = values.cs__respond_to?(:has_key?)
|
61
|
-
val = internal_nodes ? value_from_key_config(spec_key, values) : nil
|
62
|
-
val == EMPTY_VALUE ? nil : val
|
63
|
-
end
|
64
|
-
|
65
|
-
def build_configuration_map
|
66
|
-
instance_variables.each do |key|
|
67
|
-
str_key = key.to_s.tr('@', '')
|
68
|
-
next if str_key == 'configuration_map'
|
69
|
-
|
70
|
-
@configuration_map[str_key] = send(str_key.to_sym)
|
71
|
-
end
|
24
|
+
!!@capture
|
72
25
|
end
|
73
26
|
end
|
74
27
|
end
|
@@ -10,6 +10,8 @@ module Contrast
|
|
10
10
|
DEFAULT_MS = 10_000
|
11
11
|
DEFAULT_COUNT = 5
|
12
12
|
|
13
|
+
attr_writer :enable, :path, :delay_ms, :window_ms, :count, :clean
|
14
|
+
|
13
15
|
def initialize hsh = {}
|
14
16
|
@enable = traverse_config(hsh, :enable)
|
15
17
|
@path = traverse_config(hsh, :path)
|
@@ -17,13 +19,11 @@ module Contrast
|
|
17
19
|
@window_ms = traverse_config(hsh, :window_ms)
|
18
20
|
@count = traverse_config(hsh, :count)
|
19
21
|
@clean = traverse_config(hsh, :clean)
|
20
|
-
@configuration_map = {}
|
21
|
-
build_configuration_map
|
22
22
|
end
|
23
23
|
|
24
|
-
# @return [Boolean,
|
24
|
+
# @return [Boolean, Contrast::Utils::ObjectShare::FALSE] should dumps be taken
|
25
25
|
def enable
|
26
|
-
|
26
|
+
@enable.nil? ? Contrast::Utils::ObjectShare::FALSE : @enable
|
27
27
|
end
|
28
28
|
|
29
29
|
# @return [String, DEFAULT_PATH] dir to which dumps should be
|
@@ -46,67 +46,9 @@ module Contrast
|
|
46
46
|
@count ||= DEFAULT_COUNT
|
47
47
|
end
|
48
48
|
|
49
|
-
# @return [Boolean,
|
49
|
+
# @return [Boolean, Contrast::Utils::ObjectShare::FALSE] remove temporary objects or not
|
50
50
|
def clean
|
51
|
-
|
52
|
-
end
|
53
|
-
|
54
|
-
def enable= value
|
55
|
-
self['enable'] = value
|
56
|
-
end
|
57
|
-
|
58
|
-
def path= value
|
59
|
-
self['path'] = value
|
60
|
-
end
|
61
|
-
|
62
|
-
def delay_ms= value
|
63
|
-
self['delay_ms'] = value
|
64
|
-
end
|
65
|
-
|
66
|
-
def window_ms= value
|
67
|
-
self['window_ms'] = value
|
68
|
-
end
|
69
|
-
|
70
|
-
def count= value
|
71
|
-
self['count'] = value
|
72
|
-
end
|
73
|
-
|
74
|
-
def clean= value
|
75
|
-
self['clean'] = value
|
76
|
-
end
|
77
|
-
|
78
|
-
# TODO: RUBY-1493 MOVE TO BASE CONFIG
|
79
|
-
|
80
|
-
def []= key, value
|
81
|
-
instance_variable_set("@#{ key }".to_sym, value)
|
82
|
-
@configuration_map[key] = value
|
83
|
-
end
|
84
|
-
|
85
|
-
def [] key
|
86
|
-
send(key.to_sym)
|
87
|
-
end
|
88
|
-
|
89
|
-
# Traverse the given entity to build out the configuration graph.
|
90
|
-
#
|
91
|
-
# The values will be either a hash, indicating internal nodes to
|
92
|
-
# traverse, or a value to set or the EMPTY_VALUE symbol, indicating a
|
93
|
-
# leaf node.
|
94
|
-
#
|
95
|
-
# The spec_key are the Contrast defined keys based on the instance variables of
|
96
|
-
# a given configuration.
|
97
|
-
def traverse_config values, spec_key
|
98
|
-
internal_nodes = values.cs__respond_to?(:has_key?)
|
99
|
-
val = internal_nodes ? value_from_key_config(spec_key, values) : nil
|
100
|
-
val == EMPTY_VALUE ? nil : val
|
101
|
-
end
|
102
|
-
|
103
|
-
def build_configuration_map
|
104
|
-
instance_variables.each do |key|
|
105
|
-
str_key = key.to_s.tr('@', '')
|
106
|
-
next if str_key == 'configuration_map'
|
107
|
-
|
108
|
-
@configuration_map[str_key] = send(str_key.to_sym)
|
109
|
-
end
|
51
|
+
@clean.nil? ? Contrast::Utils::ObjectShare::FALSE : @clean
|
110
52
|
end
|
111
53
|
end
|
112
54
|
end
|
@@ -7,14 +7,13 @@ module Contrast
|
|
7
7
|
# inventory functionality of the Agent.
|
8
8
|
class InventoryConfiguration < BaseConfiguration
|
9
9
|
# @return [Array, nil] tags
|
10
|
-
|
10
|
+
attr_accessor :tags
|
11
|
+
attr_writer :enable, :analyze_libraries
|
11
12
|
|
12
13
|
def initialize hsh = {}
|
13
14
|
@enable = traverse_config(hsh, :enable)
|
14
15
|
@analyze_libraries = traverse_config(hsh, :analyze_libraries)
|
15
16
|
@tags = traverse_config(hsh, :tags)
|
16
|
-
@configuration_map = {}
|
17
|
-
build_configuration_map
|
18
17
|
end
|
19
18
|
|
20
19
|
# @return [Boolean, true]
|
@@ -26,52 +25,6 @@ module Contrast
|
|
26
25
|
def analyze_libraries
|
27
26
|
@analyze_libraries.nil? ? true : @analyze_libraries
|
28
27
|
end
|
29
|
-
|
30
|
-
def enable= value
|
31
|
-
self['enable'] = value
|
32
|
-
end
|
33
|
-
|
34
|
-
def analyze_libraries= value
|
35
|
-
self['analyze_libraries'] = value
|
36
|
-
end
|
37
|
-
|
38
|
-
def tags= value
|
39
|
-
self['tags'] = value
|
40
|
-
end
|
41
|
-
|
42
|
-
# TODO: RUBY-1493 MOVE TO BASE CONFIG
|
43
|
-
|
44
|
-
def []= key, value
|
45
|
-
instance_variable_set("@#{ key }".to_sym, value)
|
46
|
-
@configuration_map[key] = value
|
47
|
-
end
|
48
|
-
|
49
|
-
def [] key
|
50
|
-
send(key.to_sym)
|
51
|
-
end
|
52
|
-
|
53
|
-
# Traverse the given entity to build out the configuration graph.
|
54
|
-
#
|
55
|
-
# The values will be either a hash, indicating internal nodes to
|
56
|
-
# traverse, or a value to set or the EMPTY_VALUE symbol, indicating a
|
57
|
-
# leaf node.
|
58
|
-
#
|
59
|
-
# The spec_key are the Contrast defined keys based on the instance variables of
|
60
|
-
# a given configuration.
|
61
|
-
def traverse_config values, spec_key
|
62
|
-
internal_nodes = values.cs__respond_to?(:has_key?)
|
63
|
-
val = internal_nodes ? value_from_key_config(spec_key, values) : nil
|
64
|
-
val == EMPTY_VALUE ? nil : val
|
65
|
-
end
|
66
|
-
|
67
|
-
def build_configuration_map
|
68
|
-
instance_variables.each do |key|
|
69
|
-
str_key = key.to_s.tr('@', '')
|
70
|
-
next if str_key == 'configuration_map'
|
71
|
-
|
72
|
-
@configuration_map[str_key] = send(str_key.to_sym)
|
73
|
-
end
|
74
|
-
end
|
75
28
|
end
|
76
29
|
end
|
77
30
|
end
|
@@ -17,42 +17,6 @@ module Contrast
|
|
17
17
|
@path = traverse_config(hsh, :path)
|
18
18
|
@level = traverse_config(hsh, :level)
|
19
19
|
@progname = traverse_config(hsh, :progname)
|
20
|
-
@configuration_map = {}
|
21
|
-
build_configuration_map
|
22
|
-
end
|
23
|
-
|
24
|
-
# TODO: RUBY-1493 MOVE TO BASE CONFIG
|
25
|
-
|
26
|
-
def []= key, value
|
27
|
-
instance_variable_set("@#{ key }".to_sym, value)
|
28
|
-
@configuration_map[key] = value
|
29
|
-
end
|
30
|
-
|
31
|
-
def [] key
|
32
|
-
send(key.to_sym)
|
33
|
-
end
|
34
|
-
|
35
|
-
# Traverse the given entity to build out the configuration graph.
|
36
|
-
#
|
37
|
-
# The values will be either a hash, indicating internal nodes to
|
38
|
-
# traverse, or a value to set or the EMPTY_VALUE symbol, indicating a
|
39
|
-
# leaf node.
|
40
|
-
#
|
41
|
-
# The spec_key are the Contrast defined keys based on the instance variables of
|
42
|
-
# a given configuration.
|
43
|
-
def traverse_config values, spec_key
|
44
|
-
internal_nodes = values.cs__respond_to?(:has_key?)
|
45
|
-
val = internal_nodes ? value_from_key_config(spec_key, values) : nil
|
46
|
-
val == EMPTY_VALUE ? nil : val
|
47
|
-
end
|
48
|
-
|
49
|
-
def build_configuration_map
|
50
|
-
instance_variables.each do |key|
|
51
|
-
str_key = key.to_s.tr('@', '')
|
52
|
-
next if str_key == 'configuration_map'
|
53
|
-
|
54
|
-
@configuration_map[str_key] = send(str_key.to_sym)
|
55
|
-
end
|
56
20
|
end
|
57
21
|
end
|
58
22
|
end
|
@@ -6,14 +6,24 @@ module Contrast
|
|
6
6
|
# Common Configuration settings. Those in this section pertain to the
|
7
7
|
# protect functionality of the Agent.
|
8
8
|
class ProtectConfiguration < BaseConfiguration
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
enable: EMPTY_VALUE
|
13
|
-
}.cs__freeze
|
9
|
+
# @return [Boolean, nil]
|
10
|
+
attr_accessor :enable
|
11
|
+
attr_writer :exceptions, :rules
|
14
12
|
|
15
|
-
def initialize hsh
|
16
|
-
|
13
|
+
def initialize hsh = {}
|
14
|
+
@exceptions = Contrast::Config::ExceptionConfiguration.new(traverse_config(hsh, :exceptions))
|
15
|
+
@rules = Contrast::Config::ProtectRulesConfiguration.new(traverse_config(hsh, :rules))
|
16
|
+
@enable = traverse_config(hsh, :enable)
|
17
|
+
end
|
18
|
+
|
19
|
+
# @return [Contrast::Config::ExceptionConfiguration]
|
20
|
+
def exceptions
|
21
|
+
@exceptions ||= Contrast::Config::ExceptionConfiguration.new
|
22
|
+
end
|
23
|
+
|
24
|
+
# @return [Contrast::Config::ProtectRulesConfiguration]
|
25
|
+
def rules
|
26
|
+
@rules ||= Contrast::Config::ProtectRulesConfiguration.new
|
17
27
|
end
|
18
28
|
end
|
19
29
|
end
|
@@ -8,15 +8,24 @@ module Contrast
|
|
8
8
|
# Common Configuration settings. Those in this section pertain to the
|
9
9
|
# rule mode of a single protect rule in the Agent.
|
10
10
|
class ProtectRuleConfiguration < BaseConfiguration
|
11
|
-
|
11
|
+
# @return [Boolean, nil]
|
12
|
+
attr_accessor :enable
|
13
|
+
# @return [String, nil]
|
14
|
+
attr_accessor :mode
|
15
|
+
# @retrun [Boolean, nil]
|
16
|
+
attr_accessor :disable_system_commands
|
17
|
+
attr_writer :detect_custom_code_accessing_system_files
|
12
18
|
|
13
19
|
def initialize hsh = {}
|
14
20
|
@enable = traverse_config(hsh, :enable)
|
15
21
|
@mode = traverse_config(hsh, :mode)
|
16
22
|
@disable_system_commands = traverse_config(hsh, :disable_system_commands)
|
17
23
|
@detect_custom_code_accessing_system_files = traverse_config(hsh, :detect_custom_code_accessing_system_files)
|
18
|
-
|
19
|
-
|
24
|
+
end
|
25
|
+
|
26
|
+
# @return [Boolean, true]
|
27
|
+
def detect_custom_code_accessing_system_files
|
28
|
+
@detect_custom_code_accessing_system_files.nil? ? true : @detect_custom_code_accessing_system_files
|
20
29
|
end
|
21
30
|
|
22
31
|
# To convert the user input mode from config to a standard format used by TS & SR, we need to convert the given
|
@@ -40,33 +49,6 @@ module Contrast
|
|
40
49
|
Contrast::Api::Settings::ProtectionRule::Mode::NO_ACTION
|
41
50
|
end
|
42
51
|
end
|
43
|
-
|
44
|
-
def [] key
|
45
|
-
send(key.to_sym)
|
46
|
-
end
|
47
|
-
|
48
|
-
# Traverse the given entity to build out the configuration graph.
|
49
|
-
#
|
50
|
-
# The values will be either a hash, indicating internal nodes to
|
51
|
-
# traverse, or a value to set or the EMPTY_VALUE symbol, indicating a
|
52
|
-
# leaf node.
|
53
|
-
#
|
54
|
-
# The spec_key are the Contrast defined keys based on the instance variables of
|
55
|
-
# a given configuration.
|
56
|
-
def traverse_config values, spec_key
|
57
|
-
internal_nodes = values.cs__respond_to?(:has_key?)
|
58
|
-
val = internal_nodes ? value_from_key_config(spec_key, values) : nil
|
59
|
-
val == EMPTY_VALUE ? nil : val
|
60
|
-
end
|
61
|
-
|
62
|
-
def build_configuration_map
|
63
|
-
instance_variables.each do |key|
|
64
|
-
str_key = key.to_s.tr('@', '')
|
65
|
-
next if str_key == 'configuration_map'
|
66
|
-
|
67
|
-
@configuration_map[str_key] = send(str_key.to_sym)
|
68
|
-
end
|
69
|
-
end
|
70
52
|
end
|
71
53
|
end
|
72
54
|
end
|
@@ -8,7 +8,9 @@ module Contrast
|
|
8
8
|
# Common Configuration settings. Those in this section pertain to the
|
9
9
|
# protect rule modes of the Agent.
|
10
10
|
class ProtectRulesConfiguration < BaseConfiguration
|
11
|
-
|
11
|
+
attr_accessor :disabled_rules
|
12
|
+
attr_writer :bot_blocker, :cmd_injection, :sql_injection, :nosql_injection, :untrusted_deserialization,
|
13
|
+
:method_tampering, :xxe, :path_traversal, :reflected_xss, :unsafe_file_upload, :rule_base
|
12
14
|
|
13
15
|
BASE_RULE = 'Contrast::Agent::Protect::Rule::Base'.cs__freeze
|
14
16
|
|
@@ -27,8 +29,6 @@ module Contrast
|
|
27
29
|
@reflected_xss = Contrast::Config::ProtectRuleConfiguration.new(traverse_config(hsh, 'reflected-xss'))
|
28
30
|
@unsafe_file_upload = Contrast::Config::ProtectRuleConfiguration.new(traverse_config(hsh, 'unsafe-file-upload'))
|
29
31
|
@rule_base = Contrast::Config::ProtectRuleConfiguration.new(traverse_config(hsh, BASE_RULE))
|
30
|
-
@configuration_map = {}
|
31
|
-
build_configuration_map
|
32
32
|
end
|
33
33
|
|
34
34
|
def bot_blocker
|
@@ -75,33 +75,28 @@ module Contrast
|
|
75
75
|
@rule_base ||= Contrast::Config::ProtectRuleConfiguration.new
|
76
76
|
end
|
77
77
|
|
78
|
+
def []= key, value
|
79
|
+
instance_variable_set("@#{ convert_key(key) }".to_sym, value)
|
80
|
+
end
|
81
|
+
|
78
82
|
def [] key
|
79
|
-
send(
|
83
|
+
send(convert_key(key).to_sym)
|
80
84
|
end
|
81
85
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
#
|
87
|
-
#
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
end
|
95
|
-
|
96
|
-
def build_configuration_map
|
97
|
-
change_vals = { '@' => '', '-' => '_' }
|
98
|
-
regexp = Regexp.union(change_vals.keys)
|
99
|
-
instance_variables.each do |key|
|
100
|
-
str_key = key.to_s.gsub(regexp, change_vals)
|
101
|
-
next if str_key == 'configuration_map'
|
102
|
-
|
103
|
-
@configuration_map[return_proper_class(str_key)] = send(str_key.to_sym)
|
86
|
+
def convert_key key
|
87
|
+
return_proper_class(key).to_s.tr('-', '_')
|
88
|
+
end
|
89
|
+
|
90
|
+
# Convert instance variable names to format expected by TS
|
91
|
+
# for adding to the hash
|
92
|
+
def to_hash
|
93
|
+
hsh = {}
|
94
|
+
instance_variables.each do |iv|
|
95
|
+
# strip the '@' to get the key
|
96
|
+
key = return_proper_class(iv.to_s.delete('@'))
|
97
|
+
hsh[key.tr('_', '-')] = send(key.to_sym)
|
104
98
|
end
|
99
|
+
hsh
|
105
100
|
end
|
106
101
|
|
107
102
|
# This method is to handle the specific case of
|