Module: Contrast::Agent

Defined in:
lib/contrast/agent.rb,
lib/contrast/agent/version.rb,
lib/contrast/agent/assess/tag.rb,
lib/contrast/agent/scope/scope.rb,
lib/contrast/agent/protect/rule.rb,
lib/contrast/agent/assess/assess.rb,
lib/contrast/agent/protect/state.rb,
lib/contrast/agent/thread/thread.rb,
lib/contrast/components/rule_set.rb,
lib/contrast/agent/assess/tracker.rb,
lib/contrast/agent/telemetry/base.rb,
lib/contrast/agent/request/request.rb,
lib/contrast/agent/telemetry/event.rb,
lib/contrast/agent/reporting/report.rb,
lib/contrast/agent/telemetry/client.rb,
lib/contrast/agent/assess/properties.rb,
lib/contrast/agent/excluder/excluder.rb,
lib/contrast/agent/protect/rule/base.rb,
lib/contrast/agent/response/response.rb,
lib/contrast/agent/assess/module_data.rb,
lib/contrast/agent/hooks/at_exit_hook.rb,
lib/contrast/agent/reporting/reporter.rb,
lib/contrast/agent/inventory/inventory.rb,
lib/contrast/agent/telemetry/exception.rb,
lib/contrast/agent/telemetry/telemetry.rb,
lib/contrast/agent/assess/policy/policy.rb,
lib/contrast/agent/assess/rule/provider.rb,
lib/contrast/agent/protect/rule/xss/xss.rb,
lib/contrast/agent/protect/rule/xxe/xxe.rb,
lib/contrast/agent/telemetry/cache_hash.rb,
lib/contrast/agent/telemetry/identifier.rb,
lib/contrast/agent/thread/worker_thread.rb,
lib/contrast/agent/assess/policy/patcher.rb,
lib/contrast/agent/hooks/tracepoint_hook.rb,
lib/contrast/agent/middleware/middleware.rb,
lib/contrast/agent/patching/policy/patch.rb,
lib/contrast/agent/protect/policy/policy.rb,
lib/contrast/agent/telemetry/base64_hash.rb,
lib/contrast/agent/thread/thread_watcher.rb,
lib/contrast/agent/assess/contrast_object.rb,
lib/contrast/agent/assess/finalizers/hash.rb,
lib/contrast/agent/assess/policy/preshift.rb,
lib/contrast/agent/assess/property/tagged.rb,
lib/contrast/agent/deadzone/policy/policy.rb,
lib/contrast/agent/inventory/dependencies.rb,
lib/contrast/agent/patching/policy/policy.rb,
lib/contrast/agent/protect/rule/sqli/sqli.rb,
lib/contrast/agent/telemetry/metric_event.rb,
lib/contrast/agent/assess/property/evented.rb,
lib/contrast/agent/assess/property/updated.rb,
lib/contrast/agent/inventory/policy/policy.rb,
lib/contrast/agent/patching/policy/patcher.rb,
lib/contrast/agent/reporting/masker/masker.rb,
lib/contrast/agent/request/request_context.rb,
lib/contrast/agent/request/request_handler.rb,
lib/contrast/agent/assess/events/event_data.rb,
lib/contrast/agent/assess/policy/propagator.rb,
lib/contrast/agent/telemetry/exception/base.rb,
lib/contrast/agent/telemetry/exception_hash.rb,
lib/contrast/agent/assess/policy/policy_node.rb,
lib/contrast/agent/assess/policy/source_node.rb,
lib/contrast/agent/inventory/database_config.rb,
lib/contrast/agent/reporting/settings/assess.rb,
lib/contrast/agent/reporting/settings/syslog.rb,
lib/contrast/agent/telemetry/exception/event.rb,
lib/contrast/agent/assess/policy/trigger_node.rb,
lib/contrast/agent/excluder/exclusion_matcher.rb,
lib/contrast/agent/middleware/static_analysis.rb,
lib/contrast/agent/protect/rule/utils/filters.rb,
lib/contrast/agent/reactions/disable_reaction.rb,
lib/contrast/agent/reporting/client/interface.rb,
lib/contrast/agent/reporting/settings/helpers.rb,
lib/contrast/agent/reporting/settings/keyword.rb,
lib/contrast/agent/reporting/settings/protect.rb,
lib/contrast/agent/assess/policy/source_method.rb,
lib/contrast/agent/assess/policy/trigger/xpath.rb,
lib/contrast/agent/inventory/policy/datastores.rb,
lib/contrast/agent/patching/policy/policy_node.rb,
lib/contrast/agent/protect/policy/trigger_node.rb,
lib/contrast/agent/protect/rule/utils/builders.rb,
lib/contrast/agent/reporting/connection_status.rb,
lib/contrast/agent/reporting/details/xss_match.rb,
lib/contrast/agent/reporting/details/xxe_match.rb,
lib/contrast/agent/reporting/settings/reaction.rb,
lib/contrast/agent/reporting/settings/sampling.rb,
lib/contrast/agent/telemetry/exception/message.rb,
lib/contrast/agent/assess/policy/policy_scanner.rb,
lib/contrast/agent/assess/policy/trigger_method.rb,
lib/contrast/agent/patching/policy/patch_status.rb,
lib/contrast/agent/patching/policy/trigger_node.rb,
lib/contrast/agent/protect/rule/no_sqli/no_sqli.rb,
lib/contrast/agent/reporting/settings/ip_filter.rb,
lib/contrast/agent/reporting/settings/sanitizer.rb,
lib/contrast/agent/reporting/settings/validator.rb,
lib/contrast/agent/assess/policy/propagator/base.rb,
lib/contrast/agent/assess/policy/propagator/keep.rb,
lib/contrast/agent/assess/policy/propagator/next.rb,
lib/contrast/agent/assess/policy/propagator/trim.rb,
lib/contrast/agent/deadzone/policy/deadzone_node.rb,
lib/contrast/agent/inventory/dependency_analysis.rb,
lib/contrast/agent/inventory/policy/trigger_node.rb,
lib/contrast/agent/patching/policy/method_policy.rb,
lib/contrast/agent/patching/policy/module_policy.rb,
lib/contrast/agent/reporting/details/xss_details.rb,
lib/contrast/agent/reporting/details/xxe_details.rb,
lib/contrast/agent/reporting/details/xxe_wrapper.rb,
lib/contrast/agent/reporting/masker/masker_utils.rb,
lib/contrast/agent/reporting/settings/exclusions.rb,
lib/contrast/agent/telemetry/exception/obfuscate.rb,
lib/contrast/agent/assess/policy/propagation_node.rb,
lib/contrast/agent/assess/policy/propagator/splat.rb,
lib/contrast/agent/assess/policy/propagator/split.rb,
lib/contrast/agent/assess/rule/response/base_rule.rb,
lib/contrast/agent/assess/rule/response/body_rule.rb,
lib/contrast/agent/protect/exploitable_collection.rb,
lib/contrast/agent/protect/policy/rule_applicator.rb,
lib/contrast/agent/reporting/details/sqli_details.rb,
lib/contrast/agent/reporting/settings/assess_rule.rb,
lib/contrast/agent/reporting/settings/bot_blocker.rb,
lib/contrast/agent/request/request_context_extend.rb,
lib/contrast/agent/telemetry/input_analysis_event.rb,
lib/contrast/agent/assess/policy/policy_node_utils.rb,
lib/contrast/agent/assess/policy/propagator/append.rb,
lib/contrast/agent/assess/policy/propagator/buffer.rb,
lib/contrast/agent/assess/policy/propagator/center.rb,
lib/contrast/agent/assess/policy/propagator/custom.rb,
lib/contrast/agent/assess/policy/propagator/insert.rb,
lib/contrast/agent/assess/policy/propagator/remove.rb,
lib/contrast/agent/assess/policy/propagator/select.rb,
lib/contrast/agent/protect/policy/applies_xxe_rule.rb,
lib/contrast/agent/protect/rule/cmdi/cmd_injection.rb,
lib/contrast/agent/protect/rule/xxe/entity_wrapper.rb,
lib/contrast/agent/reporting/client/interface_base.rb,
lib/contrast/agent/reporting/reporting_events/poll.rb,
lib/contrast/agent/reporting/settings/log_enhancer.rb,
lib/contrast/agent/reporting/settings/protect_rule.rb,
lib/contrast/agent/telemetry/exception/stack_frame.rb,
lib/contrast/agent/telemetry/startup_metrics_event.rb,
lib/contrast/agent/assess/policy/propagation_method.rb,
lib/contrast/agent/assess/policy/propagator/prepend.rb,
lib/contrast/agent/assess/policy/propagator/replace.rb,
lib/contrast/agent/assess/policy/propagator/reverse.rb,
lib/contrast/agent/assess/rule/response/header_rule.rb,
lib/contrast/agent/patching/policy/after_load_patch.rb,
lib/contrast/agent/protect/policy/applies_sqli_rule.rb,
lib/contrast/agent/protect/rule/cmdi/cmdi_backdoors.rb,
lib/contrast/agent/protect/rule/cmdi/cmdi_base_rule.rb,
lib/contrast/agent/protect/rule/sqli/sqli_base_rule.rb,
lib/contrast/agent/reporting/settings/url_exclusion.rb,
lib/contrast/agent/reporting/settings/virtual_patch.rb,
lib/contrast/agent/assess/policy/propagator/response.rb,
lib/contrast/agent/reporting/details/no_sqli_details.rb,
lib/contrast/agent/reporting/settings/exclusion_base.rb,
lib/contrast/agent/assess/rule/provider/hardcoded_key.rb,
lib/contrast/agent/patching/policy/after_load_patcher.rb,
lib/contrast/agent/reporting/attack_result/user_input.rb,
lib/contrast/agent/reporting/reporting_events/finding.rb,
lib/contrast/agent/reporting/settings/input_exclusion.rb,
lib/contrast/agent/reporting/settings/rule_definition.rb,
lib/contrast/agent/reporting/settings/security_logger.rb,
lib/contrast/agent/reporting/settings/server_features.rb,
lib/contrast/agent/assess/policy/propagator/match_data.rb,
lib/contrast/agent/assess/policy/trigger/reflected_xss.rb,
lib/contrast/agent/inventory/dependency_usage_analysis.rb,
lib/contrast/agent/protect/policy/applies_no_sqli_rule.rb,
lib/contrast/agent/reporting/input_analysis/input_type.rb,
lib/contrast/agent/reporting/reporting_utilities/audit.rb,
lib/contrast/agent/assess/policy/dynamic_source_factory.rb,
lib/contrast/agent/patching/policy/method_policy_extend.rb,
lib/contrast/agent/protect/rule/bot_blocker/bot_blocker.rb,
lib/contrast/agent/protect/rule/sqli/sql_sample_builder.rb,
lib/contrast/agent/protect/rule/sqli/sqlite_sql_scanner.rb,
lib/contrast/agent/reporting/input_analysis/score_level.rb,
lib/contrast/agent/reporting/reporting_events/preflight.rb,
lib/contrast/agent/reporting/reporting_utilities/resend.rb,
lib/contrast/agent/telemetry/input_analysis_cache_event.rb,
lib/contrast/agent/assess/policy/propagator/substitution.rb,
lib/contrast/agent/assess/rule/response/hsts_header_rule.rb,
lib/contrast/agent/protect/input_analyzer/input_analyzer.rb,
lib/contrast/agent/protect/rule/cmdi/cmdi_dangerous_path.rb,
lib/contrast/agent/protect/rule/sqli/default_sql_scanner.rb,
lib/contrast/agent/reporting/attack_result/attack_result.rb,
lib/contrast/agent/reporting/attack_result/response_type.rb,
lib/contrast/agent/reporting/details/bot_blocker_details.rb,
lib/contrast/agent/reporting/details/ip_denylist_details.rb,
lib/contrast/agent/reporting/reporting_utilities/headers.rb,
lib/contrast/agent/telemetry/exception/message_exception.rb,
lib/contrast/agent/protect/rule/cmdi/cmdi_chained_command.rb,
lib/contrast/agent/protect/rule/input_classification/base.rb,
lib/contrast/agent/protect/rule/sqli/postgres_sql_scanner.rb,
lib/contrast/agent/reporting/details/protect_rule_details.rb,
lib/contrast/agent/reporting/reporting_utilities/response.rb,
lib/contrast/agent/assess/policy/propagator/database_write.rb,
lib/contrast/agent/assess/rule/provider/hardcoded_password.rb,
lib/contrast/agent/assess/rule/response/auto_complete_rule.rb,
lib/contrast/agent/protect/rule/input_classification/rates.rb,
lib/contrast/agent/protect/rule/input_classification/utils.rb,
lib/contrast/agent/reporting/details/cmd_injection_details.rb,
lib/contrast/agent/reporting/details/virtual_patch_details.rb,
lib/contrast/agent/reporting/input_analysis/input_analysis.rb,
lib/contrast/agent/reporting/reporting_utilities/endpoints.rb,
lib/contrast/agent/reporting/settings/application_settings.rb,
lib/contrast/agent/telemetry/input_analysis_encoding_event.rb,
lib/contrast/agent/assess/policy/propagator/rack_protection.rb,
lib/contrast/agent/reporting/attack_result/rasp_rule_sample.rb,
lib/contrast/agent/reporting/details/path_traversal_details.rb,
lib/contrast/agent/reporting/reporting_events/agent_startup.rb,
lib/contrast/agent/reporting/reporting_events/finding_event.rb,
lib/contrast/agent/reporting/settings/assess_server_feature.rb,
lib/contrast/agent/assess/rule/provider/hardcoded_value_rule.rb,
lib/contrast/agent/protect/rule/no_sqli/mongo_no_sql_scanner.rb,
lib/contrast/agent/reporting/reporting_events/observed_route.rb,
lib/contrast/agent/reporting/reporting_events/route_coverage.rb,
lib/contrast/agent/reporting/settings/protect_server_feature.rb,
lib/contrast/agent/reporting/settings/sensitive_data_masking.rb,
lib/contrast/agent/protect/policy/applies_path_traversal_rule.rb,
lib/contrast/agent/protect/rule/input_classification/encoding.rb,
lib/contrast/agent/protect/rule/path_traversal/path_traversal.rb,
lib/contrast/agent/reporting/details/sqli_dangerous_functions.rb,
lib/contrast/agent/reporting/reporting_events/finding_request.rb,
lib/contrast/agent/reporting/reporting_events/reportable_hash.rb,
lib/contrast/agent/reporting/reporting_events/reporting_event.rb,
lib/contrast/agent/reporting/reporting_events/route_discovery.rb,
lib/contrast/agent/reporting/reporting_events/server_settings.rb,
lib/contrast/agent/reporting/settings/virtual_patch_condition.rb,
lib/contrast/agent/assess/policy/propagator/substitution_utils.rb,
lib/contrast/agent/protect/policy/applies_deserialization_rule.rb,
lib/contrast/agent/protect/rule/cmdi/cmdi_input_classification.rb,
lib/contrast/agent/protect/rule/input_classification/lru_cache.rb,
lib/contrast/agent/protect/rule/sqli/sqli_input_classification.rb,
lib/contrast/agent/reporting/reporting_events/discovered_route.rb,
lib/contrast/agent/assess/rule/response/csp_header_missing_rule.rb,
lib/contrast/agent/assess/rule/response/framework/rails_support.rb,
lib/contrast/agent/protect/rule/deserialization/deserialization.rb,
lib/contrast/agent/protect/rule/input_classification/extendable.rb,
lib/contrast/agent/protect/rule/input_classification/statistics.rb,
lib/contrast/agent/reporting/reporting_events/library_discovery.rb,
lib/contrast/agent/reporting/reporting_events/preflight_message.rb,
lib/contrast/agent/assess/rule/response/csp_header_insecure_rule.rb,
lib/contrast/agent/protect/policy/applies_command_injection_rule.rb,
lib/contrast/agent/protect/rule/input_classification/match_rates.rb,
lib/contrast/agent/reporting/reporting_events/application_update.rb,
lib/contrast/agent/reporting/reporting_utilities/build_preflight.rb,
lib/contrast/agent/reporting/reporting_utilities/reporter_client.rb,
lib/contrast/agent/reporting/reporting_workers/reporting_workers.rb,
lib/contrast/agent/assess/policy/trigger_validation/xss_validator.rb,
lib/contrast/agent/assess/rule/response/cache_control_header_rule.rb,
lib/contrast/agent/assess/rule/response/click_jacking_header_rule.rb,
lib/contrast/agent/assess/rule/response/parameters_pollution_rule.rb,
lib/contrast/agent/protect/input_analyzer/worth_watching_analyzer.rb,
lib/contrast/agent/reporting/input_analysis/input_analysis_result.rb,
lib/contrast/agent/reporting/reporting_events/application_startup.rb,
lib/contrast/agent/reporting/reporting_events/finding_event_stack.rb,
lib/contrast/agent/reporting/reporting_utilities/response_handler.rb,
lib/contrast/agent/reporting/reporting_workers/reporter_heartbeat.rb,
lib/contrast/agent/reporting/settings/sensitive_data_masking_rule.rb,
lib/contrast/agent/assess/policy/trigger_validation/ssrf_validator.rb,
lib/contrast/agent/assess/rule/response/x_content_type_header_rule.rb,
lib/contrast/agent/protect/rule/input_classification/cached_result.rb,
lib/contrast/agent/reporting/reporting_events/application_activity.rb,
lib/contrast/agent/reporting/reporting_events/application_settings.rb,
lib/contrast/agent/reporting/reporting_events/finding_event_object.rb,
lib/contrast/agent/reporting/reporting_events/finding_event_source.rb,
lib/contrast/agent/reporting/reporting_utilities/reporting_storage.rb,
lib/contrast/agent/assess/policy/trigger_validation/redos_validator.rb,
lib/contrast/agent/protect/rule/input_classification/encoding_rates.rb,
lib/contrast/agent/reporting/reporting_events/application_inventory.rb,
lib/contrast/agent/reporting/reporting_utilities/response_extractor.rb,
lib/contrast/agent/assess/policy/source_validation/source_validation.rb,
lib/contrast/agent/assess/rule/response/x_xss_protection_header_rule.rb,
lib/contrast/agent/protect/rule/no_sqli/no_sqli_input_classification.rb,
lib/contrast/agent/reporting/reporting_events/agent_effective_config.rb,
lib/contrast/agent/reporting/reporting_events/architecture_component.rb,
lib/contrast/agent/reporting/reporting_events/finding_event_property.rb,
lib/contrast/agent/reporting/reporting_events/observed_library_usage.rb,
lib/contrast/agent/reporting/reporting_events/server_reporting_event.rb,
lib/contrast/agent/protect/rule/input_classification/base64_statistic.rb,
lib/contrast/agent/protect/rule/unsafe_file_upload/unsafe_file_upload.rb,
lib/contrast/agent/reporting/reporting_events/finding_event_signature.rb,
lib/contrast/agent/reporting/reporting_workers/server_settings_worker.rb,
lib/contrast/agent/assess/policy/trigger_validation/trigger_validation.rb,
lib/contrast/agent/protect/rule/xss/reflected_xss_input_classification.rb,
lib/contrast/agent/reporting/details/untrusted_deserialization_details.rb,
lib/contrast/agent/reporting/reporting_utilities/ng_response_extractor.rb,
lib/contrast/agent/reporting/reporting_utilities/reporter_client_utils.rb,
lib/contrast/agent/reporting/reporting_utilities/response_handler_mode.rb,
lib/contrast/agent/assess/policy/source_validation/cross_site_validator.rb,
lib/contrast/agent/reporting/reporting_events/finding_event_taint_range.rb,
lib/contrast/agent/reporting/reporting_events/library_usage_observation.rb,
lib/contrast/agent/reporting/reporting_utilities/response_handler_utils.rb,
lib/contrast/agent/reporting/input_analysis/details/protect_rule_details.rb,
lib/contrast/agent/reporting/reporting_workers/application_server_worker.rb,
lib/contrast/agent/reporting/reporting_events/application_defend_activity.rb,
lib/contrast/agent/reporting/reporting_events/application_reporting_event.rb,
lib/contrast/agent/reporting/reporting_events/finding_event_parent_object.rb,
lib/contrast/agent/reporting/reporting_events/route_discovery_observation.rb,
lib/contrast/agent/protect/rule/sqli/sqli_semantic/sqli_dangerous_functions.rb,
lib/contrast/agent/protect/rule/bot_blocker/bot_blocker_input_classification.rb,
lib/contrast/agent/reporting/reporting_events/application_inventory_activity.rb,
lib/contrast/agent/reporting/reporting_events/finding_event_taint_range_tags.rb,
lib/contrast/agent/reporting/details/path_traversal_semantic_analysis_details.rb,
lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample.rb,
lib/contrast/agent/reporting/reporting_events/application_defend_attack_activity.rb,
lib/contrast/agent/reporting/reporting_events/application_startup_instrumentation.rb,
lib/contrast/agent/protect/rule/path_traversal/path_traversal_input_classification.rb,
lib/contrast/agent/reporting/reporting_events/application_defend_attacker_activity.rb,
lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample_stack.rb,
lib/contrast/agent/protect/rule/path_traversal/path_traversal_semantic_security_bypass.rb,
lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample_activity.rb,
lib/contrast/agent/protect/rule/unsafe_file_upload/unsafe_file_upload_input_classification.rb,
ext/cs__scope/cs__scope.c,
ext/cs__common/cs__common.c

