contrast-agent 6.0.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_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 +8 -0
- 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 +101 -0
- data/ext/cs__common/cs__common.h +29 -5
- data/ext/cs__contrast_patch/cs__contrast_patch.c +1 -1
- 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/policy/policy_scanner.rb +2 -16
- data/lib/contrast/agent/assess/policy/propagator/split.rb +15 -19
- data/lib/contrast/agent/assess/policy/trigger_method.rb +3 -11
- data/lib/contrast/agent/assess/rule/provider/hardcoded_value_rule.rb +7 -2
- data/lib/contrast/agent/assess/rule/response/base_rule.rb +11 -3
- data/lib/contrast/agent/assess/rule/response/cache_control_header_rule.rb +60 -36
- data/lib/contrast/agent/at_exit_hook.rb +1 -1
- data/lib/contrast/agent/inventory/database_config.rb +10 -3
- data/lib/contrast/agent/middleware.rb +3 -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 +1 -1
- data/lib/contrast/agent/protect/input_analyzer/input_analyzer.rb +6 -2
- data/lib/contrast/agent/reporting/masker/masker.rb +8 -11
- data/lib/contrast/agent/reporting/masker/masker_utils.rb +8 -4
- data/lib/contrast/agent/reporting/reporter.rb +11 -16
- data/lib/contrast/agent/reporting/reporter_heartbeat.rb +49 -0
- data/lib/contrast/agent/reporting/reporting_events/agent_startup.rb +6 -2
- 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 +5 -1
- 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 +20 -10
- data/lib/contrast/agent/reporting/reporting_events/application_update.rb +7 -12
- data/lib/contrast/agent/reporting/reporting_events/finding.rb +9 -3
- 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/observed_library_usage.rb +6 -2
- data/lib/contrast/agent/reporting/reporting_events/observed_route.rb +7 -3
- 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 +6 -10
- 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 +9 -4
- data/lib/contrast/agent/reporting/reporting_utilities/reporter_client_utils.rb +54 -67
- data/lib/contrast/agent/reporting/reporting_utilities/response.rb +17 -7
- data/lib/contrast/agent/reporting/reporting_utilities/response_extractor.rb +8 -5
- data/lib/contrast/agent/reporting/reporting_utilities/response_handler.rb +10 -10
- data/lib/contrast/agent/reporting/reporting_utilities/response_handler_utils.rb +32 -17
- data/lib/contrast/agent/reporting/settings/protect.rb +1 -1
- data/lib/contrast/agent/reporting/settings/protect_server_feature.rb +1 -1
- data/lib/contrast/agent/request.rb +3 -3
- data/lib/contrast/agent/request_context_extend.rb +1 -1
- data/lib/contrast/agent/request_handler.rb +3 -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 +44 -36
- data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exception_event.rb +29 -21
- data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exception_message.rb +91 -73
- data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exception_message_exception.rb +62 -44
- data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exception_stack_frame.rb +50 -33
- 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 +1 -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/http_request.rb +1 -1
- data/lib/contrast/components/config.rb +13 -22
- data/lib/contrast/components/contrast_service.rb +9 -0
- data/lib/contrast/components/settings.rb +10 -0
- data/lib/contrast/config/agent_configuration.rb +21 -11
- data/lib/contrast/config/api_configuration.rb +12 -8
- data/lib/contrast/config/api_proxy_configuration.rb +7 -3
- data/lib/contrast/config/application_configuration.rb +15 -11
- data/lib/contrast/config/assess_configuration.rb +13 -9
- data/lib/contrast/config/assess_rules_configuration.rb +5 -1
- data/lib/contrast/config/base_configuration.rb +3 -35
- data/lib/contrast/config/certification_configuration.rb +9 -5
- data/lib/contrast/config/exception_configuration.rb +10 -7
- data/lib/contrast/config/heap_dump_configuration.rb +13 -9
- data/lib/contrast/config/inventory_configuration.rb +9 -6
- data/lib/contrast/config/logger_configuration.rb +9 -6
- data/lib/contrast/config/protect_configuration.rb +9 -6
- data/lib/contrast/config/protect_rule_configuration.rb +12 -8
- data/lib/contrast/config/protect_rules_configuration.rb +18 -17
- data/lib/contrast/config/request_audit_configuration.rb +10 -7
- data/lib/contrast/config/root_configuration.rb +28 -11
- data/lib/contrast/config/ruby_configuration.rb +14 -11
- data/lib/contrast/config/sampling_configuration.rb +11 -8
- data/lib/contrast/config/server_configuration.rb +13 -9
- data/lib/contrast/config/service_configuration.rb +14 -11
- data/lib/contrast/configuration.rb +19 -10
- 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 +0 -4
- data/lib/contrast/tasks/config.rb +22 -13
- data/lib/contrast/utils/class_util.rb +2 -6
- data/lib/contrast/utils/invalid_configuration_util.rb +1 -1
- data/lib/contrast/utils/log_utils.rb +2 -0
- data/lib/contrast/utils/middleware_utils.rb +1 -1
- data/lib/contrast/utils/object_share.rb +1 -1
- data/lib/contrast/utils/telemetry.rb +20 -2
- data/lib/contrast/utils/telemetry_client.rb +22 -10
- 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/ruby-agent.gemspec +1 -1
- data/service_executables/VERSION +1 -1
- data/service_executables/linux/contrast-service +0 -0
- data/service_executables/mac/contrast-service +0 -0
- metadata +39 -16
- data/lib/contrast/agent/telemetry/events/metric_telemetry_event.rb +0 -26
- data/lib/contrast/agent/telemetry/events/startup_metrics_telemetry_event.rb +0 -121
- data/lib/contrast/agent/telemetry/events/telemetry_event.rb +0 -33
- data/lib/contrast/agent/telemetry/telemetry.rb +0 -150
- data/lib/contrast/utils/exclude_key.rb +0 -20
@@ -5,7 +5,9 @@ module Contrast
|
|
5
5
|
module Config
|
6
6
|
# Common Configuration settings. Those in this section pertain to the
|
7
7
|
# assess functionality of the Agent.
|
8
|
-
class AssessConfiguration
|
8
|
+
class AssessConfiguration
|
9
|
+
include Contrast::Config::BaseConfiguration
|
10
|
+
|
9
11
|
# @return [String, nil]
|
10
12
|
attr_accessor :tags
|
11
13
|
# @return [Boolean, nil]
|
@@ -15,14 +17,16 @@ module Contrast
|
|
15
17
|
DEFAULT_STACKTRACES = 'ALL'
|
16
18
|
|
17
19
|
def initialize hsh = {}
|
18
|
-
|
19
|
-
|
20
|
-
@
|
21
|
-
@
|
22
|
-
@
|
23
|
-
@
|
24
|
-
@
|
25
|
-
@
|
20
|
+
return unless hsh
|
21
|
+
|
22
|
+
@enable = hsh[:enable]
|
23
|
+
@tags = hsh[:tags]
|
24
|
+
@enable_scan_response = hsh[:enable_scan_response]
|
25
|
+
@enable_dynamic_sources = hsh[:enable_dynamic_sources]
|
26
|
+
@enable_original_object = hsh[:enable_original_object]
|
27
|
+
@sampling = Contrast::Config::SamplingConfiguration.new(hsh[:sampling])
|
28
|
+
@rules = Contrast::Config::AssessRulesConfiguration.new(hsh[:rules])
|
29
|
+
@stacktraces = hsh[:stacktraces]
|
26
30
|
end
|
27
31
|
|
28
32
|
# @return [Boolean, true]
|
@@ -5,12 +5,16 @@ module Contrast
|
|
5
5
|
module Config
|
6
6
|
# Common Configuration settings. Those in this section pertain to the
|
7
7
|
# disabled assess rule functionality of the Agent.
|
8
|
-
class AssessRulesConfiguration
|
8
|
+
class AssessRulesConfiguration
|
9
|
+
include Contrast::Config::BaseConfiguration
|
10
|
+
|
9
11
|
SPEC_KEY = :disabled_rules.cs__freeze
|
10
12
|
# @return [Array, nil] list of disabled assess rules
|
11
13
|
attr_accessor :disabled_rules
|
12
14
|
|
13
15
|
def initialize hsh = {}
|
16
|
+
return unless hsh
|
17
|
+
|
14
18
|
@disabled_rules = cast_disabled_rules hsh
|
15
19
|
end
|
16
20
|
|
@@ -6,20 +6,11 @@ require 'contrast/utils/object_share'
|
|
6
6
|
|
7
7
|
module Contrast
|
8
8
|
module Config
|
9
|
-
# This is the base for our configuration classes. It is intended to
|
10
|
-
#
|
11
|
-
|
12
|
-
class BaseConfiguration
|
9
|
+
# This is the base for our configuration classes. It is intended to facilitate the translation of the Common
|
10
|
+
# Configuration settings to usable Ruby classes.
|
11
|
+
module BaseConfiguration
|
13
12
|
extend Forwardable
|
14
13
|
|
15
|
-
EMPTY_VALUE = :EMPTY_VALUE
|
16
|
-
|
17
|
-
def initialize hsh = {}, keys = {}
|
18
|
-
# holds configuration key value pairs
|
19
|
-
# each configuration class can contain nested BaseConfigurations
|
20
|
-
traverse_config(hsh, keys)
|
21
|
-
end
|
22
|
-
|
23
14
|
def to_hash
|
24
15
|
hsh = {}
|
25
16
|
instance_variables.each do |iv|
|
@@ -42,29 +33,6 @@ module Contrast
|
|
42
33
|
end
|
43
34
|
nil
|
44
35
|
end
|
45
|
-
|
46
|
-
private
|
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 value_from_key_config key, config_hash
|
63
|
-
return config_hash[key] if config_hash.key?(key)
|
64
|
-
return config_hash.fetch(key.to_sym, nil) if key.is_a?(String)
|
65
|
-
|
66
|
-
config_hash.fetch(key.to_s, nil)
|
67
|
-
end
|
68
36
|
end
|
69
37
|
end
|
70
38
|
end
|
@@ -4,7 +4,9 @@
|
|
4
4
|
module Contrast
|
5
5
|
module Config
|
6
6
|
# Certificate Configuration
|
7
|
-
class CertificationConfiguration
|
7
|
+
class CertificationConfiguration
|
8
|
+
include Contrast::Config::BaseConfiguration
|
9
|
+
|
8
10
|
# @return [String] path to CA Cert file
|
9
11
|
attr_accessor :ca_file
|
10
12
|
# @return [String] path to Certification file
|
@@ -14,10 +16,12 @@ module Contrast
|
|
14
16
|
attr_writer :enable
|
15
17
|
|
16
18
|
def initialize hsh = {}
|
17
|
-
|
18
|
-
|
19
|
-
@
|
20
|
-
@
|
19
|
+
return unless hsh
|
20
|
+
|
21
|
+
@enable = hsh[:enable]
|
22
|
+
@ca_file = hsh[:ca_file]
|
23
|
+
@cert_file = hsh[:cert_file]
|
24
|
+
@key_file = hsh[:key_file]
|
21
25
|
end
|
22
26
|
|
23
27
|
# @return [Boolean, false]
|
@@ -3,10 +3,11 @@
|
|
3
3
|
|
4
4
|
module Contrast
|
5
5
|
module Config
|
6
|
-
# Common Configuration settings. Those in this section pertain to the
|
7
|
-
#
|
8
|
-
|
9
|
-
|
6
|
+
# Common Configuration settings. Those in this section pertain to the exception handling in Ruby, allowing for the
|
7
|
+
# override of Response Code and Message when Security Exceptions are raised.
|
8
|
+
class ExceptionConfiguration
|
9
|
+
include Contrast::Config::BaseConfiguration
|
10
|
+
|
10
11
|
# @return [Integer] the HTTP status code override
|
11
12
|
attr_accessor :override_status
|
12
13
|
# @return [String] the message text override
|
@@ -14,9 +15,11 @@ module Contrast
|
|
14
15
|
attr_writer :capture
|
15
16
|
|
16
17
|
def initialize hsh = {}
|
17
|
-
|
18
|
-
|
19
|
-
@
|
18
|
+
return unless hsh
|
19
|
+
|
20
|
+
@capture = hsh[:capture]
|
21
|
+
@override_status = hsh[:override_status]
|
22
|
+
@override_message = hsh[:override_message]
|
20
23
|
end
|
21
24
|
|
22
25
|
# @return [Boolean, false]
|
@@ -3,9 +3,11 @@
|
|
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
|
@@ -13,12 +15,14 @@ module Contrast
|
|
13
15
|
attr_writer :enable, :path, :delay_ms, :window_ms, :count, :clean
|
14
16
|
|
15
17
|
def initialize hsh = {}
|
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
28
|
# @return [Boolean, Contrast::Utils::ObjectShare::FALSE] should dumps be taken
|
@@ -3,17 +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
|
11
12
|
attr_writer :enable, :analyze_libraries
|
12
13
|
|
13
14
|
def initialize hsh = {}
|
14
|
-
|
15
|
-
|
16
|
-
@
|
15
|
+
return unless hsh
|
16
|
+
|
17
|
+
@enable = hsh[:enable]
|
18
|
+
@analyze_libraries = hsh[:analyze_libraries]
|
19
|
+
@tags = hsh[:tags]
|
17
20
|
end
|
18
21
|
|
19
22
|
# @return [Boolean, true]
|
@@ -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,9 +15,11 @@ module Contrast
|
|
14
15
|
attr_accessor :progname
|
15
16
|
|
16
17
|
def initialize hsh = {}
|
17
|
-
|
18
|
-
|
19
|
-
@
|
18
|
+
return unless hsh
|
19
|
+
|
20
|
+
@path = hsh[:path]
|
21
|
+
@level = hsh[:level]
|
22
|
+
@progname = hsh[:progname]
|
20
23
|
end
|
21
24
|
end
|
22
25
|
end
|
@@ -3,17 +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 protect functionality of the Agent.
|
7
|
+
class ProtectConfiguration
|
8
|
+
include Contrast::Config::BaseConfiguration
|
9
|
+
|
9
10
|
# @return [Boolean, nil]
|
10
11
|
attr_accessor :enable
|
11
12
|
attr_writer :exceptions, :rules
|
12
13
|
|
13
14
|
def initialize hsh = {}
|
14
|
-
|
15
|
-
|
16
|
-
@
|
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]
|
17
20
|
end
|
18
21
|
|
19
22
|
# @return [Contrast::Config::ExceptionConfiguration]
|
@@ -5,22 +5,26 @@ 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
|
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
|
+
|
11
13
|
# @return [Boolean, nil]
|
12
14
|
attr_accessor :enable
|
13
15
|
# @return [String, nil]
|
14
16
|
attr_accessor :mode
|
15
|
-
# @
|
17
|
+
# @return [Boolean, nil]
|
16
18
|
attr_accessor :disable_system_commands
|
17
19
|
attr_writer :detect_custom_code_accessing_system_files
|
18
20
|
|
19
21
|
def initialize hsh = {}
|
20
|
-
|
21
|
-
|
22
|
-
@
|
23
|
-
@
|
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]
|
24
28
|
end
|
25
29
|
|
26
30
|
# @return [Boolean, true]
|
@@ -5,9 +5,10 @@ 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
|
-
|
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
|
+
|
11
12
|
attr_accessor :disabled_rules
|
12
13
|
attr_writer :bot_blocker, :cmd_injection, :sql_injection, :nosql_injection, :untrusted_deserialization,
|
13
14
|
:method_tampering, :xxe, :path_traversal, :reflected_xss, :unsafe_file_upload, :rule_base
|
@@ -15,20 +16,20 @@ module Contrast
|
|
15
16
|
BASE_RULE = 'Contrast::Agent::Protect::Rule::Base'.cs__freeze
|
16
17
|
|
17
18
|
def initialize hsh = {}
|
18
|
-
|
19
|
-
|
20
|
-
@
|
21
|
-
@
|
22
|
-
@
|
23
|
-
@
|
24
|
-
|
25
|
-
|
26
|
-
@
|
27
|
-
@
|
28
|
-
@
|
29
|
-
@
|
30
|
-
@
|
31
|
-
@
|
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
|
@@ -3,18 +3,21 @@
|
|
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
|
|
11
12
|
attr_writer :enable, :requests, :responses, :path
|
12
13
|
|
13
14
|
def initialize hsh = {}
|
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
|
|
20
23
|
# @return [Boolean, false]
|
@@ -4,23 +4,40 @@
|
|
4
4
|
module Contrast
|
5
5
|
module Config
|
6
6
|
# The base of the Common Configuration settings.
|
7
|
-
class RootConfiguration
|
8
|
-
|
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
|
9
26
|
# @return [Boolean, nil]
|
10
27
|
attr_accessor :enable
|
11
28
|
|
12
29
|
def initialize hsh = {}
|
13
30
|
raise ArgumentError, 'Expected a hash' unless hsh.is_a?(Hash)
|
14
31
|
|
15
|
-
@api = Contrast::Config::ApiConfiguration.new(
|
16
|
-
@enable =
|
17
|
-
@agent = Contrast::Config::AgentConfiguration.new(
|
18
|
-
@application = Contrast::Config::ApplicationConfiguration.new(
|
19
|
-
@server = Contrast::Config::ServerConfiguration.new(
|
20
|
-
@assess = Contrast::Config::AssessConfiguration.new(
|
21
|
-
@inventory = Contrast::Config::InventoryConfiguration.new(
|
22
|
-
@protect = Contrast::Config::ProtectConfiguration.new(
|
23
|
-
@service = Contrast::Config::ServiceConfiguration.new(
|
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])
|
24
41
|
end
|
25
42
|
|
26
43
|
# @return [Contrast::Config::ApiConfiguration]
|
@@ -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 specific settings that apply to Ruby
|
7
|
+
class RubyConfiguration
|
8
|
+
include Contrast::Config::BaseConfiguration
|
9
|
+
|
9
10
|
DISABLED_RAKE_TASK_LIST = %w[
|
10
11
|
about assets:clean assets:clobber assets:environment
|
11
12
|
assets:precompile assets:precompile:all db:create db:drop db:fixtures:load db:migrate
|
@@ -23,14 +24,16 @@ module Contrast
|
|
23
24
|
:track_frozen_sources, :non_request_tracking, :uninstrument_namespace
|
24
25
|
|
25
26
|
def initialize hsh = {}
|
26
|
-
|
27
|
-
|
28
|
-
@
|
29
|
-
@
|
30
|
-
@
|
31
|
-
@
|
32
|
-
@
|
33
|
-
@
|
27
|
+
return unless hsh
|
28
|
+
|
29
|
+
@disabled_agent_rake_tasks = hsh[:disabled_agent_rake_tasks]
|
30
|
+
@exceptions = Contrast::Config::ExceptionConfiguration.new(hsh[:exceptions])
|
31
|
+
@interpolate = hsh[:interpolate]
|
32
|
+
@propagate_yield = hsh[:propagate_yield]
|
33
|
+
@require_scan = hsh[:require_scan]
|
34
|
+
@track_frozen_sources = hsh[:track_frozen_sources]
|
35
|
+
@non_request_tracking = hsh[:non_request_tracking]
|
36
|
+
@uninstrument_namespace = hsh[:uninstrument_namespace]
|
34
37
|
end
|
35
38
|
|
36
39
|
# These commands being detected will result the agent disabling instrumentation, generally any command
|
@@ -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 sampling functionality of the Agent.
|
7
|
+
class SamplingConfiguration
|
8
|
+
include Contrast::Config::BaseConfiguration
|
9
|
+
|
9
10
|
# @return [Integer, nil]
|
10
11
|
attr_reader :baseline
|
11
12
|
# @return [Integer, nil]
|
@@ -16,11 +17,13 @@ module Contrast
|
|
16
17
|
attr_reader :window_ms
|
17
18
|
|
18
19
|
def initialize hsh = {}
|
19
|
-
|
20
|
-
|
21
|
-
@
|
22
|
-
@
|
23
|
-
@
|
20
|
+
return unless hsh
|
21
|
+
|
22
|
+
@enable = hsh[:enable]
|
23
|
+
@baseline = hsh[:baseline]
|
24
|
+
@request_frequency = hsh[:request_frequency]
|
25
|
+
@response_frequency = hsh[:response_frequency]
|
26
|
+
@window_ms = hsh[:window_ms]
|
24
27
|
end
|
25
28
|
|
26
29
|
# @return [Boolean, false]
|
@@ -3,9 +3,11 @@
|
|
3
3
|
|
4
4
|
module Contrast
|
5
5
|
module Config
|
6
|
-
# Common Configuration settings. Those in this section pertain to the
|
7
|
-
#
|
8
|
-
class ServerConfiguration
|
6
|
+
# Common Configuration settings. Those in this section pertain to the server identification functionality of the
|
7
|
+
# Agent.
|
8
|
+
class ServerConfiguration
|
9
|
+
include Contrast::Config::BaseConfiguration
|
10
|
+
|
9
11
|
# @return [String, nil]
|
10
12
|
attr_accessor :name
|
11
13
|
# @return [String, nil]
|
@@ -20,12 +22,14 @@ module Contrast
|
|
20
22
|
attr_accessor :version
|
21
23
|
|
22
24
|
def initialize hsh = {}
|
23
|
-
|
24
|
-
|
25
|
-
@
|
26
|
-
@
|
27
|
-
@
|
28
|
-
@
|
25
|
+
return unless hsh
|
26
|
+
|
27
|
+
@path = hsh[:path]
|
28
|
+
@name = hsh[:name]
|
29
|
+
@type = hsh[:type]
|
30
|
+
@tags = hsh[:tags]
|
31
|
+
@environment = hsh[:environment]
|
32
|
+
@version = hsh[:version]
|
29
33
|
end
|
30
34
|
end
|
31
35
|
end
|
@@ -5,11 +5,12 @@ require 'contrast/config/logger_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
|
-
|
12
|
-
#
|
8
|
+
# Common Configuration settings. Those in this section pertain to the communication between the Agent & the Service
|
9
|
+
class ServiceConfiguration
|
10
|
+
include Contrast::Config::BaseConfiguration
|
11
|
+
|
12
|
+
# We don't set these b/c we've been asked to handle the default values of these settings differently, logging
|
13
|
+
# when we have to use them.
|
13
14
|
DEFAULT_HOST = '127.0.0.1' # rubocop:disable Style/IpAddresses
|
14
15
|
DEFAULT_PORT = '30555'
|
15
16
|
|
@@ -24,12 +25,14 @@ module Contrast
|
|
24
25
|
attr_accessor :enable
|
25
26
|
|
26
27
|
def initialize hsh = {}
|
27
|
-
|
28
|
-
|
29
|
-
@
|
30
|
-
@
|
31
|
-
@
|
32
|
-
@
|
28
|
+
return unless hsh
|
29
|
+
|
30
|
+
@enable = hsh[:enable]
|
31
|
+
@host = hsh[:host]
|
32
|
+
@port = hsh[:port]
|
33
|
+
@socket = hsh[:socket]
|
34
|
+
@logger = Contrast::Config::LoggerConfiguration.new(hsh[:logger])
|
35
|
+
@bypass = hsh[:bypass]
|
33
36
|
end
|
34
37
|
|
35
38
|
# @return [Contrast::Config::LoggerConfiguration]
|