contrast-agent 5.2.0 → 6.1.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_regexp/cs__assess_regexp.c +15 -2
- data/ext/cs__assess_regexp/cs__assess_regexp.h +2 -0
- data/ext/cs__assess_string/cs__assess_string.c +21 -1
- data/ext/cs__assess_test/cs__assess_test.h +9 -0
- data/ext/cs__assess_test/cs__assess_tests.c +22 -0
- data/ext/cs__assess_test/extconf.rb +5 -0
- data/ext/cs__common/cs__common.c +113 -11
- data/ext/cs__common/cs__common.h +29 -5
- data/ext/cs__contrast_patch/cs__contrast_patch.c +55 -44
- data/ext/cs__os_information/cs__os_information.c +13 -10
- data/ext/cs__scope/cs__scope.c +146 -97
- data/ext/cs__tests/cs__tests.c +12 -0
- data/ext/cs__tests/cs__tests.h +3 -0
- data/ext/cs__tests/extconf.rb +5 -0
- data/lib/contrast/agent/assess/contrast_object.rb +16 -16
- data/lib/contrast/agent/assess/events/source_event.rb +17 -19
- 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/policy_scanner.rb +2 -16
- 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/split.rb +15 -19
- 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 +4 -10
- data/lib/contrast/agent/assess/property/tagged.rb +1 -1
- data/lib/contrast/agent/assess/rule/provider/hardcoded_value_rule.rb +7 -2
- data/lib/contrast/agent/assess/rule/response/auto_complete_rule.rb +1 -1
- data/lib/contrast/agent/assess/rule/response/base_rule.rb +11 -3
- data/lib/contrast/agent/assess/rule/response/body_rule.rb +3 -3
- data/lib/contrast/agent/assess/rule/response/cache_control_header_rule.rb +60 -36
- data/lib/contrast/agent/assess/rule/response/framework/rails_support.rb +3 -3
- data/lib/contrast/agent/assess/rule/response/parameters_pollution_rule.rb +1 -1
- data/lib/contrast/agent/assess/rule/response/x_xss_protection_header_rule.rb +1 -2
- data/lib/contrast/agent/at_exit_hook.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/inventory/database_config.rb +10 -3
- data/lib/contrast/agent/middleware.rb +5 -3
- data/lib/contrast/agent/patching/policy/after_load_patch.rb +0 -2
- data/lib/contrast/agent/patching/policy/patch.rb +13 -12
- data/lib/contrast/agent/patching/policy/patcher.rb +4 -4
- 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 +66 -9
- 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 +243 -0
- data/lib/contrast/agent/reporting/masker/masker_utils.rb +62 -0
- data/lib/contrast/agent/reporting/report.rb +2 -0
- data/lib/contrast/agent/reporting/reporter.rb +29 -22
- data/lib/contrast/agent/reporting/reporter_heartbeat.rb +49 -0
- data/lib/contrast/agent/reporting/reporting_events/agent_startup.rb +34 -0
- data/lib/contrast/agent/reporting/reporting_events/application_activity.rb +53 -0
- data/lib/contrast/agent/reporting/reporting_events/application_defend_activity.rb +48 -0
- data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_activity.rb +64 -0
- data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample.rb +70 -0
- data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample_activity.rb +57 -0
- data/lib/contrast/agent/reporting/reporting_events/application_defend_attacker_activity.rb +56 -0
- data/lib/contrast/agent/reporting/reporting_events/application_inventory.rb +12 -4
- data/lib/contrast/agent/reporting/reporting_events/application_inventory_activity.rb +58 -0
- data/lib/contrast/agent/reporting/reporting_events/application_reporting_event.rb +27 -0
- data/lib/contrast/agent/reporting/reporting_events/application_startup.rb +50 -0
- data/lib/contrast/agent/reporting/reporting_events/application_startup_instrumentation.rb +27 -0
- data/lib/contrast/agent/reporting/reporting_events/application_update.rb +7 -12
- data/lib/contrast/agent/reporting/reporting_events/finding.rb +10 -4
- data/lib/contrast/agent/reporting/reporting_events/finding_event.rb +2 -4
- data/lib/contrast/agent/reporting/reporting_events/finding_event_object.rb +3 -3
- data/lib/contrast/agent/reporting/reporting_events/library_usage_observation.rb +5 -5
- data/lib/contrast/agent/reporting/reporting_events/observed_library_usage.rb +6 -2
- data/lib/contrast/agent/reporting/reporting_events/observed_route.rb +16 -12
- data/lib/contrast/agent/reporting/reporting_events/poll.rb +6 -2
- data/lib/contrast/agent/reporting/reporting_events/preflight.rb +10 -8
- data/lib/contrast/agent/reporting/reporting_events/preflight_message.rb +8 -11
- 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_events/server_activity.rb +12 -20
- data/lib/contrast/agent/reporting/reporting_events/server_reporting_event.rb +27 -0
- data/lib/contrast/agent/reporting/reporting_utilities/audit.rb +17 -27
- data/lib/contrast/agent/reporting/reporting_utilities/build_preflight.rb +38 -0
- data/lib/contrast/agent/reporting/reporting_utilities/dtm_message.rb +8 -0
- data/lib/contrast/agent/reporting/reporting_utilities/endpoints.rb +6 -0
- data/lib/contrast/agent/reporting/reporting_utilities/reporter_client.rb +23 -7
- data/lib/contrast/agent/reporting/reporting_utilities/reporter_client_utils.rb +64 -76
- data/lib/contrast/agent/reporting/reporting_utilities/reporting_storage.rb +1 -1
- data/lib/contrast/agent/reporting/reporting_utilities/response.rb +17 -7
- data/lib/contrast/agent/reporting/reporting_utilities/response_extractor.rb +100 -0
- data/lib/contrast/agent/reporting/reporting_utilities/response_handler.rb +75 -13
- data/lib/contrast/agent/reporting/reporting_utilities/response_handler_mode.rb +63 -0
- data/lib/contrast/agent/reporting/reporting_utilities/response_handler_utils.rb +154 -113
- 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.rb +1 -1
- data/lib/contrast/agent/reporting/settings/protect_server_feature.rb +2 -2
- 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.rb +3 -3
- data/lib/contrast/agent/request_context.rb +1 -1
- data/lib/contrast/agent/request_context_extend.rb +2 -2
- data/lib/contrast/agent/request_handler.rb +7 -3
- data/lib/contrast/agent/response.rb +2 -0
- data/lib/contrast/agent/service_heartbeat.rb +6 -48
- data/lib/contrast/agent/static_analysis.rb +1 -1
- data/lib/contrast/agent/telemetry/base.rb +151 -0
- data/lib/contrast/agent/telemetry/events/event.rb +35 -0
- data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exception_base.rb +59 -0
- data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exception_event.rb +44 -0
- data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exception_message.rb +115 -0
- data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exception_message_exception.rb +83 -0
- data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exception_stack_frame.rb +64 -0
- data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exceptions.rb +20 -0
- data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exceptions_report.rb +32 -0
- data/lib/contrast/agent/telemetry/events/metric_event.rb +28 -0
- data/lib/contrast/agent/telemetry/events/startup_metrics_event.rb +123 -0
- data/lib/contrast/agent/thread_watcher.rb +52 -68
- data/lib/contrast/agent/version.rb +1 -1
- data/lib/contrast/agent/worker_thread.rb +8 -0
- data/lib/contrast/agent.rb +4 -3
- data/lib/contrast/api/communication/messaging_queue.rb +28 -11
- data/lib/contrast/api/communication/response_processor.rb +7 -10
- data/lib/contrast/api/communication/speedracer.rb +1 -1
- data/lib/contrast/api/decorators/activity.rb +33 -0
- data/lib/contrast/api/decorators/address.rb +1 -1
- data/lib/contrast/api/decorators/http_request.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/config.rb +13 -22
- data/lib/contrast/components/contrast_service.rb +9 -0
- data/lib/contrast/components/protect.rb +2 -2
- data/lib/contrast/components/sampling.rb +7 -11
- data/lib/contrast/components/settings.rb +116 -8
- data/lib/contrast/config/agent_configuration.rb +34 -41
- data/lib/contrast/config/api_configuration.rb +16 -75
- data/lib/contrast/config/api_proxy_configuration.rb +9 -48
- data/lib/contrast/config/application_configuration.rb +24 -95
- data/lib/contrast/config/assess_configuration.rb +21 -76
- data/lib/contrast/config/assess_rules_configuration.rb +13 -38
- data/lib/contrast/config/base_configuration.rb +11 -76
- data/lib/contrast/config/certification_configuration.rb +15 -68
- data/lib/contrast/config/exception_configuration.rb +15 -59
- data/lib/contrast/config/heap_dump_configuration.rb +19 -73
- data/lib/contrast/config/inventory_configuration.rb +11 -55
- data/lib/contrast/config/logger_configuration.rb +8 -41
- data/lib/contrast/config/protect_configuration.rb +23 -10
- data/lib/contrast/config/protect_rule_configuration.rb +23 -37
- data/lib/contrast/config/protect_rules_configuration.rb +39 -43
- data/lib/contrast/config/request_audit_configuration.rb +16 -55
- data/lib/contrast/config/root_configuration.rb +70 -13
- data/lib/contrast/config/ruby_configuration.rb +14 -47
- data/lib/contrast/config/sampling_configuration.rb +12 -65
- data/lib/contrast/config/server_configuration.rb +13 -45
- data/lib/contrast/config/service_configuration.rb +36 -17
- data/lib/contrast/configuration.rb +21 -13
- 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/framework/rails/patch/support.rb +13 -45
- data/lib/contrast/logger/aliased_logging.rb +87 -0
- data/lib/contrast/logger/application.rb +1 -5
- data/lib/contrast/logger/cef_log.rb +1 -1
- data/lib/contrast/tasks/config.rb +100 -4
- 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 +5 -18
- data/lib/contrast/utils/input_classification.rb +73 -0
- data/lib/contrast/utils/invalid_configuration_util.rb +1 -1
- data/lib/contrast/utils/log_utils.rb +3 -1
- data/lib/contrast/utils/middleware_utils.rb +10 -9
- 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 +20 -2
- data/lib/contrast/utils/telemetry_client.rb +23 -11
- data/lib/contrast/utils/telemetry_hash.rb +41 -0
- data/lib/contrast/utils/telemetry_identifier.rb +16 -1
- data/lib/contrast.rb +9 -0
- data/resources/assess/policy.json +98 -0
- data/resources/deadzone/policy.json +0 -86
- data/ruby-agent.gemspec +10 -9
- data/service_executables/VERSION +1 -1
- data/service_executables/linux/contrast-service +0 -0
- data/service_executables/mac/contrast-service +0 -0
- metadata +98 -30
- data/lib/contrast/agent/metric_telemetry_event.rb +0 -26
- data/lib/contrast/agent/startup_metrics_telemetry_event.rb +0 -121
- data/lib/contrast/agent/telemetry.rb +0 -137
- data/lib/contrast/agent/telemetry_event.rb +0 -33
- data/lib/contrast/utils/exclude_key.rb +0 -20
@@ -3,27 +3,31 @@
|
|
3
3
|
|
4
4
|
module Contrast
|
5
5
|
module Config
|
6
|
-
# Common Configuration settings. Those in this section pertain to the
|
7
|
-
#
|
8
|
-
class HeapDumpConfiguration
|
6
|
+
# Common Configuration settings. Those in this section pertain to the Heap Dump collection functionality of the
|
7
|
+
# Agent.
|
8
|
+
class HeapDumpConfiguration
|
9
|
+
include Contrast::Config::BaseConfiguration
|
10
|
+
|
9
11
|
DEFAULT_PATH = 'contrast_heap_dumps' # saved
|
10
12
|
DEFAULT_MS = 10_000
|
11
13
|
DEFAULT_COUNT = 5
|
12
14
|
|
15
|
+
attr_writer :enable, :path, :delay_ms, :window_ms, :count, :clean
|
16
|
+
|
13
17
|
def initialize hsh = {}
|
14
|
-
|
15
|
-
|
16
|
-
@
|
17
|
-
@
|
18
|
-
@
|
19
|
-
@
|
20
|
-
@
|
21
|
-
|
18
|
+
return unless hsh
|
19
|
+
|
20
|
+
@enable = hsh[:enable]
|
21
|
+
@path = hsh[:path]
|
22
|
+
@delay_ms = hsh[:delay_ms]
|
23
|
+
@window_ms = hsh[:window_ms]
|
24
|
+
@count = hsh[:count]
|
25
|
+
@clean = hsh[:clean]
|
22
26
|
end
|
23
27
|
|
24
|
-
# @return [Boolean,
|
28
|
+
# @return [Boolean, Contrast::Utils::ObjectShare::FALSE] should dumps be taken
|
25
29
|
def enable
|
26
|
-
|
30
|
+
@enable.nil? ? Contrast::Utils::ObjectShare::FALSE : @enable
|
27
31
|
end
|
28
32
|
|
29
33
|
# @return [String, DEFAULT_PATH] dir to which dumps should be
|
@@ -46,67 +50,9 @@ module Contrast
|
|
46
50
|
@count ||= DEFAULT_COUNT
|
47
51
|
end
|
48
52
|
|
49
|
-
# @return [Boolean,
|
53
|
+
# @return [Boolean, Contrast::Utils::ObjectShare::FALSE] remove temporary objects or not
|
50
54
|
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
|
55
|
+
@clean.nil? ? Contrast::Utils::ObjectShare::FALSE : @clean
|
110
56
|
end
|
111
57
|
end
|
112
58
|
end
|
@@ -3,18 +3,20 @@
|
|
3
3
|
|
4
4
|
module Contrast
|
5
5
|
module Config
|
6
|
-
# Common Configuration settings. Those in this section pertain to the
|
7
|
-
|
8
|
-
|
6
|
+
# Common Configuration settings. Those in this section pertain to the inventory functionality of the Agent.
|
7
|
+
class InventoryConfiguration
|
8
|
+
include Contrast::Config::BaseConfiguration
|
9
|
+
|
9
10
|
# @return [Array, nil] tags
|
10
|
-
|
11
|
+
attr_accessor :tags
|
12
|
+
attr_writer :enable, :analyze_libraries
|
11
13
|
|
12
14
|
def initialize hsh = {}
|
13
|
-
|
14
|
-
|
15
|
-
@
|
16
|
-
@
|
17
|
-
|
15
|
+
return unless hsh
|
16
|
+
|
17
|
+
@enable = hsh[:enable]
|
18
|
+
@analyze_libraries = hsh[:analyze_libraries]
|
19
|
+
@tags = hsh[:tags]
|
18
20
|
end
|
19
21
|
|
20
22
|
# @return [Boolean, true]
|
@@ -26,52 +28,6 @@ module Contrast
|
|
26
28
|
def analyze_libraries
|
27
29
|
@analyze_libraries.nil? ? true : @analyze_libraries
|
28
30
|
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
31
|
end
|
76
32
|
end
|
77
33
|
end
|
@@ -3,9 +3,10 @@
|
|
3
3
|
|
4
4
|
module Contrast
|
5
5
|
module Config
|
6
|
-
# Common Configuration settings. Those in this section pertain to the
|
7
|
-
|
8
|
-
|
6
|
+
# Common Configuration settings. Those in this section pertain to the logging in the Agent.
|
7
|
+
class LoggerConfiguration
|
8
|
+
include Contrast::Config::BaseConfiguration
|
9
|
+
|
9
10
|
# @return [String, nil]
|
10
11
|
attr_accessor :path
|
11
12
|
# @return [String, nil]
|
@@ -14,45 +15,11 @@ module Contrast
|
|
14
15
|
attr_accessor :progname
|
15
16
|
|
16
17
|
def initialize hsh = {}
|
17
|
-
|
18
|
-
@level = traverse_config(hsh, :level)
|
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'
|
18
|
+
return unless hsh
|
53
19
|
|
54
|
-
|
55
|
-
|
20
|
+
@path = hsh[:path]
|
21
|
+
@level = hsh[:level]
|
22
|
+
@progname = hsh[:progname]
|
56
23
|
end
|
57
24
|
end
|
58
25
|
end
|
@@ -3,17 +3,30 @@
|
|
3
3
|
|
4
4
|
module Contrast
|
5
5
|
module Config
|
6
|
-
# Common Configuration settings. Those in this section pertain to the
|
7
|
-
|
8
|
-
|
9
|
-
KEYS = {
|
10
|
-
exceptions: Contrast::Config::ExceptionConfiguration,
|
11
|
-
rules: Contrast::Config::ProtectRulesConfiguration,
|
12
|
-
enable: EMPTY_VALUE
|
13
|
-
}.cs__freeze
|
6
|
+
# Common Configuration settings. Those in this section pertain to the protect functionality of the Agent.
|
7
|
+
class ProtectConfiguration
|
8
|
+
include Contrast::Config::BaseConfiguration
|
14
9
|
|
15
|
-
|
16
|
-
|
10
|
+
# @return [Boolean, nil]
|
11
|
+
attr_accessor :enable
|
12
|
+
attr_writer :exceptions, :rules
|
13
|
+
|
14
|
+
def initialize hsh = {}
|
15
|
+
return unless hsh
|
16
|
+
|
17
|
+
@exceptions = Contrast::Config::ExceptionConfiguration.new(hsh[:exceptions])
|
18
|
+
@rules = Contrast::Config::ProtectRulesConfiguration.new(hsh[:rules])
|
19
|
+
@enable = hsh[:enable]
|
20
|
+
end
|
21
|
+
|
22
|
+
# @return [Contrast::Config::ExceptionConfiguration]
|
23
|
+
def exceptions
|
24
|
+
@exceptions ||= Contrast::Config::ExceptionConfiguration.new
|
25
|
+
end
|
26
|
+
|
27
|
+
# @return [Contrast::Config::ProtectRulesConfiguration]
|
28
|
+
def rules
|
29
|
+
@rules ||= Contrast::Config::ProtectRulesConfiguration.new
|
17
30
|
end
|
18
31
|
end
|
19
32
|
end
|
@@ -5,18 +5,31 @@ require 'set'
|
|
5
5
|
|
6
6
|
module Contrast
|
7
7
|
module Config
|
8
|
-
# Common Configuration settings. Those in this section pertain to the
|
9
|
-
#
|
10
|
-
class ProtectRuleConfiguration
|
11
|
-
|
8
|
+
# Common Configuration settings. Those in this section pertain to the rule mode of a single protect rule in the
|
9
|
+
# Agent.
|
10
|
+
class ProtectRuleConfiguration
|
11
|
+
include Contrast::Config::BaseConfiguration
|
12
|
+
|
13
|
+
# @return [Boolean, nil]
|
14
|
+
attr_accessor :enable
|
15
|
+
# @return [String, nil]
|
16
|
+
attr_accessor :mode
|
17
|
+
# @return [Boolean, nil]
|
18
|
+
attr_accessor :disable_system_commands
|
19
|
+
attr_writer :detect_custom_code_accessing_system_files
|
12
20
|
|
13
21
|
def initialize hsh = {}
|
14
|
-
|
15
|
-
|
16
|
-
@
|
17
|
-
@
|
18
|
-
@
|
19
|
-
|
22
|
+
return unless hsh
|
23
|
+
|
24
|
+
@enable = hsh[:enable]
|
25
|
+
@mode = hsh[:mode]
|
26
|
+
@disable_system_commands = hsh[:disable_system_commands]
|
27
|
+
@detect_custom_code_accessing_system_files = hsh[:detect_custom_code_accessing_system_files]
|
28
|
+
end
|
29
|
+
|
30
|
+
# @return [Boolean, true]
|
31
|
+
def detect_custom_code_accessing_system_files
|
32
|
+
@detect_custom_code_accessing_system_files.nil? ? true : @detect_custom_code_accessing_system_files
|
20
33
|
end
|
21
34
|
|
22
35
|
# To convert the user input mode from config to a standard format used by TS & SR, we need to convert the given
|
@@ -40,33 +53,6 @@ module Contrast
|
|
40
53
|
Contrast::Api::Settings::ProtectionRule::Mode::NO_ACTION
|
41
54
|
end
|
42
55
|
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
56
|
end
|
71
57
|
end
|
72
58
|
end
|
@@ -5,30 +5,31 @@ require 'contrast/config/protect_rule_configuration'
|
|
5
5
|
|
6
6
|
module Contrast
|
7
7
|
module Config
|
8
|
-
# Common Configuration settings. Those in this section pertain to the
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
# Common Configuration settings. Those in this section pertain to the protect rule modes of the Agent.
|
9
|
+
class ProtectRulesConfiguration
|
10
|
+
include Contrast::Config::BaseConfiguration
|
11
|
+
|
12
|
+
attr_accessor :disabled_rules
|
13
|
+
attr_writer :bot_blocker, :cmd_injection, :sql_injection, :nosql_injection, :untrusted_deserialization,
|
14
|
+
:method_tampering, :xxe, :path_traversal, :reflected_xss, :unsafe_file_upload, :rule_base
|
12
15
|
|
13
16
|
BASE_RULE = 'Contrast::Agent::Protect::Rule::Base'.cs__freeze
|
14
17
|
|
15
18
|
def initialize hsh = {}
|
16
|
-
|
17
|
-
|
18
|
-
@
|
19
|
-
@
|
20
|
-
@
|
21
|
-
@
|
22
|
-
|
23
|
-
|
24
|
-
@
|
25
|
-
@
|
26
|
-
@
|
27
|
-
@
|
28
|
-
@
|
29
|
-
@
|
30
|
-
@configuration_map = {}
|
31
|
-
build_configuration_map
|
19
|
+
return unless hsh
|
20
|
+
|
21
|
+
@disabled_rules = hsh[:disabled_rules]
|
22
|
+
@rule_base = Contrast::Config::ProtectRuleConfiguration.new(hsh[BASE_RULE.to_sym])
|
23
|
+
@bot_blocker = Contrast::Config::ProtectRuleConfiguration.new(hsh[:'bot-blocker'])
|
24
|
+
@cmd_injection = Contrast::Config::ProtectRuleConfiguration.new(hsh[:'cmd-injection'])
|
25
|
+
@method_tampering = Contrast::Config::ProtectRuleConfiguration.new(hsh[:'method-tampering'])
|
26
|
+
@nosql_injection = Contrast::Config::ProtectRuleConfiguration.new(hsh[:'nosql-injection'])
|
27
|
+
@path_traversal = Contrast::Config::ProtectRuleConfiguration.new(hsh[:'path-traversal'])
|
28
|
+
@reflected_xss = Contrast::Config::ProtectRuleConfiguration.new(hsh[:'reflected-xss'])
|
29
|
+
@sql_injection = Contrast::Config::ProtectRuleConfiguration.new(hsh[:'sql-injection'])
|
30
|
+
@unsafe_file_upload = Contrast::Config::ProtectRuleConfiguration.new(hsh[:'unsafe-file-upload'])
|
31
|
+
@untrusted_deserialization = Contrast::Config::ProtectRuleConfiguration.new(hsh[:'untrusted-deserialization'])
|
32
|
+
@xxe = Contrast::Config::ProtectRuleConfiguration.new(hsh[:xxe])
|
32
33
|
end
|
33
34
|
|
34
35
|
def bot_blocker
|
@@ -75,33 +76,28 @@ module Contrast
|
|
75
76
|
@rule_base ||= Contrast::Config::ProtectRuleConfiguration.new
|
76
77
|
end
|
77
78
|
|
79
|
+
def []= key, value
|
80
|
+
instance_variable_set("@#{ convert_key(key) }".to_sym, value)
|
81
|
+
end
|
82
|
+
|
78
83
|
def [] key
|
79
|
-
send(
|
84
|
+
send(convert_key(key).to_sym)
|
80
85
|
end
|
81
86
|
|
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)
|
87
|
+
def convert_key key
|
88
|
+
return_proper_class(key).to_s.tr('-', '_')
|
89
|
+
end
|
90
|
+
|
91
|
+
# Convert instance variable names to format expected by TS
|
92
|
+
# for adding to the hash
|
93
|
+
def to_hash
|
94
|
+
hsh = {}
|
95
|
+
instance_variables.each do |iv|
|
96
|
+
# strip the '@' to get the key
|
97
|
+
key = return_proper_class(iv.to_s.delete('@'))
|
98
|
+
hsh[key.tr('_', '-')] = send(key.to_sym)
|
104
99
|
end
|
100
|
+
hsh
|
105
101
|
end
|
106
102
|
|
107
103
|
# This method is to handle the specific case of
|
@@ -3,81 +3,42 @@
|
|
3
3
|
|
4
4
|
module Contrast
|
5
5
|
module Config
|
6
|
-
# This class holds the Common Settings for the
|
7
|
-
|
8
|
-
|
6
|
+
# This class holds the Common Settings for the hidden functionality of the TS
|
7
|
+
class RequestAuditConfiguration
|
8
|
+
include Contrast::Config::BaseConfiguration
|
9
|
+
|
9
10
|
DEFAULT_PATH = './messages'
|
10
11
|
|
12
|
+
attr_writer :enable, :requests, :responses, :path
|
13
|
+
|
11
14
|
def initialize hsh = {}
|
12
|
-
|
13
|
-
|
14
|
-
@
|
15
|
-
@
|
16
|
-
@
|
17
|
-
|
15
|
+
return unless hsh
|
16
|
+
|
17
|
+
@enable = hsh[:enable]
|
18
|
+
@requests = hsh[:requests]
|
19
|
+
@responses = hsh[:responses]
|
20
|
+
@path = hsh[:path]
|
18
21
|
end
|
19
22
|
|
23
|
+
# @return [Boolean, false]
|
20
24
|
def enable
|
21
25
|
@enable.nil? ? false : @enable
|
22
26
|
end
|
23
27
|
|
28
|
+
# @return [Boolean, false]
|
24
29
|
def requests
|
25
30
|
@requests.nil? ? false : @requests
|
26
31
|
end
|
27
32
|
|
33
|
+
# @return [Boolean, false]
|
28
34
|
def responses
|
29
35
|
@responses.nil? ? false : @responses
|
30
36
|
end
|
31
37
|
|
38
|
+
# @return [String, ::DEFAULT_PATH]
|
32
39
|
def path
|
33
40
|
@path.nil? ? DEFAULT_PATH : @path
|
34
41
|
end
|
35
|
-
|
36
|
-
def enable= value
|
37
|
-
self['enable'] = value
|
38
|
-
end
|
39
|
-
|
40
|
-
def requests= value
|
41
|
-
self['requests'] = value
|
42
|
-
end
|
43
|
-
|
44
|
-
def responses= value
|
45
|
-
self['responses'] = value
|
46
|
-
end
|
47
|
-
|
48
|
-
def path= value
|
49
|
-
self['path'] = value
|
50
|
-
end
|
51
|
-
|
52
|
-
# TODO: RUBY-1493 MOVE TO BASE CONFIG
|
53
|
-
|
54
|
-
def []= key, value
|
55
|
-
instance_variable_set("@#{ key }".to_sym, value)
|
56
|
-
@configuration_map[key] = value
|
57
|
-
end
|
58
|
-
|
59
|
-
# Traverse the given entity to build out the configuration graph.
|
60
|
-
#
|
61
|
-
# The values will be either a hash, indicating internal nodes to
|
62
|
-
# traverse, or a value to set or the EMPTY_VALUE symbol, indicating a
|
63
|
-
# leaf node.
|
64
|
-
#
|
65
|
-
# The spec_key are the Contrast defined keys based on the instance variables of
|
66
|
-
# a given configuration.
|
67
|
-
def traverse_config values, spec_key
|
68
|
-
internal_nodes = values.cs__respond_to?(:has_key?)
|
69
|
-
val = internal_nodes ? value_from_key_config(spec_key, values) : nil
|
70
|
-
val == EMPTY_VALUE ? nil : val
|
71
|
-
end
|
72
|
-
|
73
|
-
def build_configuration_map
|
74
|
-
instance_variables.each do |key|
|
75
|
-
str_key = key.to_s.tr('@', '')
|
76
|
-
next if str_key == 'configuration_map'
|
77
|
-
|
78
|
-
@configuration_map[str_key] = send(str_key.to_sym)
|
79
|
-
end
|
80
|
-
end
|
81
42
|
end
|
82
43
|
end
|
83
44
|
end
|
@@ -4,23 +4,80 @@
|
|
4
4
|
module Contrast
|
5
5
|
module Config
|
6
6
|
# The base of the Common Configuration settings.
|
7
|
-
class RootConfiguration
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
7
|
+
class RootConfiguration
|
8
|
+
include Contrast::Config::BaseConfiguration
|
9
|
+
|
10
|
+
# @return [Contrast::Config::ApiConfiguration]
|
11
|
+
attr_writer :api
|
12
|
+
# @return [Contrast::Config::AgentConfiguration]
|
13
|
+
attr_writer :agent
|
14
|
+
# @return [Contrast::Config::ApplicationConfiguration]
|
15
|
+
attr_writer :application
|
16
|
+
# @return [Contrast::Config::ServerConfiguration]
|
17
|
+
attr_writer :server
|
18
|
+
# @return [Contrast::Config::AssessConfiguration]
|
19
|
+
attr_writer :assess
|
20
|
+
# @return [Contrast::Config::InventoryConfiguration]
|
21
|
+
attr_writer :inventory
|
22
|
+
# @return [Contrast::Config::ProtectConfiguration]
|
23
|
+
attr_writer :protect
|
24
|
+
# @return [Contrast::Config::ServiceConfiguration]
|
25
|
+
attr_writer :service
|
26
|
+
# @return [Boolean, nil]
|
27
|
+
attr_accessor :enable
|
19
28
|
|
20
29
|
def initialize hsh = {}
|
21
30
|
raise ArgumentError, 'Expected a hash' unless hsh.is_a?(Hash)
|
22
31
|
|
23
|
-
|
32
|
+
@api = Contrast::Config::ApiConfiguration.new(hsh[:api])
|
33
|
+
@enable = hsh[:enable]
|
34
|
+
@agent = Contrast::Config::AgentConfiguration.new(hsh[:agent])
|
35
|
+
@application = Contrast::Config::ApplicationConfiguration.new(hsh[:application])
|
36
|
+
@server = Contrast::Config::ServerConfiguration.new(hsh[:server])
|
37
|
+
@assess = Contrast::Config::AssessConfiguration.new(hsh[:assess])
|
38
|
+
@inventory = Contrast::Config::InventoryConfiguration.new(hsh[:inventory])
|
39
|
+
@protect = Contrast::Config::ProtectConfiguration.new(hsh[:protect])
|
40
|
+
@service = Contrast::Config::ServiceConfiguration.new(hsh[:service])
|
41
|
+
end
|
42
|
+
|
43
|
+
# @return [Contrast::Config::ApiConfiguration]
|
44
|
+
def api
|
45
|
+
@api ||= Contrast::Config::ApiConfiguration.new
|
46
|
+
end
|
47
|
+
|
48
|
+
# @return [Contrast::Config::AgentConfiguration]
|
49
|
+
def agent
|
50
|
+
@agent ||= Contrast::Config::AgentConfiguration.new
|
51
|
+
end
|
52
|
+
|
53
|
+
# @return [Contrast::Config::ApplicationConfiguration]
|
54
|
+
def application
|
55
|
+
@application ||= Contrast::Config::ApplicationConfiguration.new
|
56
|
+
end
|
57
|
+
|
58
|
+
# @return [Contrast::Config::ServerConfiguration]
|
59
|
+
def server
|
60
|
+
@server ||= Contrast::Config::ServerConfiguration.new
|
61
|
+
end
|
62
|
+
|
63
|
+
# @return [Contrast::Config::AssessConfiguration]
|
64
|
+
def assess
|
65
|
+
@assess ||= Contrast::Config::AssessConfiguration.new
|
66
|
+
end
|
67
|
+
|
68
|
+
# @return [Contrast::Config::InventoryConfiguration]
|
69
|
+
def inventory
|
70
|
+
@inventory ||= Contrast::Config::InventoryConfiguration.new
|
71
|
+
end
|
72
|
+
|
73
|
+
# @return [Contrast::Config::ProtectConfiguration]
|
74
|
+
def protect
|
75
|
+
@protect ||= Contrast::Config::ProtectConfiguration.new
|
76
|
+
end
|
77
|
+
|
78
|
+
# @return [Contrast::Config::ServiceConfiguration]
|
79
|
+
def service
|
80
|
+
@service ||= Contrast::Config::ServiceConfiguration.new
|
24
81
|
end
|
25
82
|
end
|
26
83
|
end
|