Overview

Top namespace of the Agent section. Holds tracking contexts that will be accessed throughout the Agent.

Defined Under Namespace

Modules: Assess, AtExitHook, Deadzone, DisableReaction, Inventory, Patching, Protect, Reporting, ReportingWorkers, RequestContextExtend, Telemetry, TracePointHook Classes: Excluder, ExclusionMatcher, Middleware, ModuleData, Reporter, Request, RequestContext, RequestHandler, Response, RuleSet, Scope, StaticAnalysis, Thread, ThreadWatcher, WorkerThread

Constant Summary collapse

REQUEST_TRACKER =

build a map for tracking the context of the current request

Contrast::Utils::ThreadTracker.new
FINDINGS =
Contrast::Utils::Findings.new
EXPLOITS =
Contrast::Agent::Protect::ExploitableCollection.new
VERSION =
'7.6.1'

Class Method Summary collapse

Class Method Details

.framework_managerContrast::Framework::Manager



58
59
60
61
# File 'lib/contrast/agent.rb', line 58

def self.framework_manager
  reinitialize_with_log
  @_framework_manager ||= Contrast::Framework::Manager.new
end

.heapdump_utilnil, Contrast::Utils::HeapDumpUtil



64
65
66
# File 'lib/contrast/agent.rb', line 64

