contrast-agent 6.8.0 → 6.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/lib/contrast/agent/assess/policy/trigger_method.rb +1 -1
- data/lib/contrast/agent/assess/property/evented.rb +11 -11
- data/lib/contrast/agent/assess/rule/response/body_rule.rb +1 -1
- data/lib/contrast/agent/assess.rb +0 -1
- data/lib/contrast/agent/excluder.rb +1 -1
- data/lib/contrast/agent/middleware.rb +12 -4
- data/lib/contrast/agent/protect/input_analyzer/input_analyzer.rb +76 -83
- data/lib/contrast/agent/protect/input_analyzer/worth_watching_analyzer.rb +121 -0
- data/lib/contrast/agent/protect/policy/applies_command_injection_rule.rb +2 -0
- data/lib/contrast/agent/protect/policy/applies_no_sqli_rule.rb +6 -3
- data/lib/contrast/agent/protect/policy/applies_path_traversal_rule.rb +3 -0
- data/lib/contrast/agent/protect/policy/applies_sqli_rule.rb +3 -0
- data/lib/contrast/agent/protect/policy/rule_applicator.rb +12 -0
- data/lib/contrast/agent/protect/rule/base.rb +21 -7
- data/lib/contrast/agent/protect/rule/base_service.rb +6 -0
- data/lib/contrast/agent/protect/rule/bot_blocker/bot_blocker_input_classification.rb +1 -1
- data/lib/contrast/agent/protect/rule/bot_blocker.rb +9 -1
- data/lib/contrast/agent/protect/rule/cmd_injection.rb +8 -7
- data/lib/contrast/agent/protect/rule/cmdi/cmdi_base_rule.rb +8 -0
- data/lib/contrast/agent/protect/rule/cmdi/cmdi_chained_command.rb +0 -5
- data/lib/contrast/agent/protect/rule/cmdi/cmdi_dangerous_path.rb +0 -5
- data/lib/contrast/agent/protect/rule/deserialization.rb +2 -2
- data/lib/contrast/agent/protect/rule/no_sqli.rb +24 -2
- data/lib/contrast/agent/protect/rule/path_traversal/path_traversal_input_classification.rb +1 -1
- data/lib/contrast/agent/protect/rule/path_traversal.rb +12 -3
- data/lib/contrast/agent/protect/rule/sqli/sqli_input_classification.rb +0 -1
- data/lib/contrast/agent/protect/rule/sqli.rb +10 -13
- data/lib/contrast/agent/protect/rule/unsafe_file_upload/unsafe_file_upload_input_classification.rb +6 -2
- data/lib/contrast/agent/protect/rule/unsafe_file_upload.rb +20 -0
- data/lib/contrast/agent/protect/rule/xss/reflected_xss_input_classification.rb +1 -1
- data/lib/contrast/agent/protect/rule/xss.rb +9 -0
- data/lib/contrast/agent/protect/rule/xxe.rb +2 -2
- data/lib/contrast/agent/protect/rule.rb +0 -3
- data/lib/contrast/agent/reporting/attack_result/rasp_rule_sample.rb +1 -1
- data/lib/contrast/agent/reporting/attack_result/user_input.rb +0 -1
- data/lib/contrast/agent/reporting/details/details.rb +0 -1
- data/lib/contrast/agent/reporting/input_analysis/input_analysis.rb +12 -0
- data/lib/contrast/agent/reporting/report.rb +2 -0
- data/lib/contrast/agent/reporting/reporter.rb +42 -7
- data/lib/contrast/agent/reporting/reporting_events/application_activity.rb +5 -6
- data/lib/contrast/agent/reporting/reporting_events/application_defend_activity.rb +24 -7
- data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_activity.rb +20 -5
- data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample.rb +0 -1
- data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample_activity.rb +5 -0
- data/lib/contrast/agent/reporting/reporting_events/application_defend_attacker_activity.rb +10 -1
- data/lib/contrast/agent/reporting/reporting_events/application_inventory.rb +2 -1
- data/lib/contrast/agent/reporting/reporting_events/application_inventory_activity.rb +6 -1
- data/lib/contrast/agent/reporting/reporting_events/application_reporting_event.rb +10 -0
- data/lib/contrast/agent/reporting/reporting_events/application_settings.rb +40 -0
- data/lib/contrast/agent/reporting/reporting_events/finding.rb +2 -2
- data/lib/contrast/agent/reporting/reporting_events/finding_event.rb +239 -93
- data/lib/contrast/agent/reporting/reporting_events/finding_event_signature.rb +10 -23
- data/lib/contrast/agent/reporting/reporting_events/finding_event_source.rb +10 -9
- data/lib/contrast/agent/reporting/reporting_events/observed_route.rb +12 -0
- data/lib/contrast/agent/reporting/reporting_events/server_reporting_event.rb +8 -0
- data/lib/contrast/agent/reporting/reporting_events/server_settings.rb +40 -0
- data/lib/contrast/agent/reporting/reporting_utilities/endpoints.rb +6 -0
- data/lib/contrast/agent/reporting/reporting_utilities/ng_response_extractor.rb +137 -0
- data/lib/contrast/agent/reporting/reporting_utilities/reporter_client.rb +52 -2
- data/lib/contrast/agent/reporting/reporting_utilities/reporter_client_utils.rb +8 -4
- data/lib/contrast/agent/reporting/reporting_utilities/response_extractor.rb +105 -58
- data/lib/contrast/agent/reporting/reporting_utilities/response_handler.rb +9 -7
- data/lib/contrast/agent/reporting/reporting_utilities/response_handler_utils.rb +143 -49
- data/lib/contrast/agent/reporting/reporting_workers/application_server_worker.rb +46 -0
- data/lib/contrast/agent/reporting/reporting_workers/reporter_heartbeat.rb +51 -0
- data/lib/contrast/agent/reporting/reporting_workers/reporting_workers.rb +14 -0
- data/lib/contrast/agent/reporting/reporting_workers/server_settings_worker.rb +46 -0
- data/lib/contrast/agent/reporting/settings/assess.rb +14 -1
- data/lib/contrast/agent/reporting/settings/assess_rule.rb +18 -0
- data/lib/contrast/agent/reporting/settings/assess_server_feature.rb +14 -2
- data/lib/contrast/agent/reporting/settings/helpers.rb +9 -0
- data/lib/contrast/agent/reporting/settings/protect.rb +17 -12
- data/lib/contrast/agent/reporting/settings/protect_rule.rb +18 -0
- data/lib/contrast/agent/reporting/settings/protect_server_feature.rb +40 -3
- data/lib/contrast/agent/reporting/settings/rule_definition.rb +3 -0
- data/lib/contrast/agent/reporting/settings/security_logger.rb +77 -0
- data/lib/contrast/agent/reporting/settings/sensitive_data_masking.rb +1 -1
- data/lib/contrast/agent/reporting/settings/server_features.rb +9 -0
- data/lib/contrast/agent/reporting/settings/syslog.rb +34 -5
- data/lib/contrast/agent/reporting/settings/virtual_patch.rb +56 -0
- data/lib/contrast/agent/reporting/settings/virtual_patch_condition.rb +47 -0
- data/lib/contrast/agent/request.rb +1 -0
- data/lib/contrast/agent/request_context_extend.rb +20 -0
- data/lib/contrast/agent/request_handler.rb +5 -10
- data/lib/contrast/agent/telemetry/base.rb +11 -10
- data/lib/contrast/agent/telemetry/events/exceptions/obfuscate.rb +108 -103
- data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exception_event.rb +1 -1
- data/lib/contrast/agent/telemetry/events/startup_metrics_event.rb +1 -1
- data/lib/contrast/agent/thread_watcher.rb +46 -6
- data/lib/contrast/agent/version.rb +1 -1
- data/lib/contrast/agent.rb +18 -0
- data/lib/contrast/agent_lib/api/init.rb +1 -7
- data/lib/contrast/agent_lib/api/input_tracing.rb +2 -4
- data/lib/contrast/agent_lib/interface.rb +1 -16
- data/lib/contrast/agent_lib/interface_base.rb +52 -39
- data/lib/contrast/agent_lib/return_types/eval_result.rb +2 -2
- data/lib/contrast/api/communication/connection_status.rb +15 -0
- data/lib/contrast/components/agent.rb +34 -0
- data/lib/contrast/components/api.rb +23 -0
- data/lib/contrast/components/app_context.rb +23 -3
- data/lib/contrast/components/assess.rb +60 -8
- data/lib/contrast/components/assess_rules.rb +18 -0
- data/lib/contrast/components/base.rb +40 -0
- data/lib/contrast/components/config/sources.rb +95 -0
- data/lib/contrast/components/config.rb +18 -1
- data/lib/contrast/components/heap_dump.rb +10 -0
- data/lib/contrast/components/inventory.rb +15 -2
- data/lib/contrast/components/logger.rb +18 -0
- data/lib/contrast/components/polling.rb +39 -0
- data/lib/contrast/components/protect.rb +48 -1
- data/lib/contrast/components/ruby_component.rb +15 -0
- data/lib/contrast/components/sampling.rb +70 -13
- data/lib/contrast/components/security_logger.rb +13 -0
- data/lib/contrast/components/settings.rb +120 -10
- data/lib/contrast/config/certification_configuration.rb +14 -0
- data/lib/contrast/config/config.rb +46 -0
- data/lib/contrast/config/diagnostics.rb +114 -0
- data/lib/contrast/config/diagnostics_tools.rb +98 -0
- data/lib/contrast/config/effective_config.rb +65 -0
- data/lib/contrast/config/effective_config_value.rb +32 -0
- data/lib/contrast/config/exception_configuration.rb +12 -0
- data/lib/contrast/config/protect_rule_configuration.rb +2 -2
- data/lib/contrast/config/protect_rules_configuration.rb +7 -6
- data/lib/contrast/config/request_audit_configuration.rb +13 -0
- data/lib/contrast/config/server_configuration.rb +41 -2
- data/lib/contrast/configuration.rb +28 -2
- data/lib/contrast/extension/assess/array.rb +3 -3
- data/lib/contrast/extension/assess/erb.rb +1 -1
- data/lib/contrast/extension/assess/regexp.rb +2 -2
- data/lib/contrast/logger/aliased_logging.rb +48 -15
- data/lib/contrast/utils/assess/event_limit_utils.rb +31 -9
- data/lib/contrast/utils/assess/trigger_method_utils.rb +5 -4
- data/lib/contrast/utils/hash_digest.rb +2 -2
- data/lib/contrast/utils/input_classification_base.rb +21 -5
- data/lib/contrast/utils/reporting/application_activity_batch_utils.rb +81 -0
- data/lib/contrast/utils/routes_sent.rb +60 -0
- data/lib/contrast/utils/telemetry.rb +1 -1
- data/lib/contrast/utils/telemetry_client.rb +2 -3
- data/lib/contrast/utils/timer.rb +16 -0
- data/lib/contrast.rb +3 -1
- data/resources/protect/policy.json +8 -0
- data/ruby-agent.gemspec +6 -2
- metadata +43 -24
- data/lib/contrast/agent/assess/contrast_event.rb +0 -157
- data/lib/contrast/agent/assess/events/event_factory.rb +0 -34
- data/lib/contrast/agent/assess/events/source_event.rb +0 -46
- data/lib/contrast/agent/protect/rule/http_method_tampering/http_method_tampering_input_classification.rb +0 -96
- data/lib/contrast/agent/protect/rule/http_method_tampering.rb +0 -83
- data/lib/contrast/agent/reporting/details/http_method_tempering_details.rb +0 -27
- data/lib/contrast/agent/reporting/reporter_heartbeat.rb +0 -53
- data/lib/contrast/agent/reporting/reporting_events/server_activity.rb +0 -36
- data/lib/contrast/agent_lib/api/method_tempering.rb +0 -29
@@ -13,33 +13,50 @@ module Contrast
|
|
13
13
|
# @return [Array<Contrast::Agent::Reporting::ApplicationDefendAttackerActivity>]
|
14
14
|
attr_reader :attackers
|
15
15
|
|
16
|
+
# @return [Boolean]
|
17
|
+
attr_reader :existing_attacker_activity
|
18
|
+
|
16
19
|
def initialize
|
17
20
|
@attackers = []
|
21
|
+
@existing_attacker_activity = false
|
18
22
|
@event_type = :application_defend_activity
|
19
23
|
end
|
20
24
|
|
21
25
|
def to_controlled_hash
|
26
|
+
validate
|
22
27
|
{
|
23
28
|
attackers: attackers.map(&:to_controlled_hash)
|
24
29
|
}
|
25
30
|
end
|
26
31
|
|
32
|
+
def validate
|
33
|
+
raise(ArgumentError, 'Attackers data must be populated') if existing_attacker_activity && attackers.empty?
|
34
|
+
end
|
35
|
+
|
27
36
|
# @param attack_result [Contrast::Agent::Reporting::AttackResult]
|
28
37
|
def attach_data attack_result
|
38
|
+
return unless attack_result&.cs__is_a?(Contrast::Agent::Reporting::AttackResult)
|
39
|
+
|
29
40
|
attacker_activity = Contrast::Agent::Reporting::ApplicationDefendAttackerActivity.new
|
30
41
|
attacker_activity.attach_data(attack_result)
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
rule = attack_result.rule_id
|
36
|
-
if existing_attacker_activity
|
37
|
-
attach_existing(existing_attacker_activity, attacker_activity, rule)
|
42
|
+
|
43
|
+
@existing_attacker_activity = true
|
44
|
+
if (existing_attacker_activity = find_existing_attacker_activity(attacker_activity))
|
45
|
+
attach_existing(existing_attacker_activity, attacker_activity, attack_result.rule_id)
|
38
46
|
else
|
39
47
|
attackers << attacker_activity
|
40
48
|
end
|
41
49
|
end
|
42
50
|
|
51
|
+
# Find an existing attacker if it matches on source details
|
52
|
+
# @param new_attacker_activity [Contrast::Agent::Reporting::ApplicationDefendAttackerActivity]
|
53
|
+
def find_existing_attacker_activity new_attacker_activity
|
54
|
+
attackers.find do |existing|
|
55
|
+
existing.source_forwarded_for == new_attacker_activity.source_forwarded_for &&
|
56
|
+
existing.source_ip == new_attacker_activity.source_ip
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
43
60
|
# @param existing_attacker_activity [Contrast::Agent::Reporting::ApplicationDefendAttackerActivity]
|
44
61
|
# @param attacker_activity [Contrast::Agent::Reporting::ApplicationDefendAttackerActivity]
|
45
62
|
# @param rule [String]
|
@@ -9,6 +9,7 @@ module Contrast
|
|
9
9
|
module Reporting
|
10
10
|
# This is the new ApplicationDefendAttackActivity class which will include the attacks sent by the source.
|
11
11
|
class ApplicationDefendAttackActivity
|
12
|
+
include Contrast::Components::Logger::InstanceMethods
|
12
13
|
# @return [Contrast::Agent::Reporting::ApplicationDefendAttackSampleActivity]
|
13
14
|
attr_accessor :blocked
|
14
15
|
# @return [Contrast::Agent::Reporting::ApplicationDefendAttackSampleActivity]
|
@@ -27,15 +28,29 @@ module Contrast
|
|
27
28
|
end
|
28
29
|
|
29
30
|
def to_controlled_hash
|
31
|
+
blocked_hash = blocked&.to_controlled_hash || Contrast::Utils::ObjectShare::EMPTY_HASH
|
32
|
+
exploited_hash = exploited&.to_controlled_hash || Contrast::Utils::ObjectShare::EMPTY_HASH
|
33
|
+
ineffective_hash = ineffective&.to_controlled_hash || Contrast::Utils::ObjectShare::EMPTY_HASH
|
34
|
+
suspicious_hash = suspicious&.to_controlled_hash || Contrast::Utils::ObjectShare::EMPTY_HASH
|
35
|
+
validate(blocked_hash, exploited_hash, ineffective_hash, suspicious_hash)
|
36
|
+
|
30
37
|
{
|
31
38
|
startTime: @start_time,
|
32
|
-
blocked:
|
33
|
-
exploited:
|
34
|
-
ineffective:
|
35
|
-
suspicious:
|
39
|
+
blocked: blocked_hash,
|
40
|
+
exploited: exploited_hash,
|
41
|
+
ineffective: ineffective_hash,
|
42
|
+
suspicious: suspicious_hash
|
36
43
|
}
|
37
44
|
end
|
38
45
|
|
46
|
+
def validate blocked_hash, exploited_hash, ineffective_hash, suspicious_hash
|
47
|
+
return unless [blocked_hash, exploited_hash, ineffective_hash, suspicious_hash].all?(&:empty?)
|
48
|
+
|
49
|
+
raise(ArgumentError, 'Start Time for is not presented') unless start_time
|
50
|
+
|
51
|
+
raise(ArgumentError, 'At least one of the samples must be populated')
|
52
|
+
end
|
53
|
+
|
39
54
|
# @param attack_result [Contrast::Agent::Reporting::AttackResult]
|
40
55
|
# @return [Contrast::Agent::Reporting::Defend::AttackSampleActivity]
|
41
56
|
def attach_data attack_result
|
@@ -57,7 +72,7 @@ module Contrast
|
|
57
72
|
end
|
58
73
|
|
59
74
|
def start_time
|
60
|
-
Contrast::Agent::REQUEST_TRACKER.current&.timer&.start_ms
|
75
|
+
Contrast::Agent::REQUEST_TRACKER.current&.timer&.start_ms || 0
|
61
76
|
end
|
62
77
|
end
|
63
78
|
end
|
@@ -3,7 +3,6 @@
|
|
3
3
|
|
4
4
|
require 'contrast/agent/protect/rule/cmd_injection'
|
5
5
|
require 'contrast/agent/protect/rule/deserialization'
|
6
|
-
require 'contrast/agent/protect/rule/http_method_tampering'
|
7
6
|
require 'contrast/agent/protect/rule/no_sqli'
|
8
7
|
require 'contrast/agent/reporting/attack_result/user_input'
|
9
8
|
require 'contrast/agent/reporting/attack_result/response_type'
|
data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample_activity.rb
CHANGED
@@ -24,6 +24,7 @@ module Contrast
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def to_controlled_hash
|
27
|
+
validate
|
27
28
|
{
|
28
29
|
attackTimeMap: time_map,
|
29
30
|
samples: samples.map(&:to_controlled_hash),
|
@@ -32,6 +33,10 @@ module Contrast
|
|
32
33
|
}
|
33
34
|
end
|
34
35
|
|
36
|
+
def validate
|
37
|
+
raise(ArgumentError, 'Start Time is not presented') unless @start_time
|
38
|
+
end
|
39
|
+
|
35
40
|
# @param attack_result [Contrast::Agent::Reporting::AttackResult]
|
36
41
|
def attach_data attack_result
|
37
42
|
attack_result.samples.each do |attack_sample|
|
@@ -11,6 +11,7 @@ module Contrast
|
|
11
11
|
# This is the new AttackerActivity class which will includes the attacker information discovered during this
|
12
12
|
# activity period.
|
13
13
|
class ApplicationDefendAttackerActivity
|
14
|
+
include Contrast::Components::Logger::InstanceMethods
|
14
15
|
# @return [Hash<String,Contrast::Agent::Reporting::ApplicationDefendAttackActivity>] map of rule-id to violated
|
15
16
|
# samples for that rule
|
16
17
|
attr_accessor :protection_rules
|
@@ -32,8 +33,11 @@ module Contrast
|
|
32
33
|
end
|
33
34
|
|
34
35
|
def to_controlled_hash
|
36
|
+
processed_rules = process_protection_rules
|
37
|
+
validate(processed_rules)
|
38
|
+
|
35
39
|
{
|
36
|
-
protectionRules:
|
40
|
+
protectionRules: processed_rules,
|
37
41
|
source: {
|
38
42
|
ip: source_ip,
|
39
43
|
xForwardedFor: source_forwarded_for
|
@@ -41,6 +45,11 @@ module Contrast
|
|
41
45
|
}
|
42
46
|
end
|
43
47
|
|
48
|
+
def validate processed_rules
|
49
|
+
raise(ArgumentError, 'Protection Rules are not presented') if processed_rules.empty?
|
50
|
+
raise(ArgumentError, 'Source is not presented') unless source_ip
|
51
|
+
end
|
52
|
+
|
44
53
|
# @param attack_result [Contrast::Agent::Reporting::AttackResult]
|
45
54
|
def attach_data attack_result
|
46
55
|
@protection_rules[attack_result.rule_id] = Contrast::Agent::Reporting::ApplicationDefendAttackActivity.new.
|
@@ -22,7 +22,7 @@ module Contrast
|
|
22
22
|
@event_method = :POST
|
23
23
|
@event_endpoint = Contrast::Agent::Reporting::Endpoints.application_inventory
|
24
24
|
# The API spec limits us to 500 routes, so we'll enforce that here to not hold on to superfulous data.
|
25
|
-
@routes = Contrast::Agent.framework_manager.find_route_discovery_data
|
25
|
+
@routes = Contrast::Agent.framework_manager.find_route_discovery_data&.take(500)
|
26
26
|
super
|
27
27
|
end
|
28
28
|
|
@@ -33,6 +33,7 @@ module Contrast
|
|
33
33
|
def to_controlled_hash
|
34
34
|
{
|
35
35
|
session_id: ::Contrast::ASSESS.session_id,
|
36
|
+
# documentation lists routes as deprecated from the agent_ng_endpoints.yml
|
36
37
|
routes: routes.map(&:to_controlled_hash)
|
37
38
|
}
|
38
39
|
end
|
@@ -13,7 +13,7 @@ module Contrast
|
|
13
13
|
# about the inventory of the application which was discovered during exercise of the application
|
14
14
|
# during this activity period.
|
15
15
|
class ApplicationInventoryActivity < Contrast::Agent::Reporting::ApplicationReportingEvent
|
16
|
-
# return [Contrast::Agent::Reporting::ArchitectureComponent]
|
16
|
+
# return [Array<Contrast::Agent::Reporting::ArchitectureComponent>]
|
17
17
|
attr_reader :components
|
18
18
|
# @ return [Array<String>, nil] - User-Agent Header value
|
19
19
|
attr_reader :browsers
|
@@ -46,6 +46,11 @@ module Contrast
|
|
46
46
|
def duration
|
47
47
|
Contrast::Utils::Timer.now_ms - (Contrast::Agent::REQUEST_TRACKER.current&.timer&.start_ms || 0)
|
48
48
|
end
|
49
|
+
|
50
|
+
# Helper method to determine if InventoryActivity has no data
|
51
|
+
def empty?
|
52
|
+
@browsers.empty? && @components.empty?
|
53
|
+
end
|
49
54
|
end
|
50
55
|
end
|
51
56
|
end
|
@@ -17,10 +17,20 @@ module Contrast
|
|
17
17
|
# The timestamp field is a bit of a misnomer. It's really the time, in ms, since the settings for this
|
18
18
|
# application have been updated. If I've never updated, then it's been 0ms since then.
|
19
19
|
#
|
20
|
+
#
|
20
21
|
# @return [Integer]
|
21
22
|
def since_last_update
|
22
23
|
(update_time = Contrast::SETTINGS.last_app_update_ms) ? Contrast::Utils::Timer.now_ms - update_time : 0
|
23
24
|
end
|
25
|
+
|
26
|
+
# Human readable last time update for header set. Set to 0 if the agent is just starting and have not received
|
27
|
+
# the latest header from TS.
|
28
|
+
#
|
29
|
+
#
|
30
|
+
# @return [String]
|
31
|
+
def since_last_update_httpdate
|
32
|
+
Contrast::SETTINGS.app_settings_last_httpdate || Contrast::Utils::Timer.ms_to_httpdate(0)
|
33
|
+
end
|
24
34
|
end
|
25
35
|
end
|
26
36
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'contrast/agent/reporting/reporting_events/application_reporting_event'
|
5
|
+
require 'contrast/agent/reporting/reporting_utilities/endpoints'
|
6
|
+
require 'contrast/utils/timer'
|
7
|
+
|
8
|
+
module Contrast
|
9
|
+
module Agent
|
10
|
+
module Reporting
|
11
|
+
# This class will initialize a GET request to be send to TS. The application settings endpoint is the way
|
12
|
+
# the Agent receives application sittings
|
13
|
+
class ApplicationSettings < Contrast::Agent::Reporting::ApplicationReportingEvent
|
14
|
+
def initialize
|
15
|
+
@event_method = :GET
|
16
|
+
@event_endpoint = Contrast::Agent::Reporting::Endpoints.application_settings
|
17
|
+
super
|
18
|
+
end
|
19
|
+
|
20
|
+
def file_name
|
21
|
+
'application-settings'
|
22
|
+
end
|
23
|
+
|
24
|
+
# Attach the last server settings received timestamp to the request as it is required.
|
25
|
+
#
|
26
|
+
# If-Modified-Since: <day-name>, <day> <month> <year> <hour>:<minute>:<second> GMT
|
27
|
+
# @param request [Net::HTTPRequest]
|
28
|
+
def attach_headers request
|
29
|
+
request['If-Modified-Since'] = since_last_update_httpdate
|
30
|
+
end
|
31
|
+
|
32
|
+
# @return [Hash]
|
33
|
+
# @raise [ArgumentError]
|
34
|
+
def to_controlled_hash
|
35
|
+
{}
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -88,8 +88,8 @@ module Contrast
|
|
88
88
|
event_messages = Contrast::Agent::Reporting::FindingEvent.from_source(source)
|
89
89
|
events.concat(event_messages) if event_messages&.any?
|
90
90
|
event_data = Contrast::Agent::Assess::Events::EventData.new(trigger_node, source, object, ret, args)
|
91
|
-
contrast_event = Contrast::Agent::
|
92
|
-
events <<
|
91
|
+
contrast_event = Contrast::Agent::Reporting::FindingEvent.new(event_data)
|
92
|
+
events << contrast_event
|
93
93
|
return unless request
|
94
94
|
|
95
95
|
@request = Contrast::Agent::Reporting::FindingRequest.convert(request)
|