def self.heapdump_util
  thread_watcher.heapdump_util
end

.reinitialize_with_logObject

Apparently by some unknown reason - if we have already some instance for the AgentLib - we can set the logger with options. That’s why in rspec it started passing - because when we set the const in protect_spec_helper in the with AgentLib context - we’ve already set the AGENT_LIB constant.

So that leads to this methods logic here, which somehow works



93
94
95
96
97
98
99
100
# File 'lib/contrast/agent.rb', line 93

def self.reinitialize_with_log
  return if Contrast::AGENT_LIB.enable_log

  # Silence warning about reinit AgentLib
  Contrast::Utils::SilenceMaker.hush do
    Contrast.cs__const_set(:AGENT_LIB, Contrast::AgentLib::Interface.new(true, 2, nil))
  end
end

.reporterContrast::Agent::Reporter



74
75
76
# File 'lib/contrast/agent.rb', line 74

def self.reporter
  thread_watcher.reporter
end

.telemetry_queuenil, Contrast::Agent::Telemetry::Base



69
70
71
# File 'lib/contrast/agent.rb', line 69

def self.telemetry_queue
  thread_watcher.telemetry_queue
end

.thread_watcherContrast::Agent::ThreadWatcher



84
85
86
# File 'lib/contrast/agent.rb', line 84

def self.thread_watcher
  @_thread_watcher ||= Contrast::Agent::ThreadWatcher.new
end

.worth_watching_analyzerContrast::Agent::Protect::WorthWatchingAnalyzer

Returns:

  • (Contrast::Agent::Protect::WorthWatchingAnalyzer)


79
80
81
# File 'lib/contrast/agent.rb', line 79

def self.worth_watching_analyzer
  thread_watcher.worth_watching_analyzer
end