contrast-agent 6.10.0 → 6.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.simplecov +1 -1
- data/Gemfile +1 -1
- data/Rakefile +1 -1
- data/ext/build_funchook.rb +2 -2
- data/ext/cs__assess_array/cs__assess_array.c +24 -18
- data/ext/cs__assess_array/extconf.rb +1 -1
- data/ext/cs__assess_basic_object/cs__assess_basic_object.c +1 -1
- data/ext/cs__assess_basic_object/extconf.rb +1 -1
- data/ext/cs__assess_fiber_track/cs__assess_fiber_track.c +1 -1
- data/ext/cs__assess_fiber_track/extconf.rb +1 -1
- data/ext/cs__assess_hash/cs__assess_hash.c +1 -1
- data/ext/cs__assess_hash/extconf.rb +1 -1
- data/ext/cs__assess_kernel/cs__assess_kernel.c +1 -1
- data/ext/cs__assess_kernel/extconf.rb +1 -1
- data/ext/cs__assess_marshal_module/cs__assess_marshal_module.c +7 -5
- data/ext/cs__assess_marshal_module/extconf.rb +1 -1
- data/ext/cs__assess_module/cs__assess_module.c +1 -1
- data/ext/cs__assess_module/extconf.rb +1 -1
- data/ext/cs__assess_regexp/cs__assess_regexp.c +1 -1
- data/ext/cs__assess_regexp/extconf.rb +1 -1
- data/ext/cs__assess_string/cs__assess_string.c +1 -1
- data/ext/cs__assess_string/extconf.rb +1 -1
- data/ext/cs__assess_string_interpolation/cs__assess_string_interpolation.c +1 -1
- data/ext/cs__assess_string_interpolation/extconf.rb +1 -1
- data/ext/cs__assess_test/extconf.rb +1 -1
- data/ext/cs__assess_yield_track/cs__assess_yield_track.c +1 -1
- data/ext/cs__assess_yield_track/extconf.rb +1 -1
- data/ext/cs__common/cs__common.c +1 -1
- data/ext/cs__common/extconf.rb +1 -1
- data/ext/cs__contrast_patch/cs__contrast_patch.c +12 -10
- data/ext/cs__contrast_patch/extconf.rb +1 -1
- data/ext/cs__os_information/cs__os_information.c +1 -1
- data/ext/cs__os_information/extconf.rb +1 -1
- data/ext/cs__scope/cs__scope.c +390 -207
- data/ext/cs__scope/cs__scope.h +3 -1
- data/ext/cs__scope/extconf.rb +1 -1
- data/ext/cs__tests/cs__tests.c +1 -1
- data/ext/cs__tests/extconf.rb +1 -1
- data/ext/extconf_common.rb +1 -1
- data/lib/contrast/agent/assess/contrast_object.rb +1 -1
- data/lib/contrast/agent/assess/events/event_data.rb +1 -1
- data/lib/contrast/agent/assess/finalizers/freeze.rb +1 -1
- data/lib/contrast/agent/assess/finalizers/hash.rb +1 -1
- data/lib/contrast/agent/assess/policy/dynamic_source_factory.rb +1 -1
- data/lib/contrast/agent/assess/policy/patcher.rb +1 -1
- data/lib/contrast/agent/assess/policy/policy.rb +1 -1
- data/lib/contrast/agent/assess/policy/policy_node.rb +1 -1
- data/lib/contrast/agent/assess/policy/policy_node_utils.rb +1 -1
- data/lib/contrast/agent/assess/policy/policy_scanner.rb +1 -1
- data/lib/contrast/agent/assess/policy/preshift.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagation_method.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagation_node.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/append.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/base.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/buffer.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/center.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/custom.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/database_write.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/insert.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/keep.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/match_data.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/next.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/prepend.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/rack_protection.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/remove.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/replace.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/reverse.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/select.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/splat.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/split.rb +2 -5
- 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 -1
- data/lib/contrast/agent/assess/policy/source_method.rb +1 -3
- data/lib/contrast/agent/assess/policy/source_node.rb +1 -1
- data/lib/contrast/agent/assess/policy/source_validation/cross_site_validator.rb +1 -1
- data/lib/contrast/agent/assess/policy/source_validation/source_validation.rb +1 -1
- data/lib/contrast/agent/assess/policy/trigger/reflected_xss.rb +2 -1
- data/lib/contrast/agent/assess/policy/trigger/xpath.rb +1 -1
- data/lib/contrast/agent/assess/policy/trigger_method.rb +1 -1
- data/lib/contrast/agent/assess/policy/trigger_node.rb +1 -1
- data/lib/contrast/agent/assess/policy/trigger_validation/redos_validator.rb +1 -1
- data/lib/contrast/agent/assess/policy/trigger_validation/ssrf_validator.rb +1 -1
- data/lib/contrast/agent/assess/policy/trigger_validation/trigger_validation.rb +1 -1
- data/lib/contrast/agent/assess/policy/trigger_validation/xss_validator.rb +1 -1
- data/lib/contrast/agent/assess/properties.rb +1 -1
- data/lib/contrast/agent/assess/property/evented.rb +1 -1
- data/lib/contrast/agent/assess/property/tagged.rb +1 -1
- data/lib/contrast/agent/assess/property/updated.rb +1 -1
- data/lib/contrast/agent/assess/rule/provider/hardcoded_key.rb +1 -1
- data/lib/contrast/agent/assess/rule/provider/hardcoded_password.rb +1 -1
- data/lib/contrast/agent/assess/rule/provider/hardcoded_value_rule.rb +1 -1
- data/lib/contrast/agent/assess/rule/provider.rb +1 -1
- data/lib/contrast/agent/assess/rule/response/auto_complete_rule.rb +1 -1
- data/lib/contrast/agent/assess/rule/response/base_rule.rb +1 -1
- data/lib/contrast/agent/assess/rule/response/body_rule.rb +1 -1
- data/lib/contrast/agent/assess/rule/response/cache_control_header_rule.rb +1 -1
- data/lib/contrast/agent/assess/rule/response/click_jacking_header_rule.rb +1 -1
- data/lib/contrast/agent/assess/rule/response/csp_header_insecure_rule.rb +1 -1
- data/lib/contrast/agent/assess/rule/response/csp_header_missing_rule.rb +1 -1
- data/lib/contrast/agent/assess/rule/response/framework/rails_support.rb +1 -1
- data/lib/contrast/agent/assess/rule/response/header_rule.rb +1 -1
- data/lib/contrast/agent/assess/rule/response/hsts_header_rule.rb +1 -1
- data/lib/contrast/agent/assess/rule/response/parameters_pollution_rule.rb +1 -1
- data/lib/contrast/agent/assess/rule/response/x_content_type_header_rule.rb +1 -1
- data/lib/contrast/agent/assess/rule/response/x_xss_protection_header_rule.rb +1 -1
- data/lib/contrast/agent/assess/tag.rb +1 -1
- data/lib/contrast/agent/assess/tracker.rb +1 -1
- data/lib/contrast/agent/assess.rb +1 -1
- data/lib/contrast/agent/at_exit_hook.rb +1 -1
- data/lib/contrast/agent/deadzone/policy/deadzone_node.rb +1 -1
- data/lib/contrast/agent/deadzone/policy/policy.rb +1 -1
- data/lib/contrast/agent/disable_reaction.rb +1 -1
- data/lib/contrast/agent/excluder.rb +125 -43
- data/lib/contrast/agent/exclusion_matcher.rb +11 -55
- data/lib/contrast/agent/inventory/database_config.rb +1 -1
- data/lib/contrast/agent/inventory/dependencies.rb +1 -1
- data/lib/contrast/agent/inventory/dependency_analysis.rb +1 -1
- data/lib/contrast/agent/inventory/dependency_usage_analysis.rb +1 -1
- data/lib/contrast/agent/inventory/policy/datastores.rb +1 -1
- data/lib/contrast/agent/inventory/policy/policy.rb +1 -1
- data/lib/contrast/agent/inventory/policy/trigger_node.rb +1 -1
- data/lib/contrast/agent/inventory.rb +1 -1
- data/lib/contrast/agent/middleware.rb +22 -9
- data/lib/contrast/agent/module_data.rb +1 -1
- data/lib/contrast/agent/patching/policy/after_load_patch.rb +1 -1
- data/lib/contrast/agent/patching/policy/after_load_patcher.rb +1 -1
- data/lib/contrast/agent/patching/policy/method_policy.rb +1 -1
- data/lib/contrast/agent/patching/policy/method_policy_extend.rb +7 -3
- data/lib/contrast/agent/patching/policy/module_policy.rb +1 -1
- data/lib/contrast/agent/patching/policy/patch.rb +1 -1
- data/lib/contrast/agent/patching/policy/patch_status.rb +1 -1
- data/lib/contrast/agent/patching/policy/patcher.rb +1 -1
- data/lib/contrast/agent/patching/policy/policy.rb +1 -1
- data/lib/contrast/agent/patching/policy/policy_node.rb +1 -1
- data/lib/contrast/agent/patching/policy/trigger_node.rb +2 -2
- data/lib/contrast/agent/protect/exploitable_collection.rb +1 -1
- data/lib/contrast/agent/protect/input_analyzer/input_analyzer.rb +4 -2
- data/lib/contrast/agent/protect/input_analyzer/worth_watching_analyzer.rb +12 -11
- data/lib/contrast/agent/protect/policy/applies_command_injection_rule.rb +1 -1
- data/lib/contrast/agent/protect/policy/applies_deserialization_rule.rb +1 -1
- data/lib/contrast/agent/protect/policy/applies_no_sqli_rule.rb +1 -1
- data/lib/contrast/agent/protect/policy/applies_path_traversal_rule.rb +3 -3
- data/lib/contrast/agent/protect/policy/applies_sqli_rule.rb +1 -1
- data/lib/contrast/agent/protect/policy/applies_xxe_rule.rb +1 -1
- data/lib/contrast/agent/protect/policy/policy.rb +1 -1
- data/lib/contrast/agent/protect/policy/rule_applicator.rb +6 -1
- data/lib/contrast/agent/protect/policy/trigger_node.rb +1 -1
- data/lib/contrast/agent/protect/rule/base.rb +9 -19
- data/lib/contrast/agent/protect/rule/base_service.rb +34 -12
- data/lib/contrast/agent/protect/rule/bot_blocker/bot_blocker_input_classification.rb +1 -1
- data/lib/contrast/agent/protect/rule/bot_blocker.rb +1 -1
- data/lib/contrast/agent/protect/rule/cmd_injection.rb +1 -1
- data/lib/contrast/agent/protect/rule/cmdi/cmdi_backdoors.rb +9 -51
- data/lib/contrast/agent/protect/rule/cmdi/cmdi_base_rule.rb +12 -19
- data/lib/contrast/agent/protect/rule/cmdi/cmdi_chained_command.rb +11 -12
- data/lib/contrast/agent/protect/rule/cmdi/cmdi_dangerous_path.rb +11 -12
- data/lib/contrast/agent/protect/rule/cmdi/cmdi_input_classification.rb +1 -1
- data/lib/contrast/agent/protect/rule/default_scanner.rb +1 -1
- data/lib/contrast/agent/protect/rule/deserialization.rb +2 -3
- data/lib/contrast/agent/protect/rule/no_sqli/mongo_no_sql_scanner.rb +1 -1
- data/lib/contrast/agent/protect/rule/no_sqli/no_sqli_input_classification.rb +1 -1
- data/lib/contrast/agent/protect/rule/no_sqli.rb +1 -13
- data/lib/contrast/agent/protect/rule/path_traversal/path_traversal_input_classification.rb +1 -1
- data/lib/contrast/agent/protect/rule/path_traversal/path_traversal_semantic_security_bypass.rb +34 -9
- data/lib/contrast/agent/protect/rule/path_traversal.rb +1 -47
- data/lib/contrast/agent/protect/rule/sql_sample_builder.rb +1 -1
- data/lib/contrast/agent/protect/rule/sqli/default_sql_scanner.rb +1 -1
- data/lib/contrast/agent/protect/rule/sqli/mysql_sql_scanner.rb +1 -1
- data/lib/contrast/agent/protect/rule/sqli/postgres_sql_scanner.rb +2 -3
- data/lib/contrast/agent/protect/rule/sqli/sqli_base_rule.rb +1 -1
- data/lib/contrast/agent/protect/rule/sqli/sqli_input_classification.rb +1 -1
- data/lib/contrast/agent/protect/rule/sqli/sqli_semantic/sqli_dangerous_functions.rb +5 -5
- data/lib/contrast/agent/protect/rule/sqli/sqlite_sql_scanner.rb +1 -1
- data/lib/contrast/agent/protect/rule/sqli.rb +1 -13
- data/lib/contrast/agent/protect/rule/unsafe_file_upload/unsafe_file_upload_input_classification.rb +1 -1
- data/lib/contrast/agent/protect/rule/unsafe_file_upload.rb +1 -2
- data/lib/contrast/agent/protect/rule/xss/reflected_xss_input_classification.rb +1 -1
- data/lib/contrast/agent/protect/rule/xss.rb +1 -1
- data/lib/contrast/agent/protect/rule/xxe/entity_wrapper.rb +1 -1
- data/lib/contrast/agent/protect/rule/xxe.rb +2 -3
- data/lib/contrast/agent/protect/rule.rb +1 -1
- data/lib/contrast/agent/reporting/attack_result/attack_result.rb +1 -1
- data/lib/contrast/agent/reporting/attack_result/rasp_rule_sample.rb +1 -1
- data/lib/contrast/agent/reporting/attack_result/response_type.rb +1 -1
- data/lib/contrast/agent/reporting/attack_result/user_input.rb +1 -1
- data/lib/contrast/{api/communication → agent/reporting}/connection_status.rb +3 -17
- data/lib/contrast/agent/reporting/details/bot_blocker_details.rb +1 -1
- data/lib/contrast/agent/reporting/details/cmd_injection_details.rb +1 -1
- data/lib/contrast/agent/reporting/details/details.rb +1 -1
- data/lib/contrast/agent/reporting/details/ip_denylist_details.rb +1 -1
- data/lib/contrast/agent/reporting/details/no_sqli_details.rb +1 -1
- data/lib/contrast/agent/reporting/details/path_traversal_details.rb +1 -1
- data/lib/contrast/agent/reporting/details/path_traversal_semantic_analysis_details.rb +1 -1
- data/lib/contrast/agent/reporting/details/protect_rule_details.rb +1 -1
- data/lib/contrast/agent/reporting/details/sqli_dangerous_functions.rb +1 -1
- data/lib/contrast/agent/reporting/details/sqli_details.rb +1 -1
- data/lib/contrast/agent/reporting/details/untrusted_deserialization_details.rb +1 -1
- data/lib/contrast/agent/reporting/details/virtual_patch_details.rb +1 -1
- data/lib/contrast/agent/reporting/details/xss_details.rb +1 -1
- data/lib/contrast/agent/reporting/details/xss_match.rb +1 -1
- data/lib/contrast/agent/reporting/details/xxe_details.rb +1 -1
- data/lib/contrast/agent/reporting/details/xxe_match.rb +1 -1
- data/lib/contrast/agent/reporting/details/xxe_wrapper.rb +1 -1
- data/lib/contrast/agent/reporting/input_analysis/details/bot_blocker_details.rb +1 -1
- data/lib/contrast/agent/reporting/input_analysis/details/protect_rule_details.rb +1 -1
- data/lib/contrast/agent/reporting/input_analysis/input_analysis.rb +1 -1
- data/lib/contrast/agent/reporting/input_analysis/input_analysis_result.rb +1 -1
- data/lib/contrast/agent/reporting/input_analysis/input_type.rb +1 -1
- data/lib/contrast/agent/reporting/input_analysis/score_level.rb +1 -1
- data/lib/contrast/agent/reporting/masker/masker.rb +1 -1
- data/lib/contrast/agent/reporting/masker/masker_utils.rb +1 -1
- data/lib/contrast/agent/reporting/report.rb +1 -1
- data/lib/contrast/agent/reporting/reporter.rb +14 -17
- data/lib/contrast/agent/reporting/reporting_events/agent_startup.rb +2 -2
- data/lib/contrast/agent/reporting/reporting_events/application_activity.rb +5 -4
- data/lib/contrast/agent/reporting/reporting_events/application_defend_activity.rb +13 -9
- data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_activity.rb +5 -6
- data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample.rb +1 -1
- data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample_activity.rb +4 -3
- data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample_stack.rb +1 -1
- data/lib/contrast/agent/reporting/reporting_events/application_defend_attacker_activity.rb +19 -12
- data/lib/contrast/agent/reporting/reporting_events/application_inventory.rb +2 -2
- data/lib/contrast/agent/reporting/reporting_events/application_inventory_activity.rb +2 -2
- data/lib/contrast/agent/reporting/reporting_events/application_reporting_event.rb +1 -1
- data/lib/contrast/agent/reporting/reporting_events/application_settings.rb +2 -2
- data/lib/contrast/agent/reporting/reporting_events/application_startup.rb +2 -2
- data/lib/contrast/agent/reporting/reporting_events/application_startup_instrumentation.rb +1 -1
- data/lib/contrast/agent/reporting/reporting_events/application_update.rb +2 -3
- data/lib/contrast/agent/reporting/reporting_events/architecture_component.rb +4 -10
- data/lib/contrast/agent/reporting/reporting_events/discovered_route.rb +10 -14
- data/lib/contrast/agent/reporting/reporting_events/finding.rb +2 -11
- data/lib/contrast/agent/reporting/reporting_events/finding_event.rb +5 -12
- data/lib/contrast/agent/reporting/reporting_events/finding_event_object.rb +4 -12
- data/lib/contrast/agent/reporting/reporting_events/finding_event_parent_object.rb +9 -13
- data/lib/contrast/agent/reporting/reporting_events/finding_event_property.rb +9 -13
- data/lib/contrast/agent/reporting/reporting_events/finding_event_signature.rb +5 -12
- data/lib/contrast/agent/reporting/reporting_events/finding_event_source.rb +10 -21
- data/lib/contrast/agent/reporting/reporting_events/finding_event_stack.rb +9 -12
- data/lib/contrast/agent/reporting/reporting_events/finding_event_taint_range.rb +10 -14
- data/lib/contrast/agent/reporting/reporting_events/finding_event_taint_range_tags.rb +1 -1
- data/lib/contrast/agent/reporting/reporting_events/finding_request.rb +4 -12
- data/lib/contrast/agent/reporting/reporting_events/library_discovery.rb +14 -14
- data/lib/contrast/agent/reporting/reporting_events/library_usage_observation.rb +14 -14
- data/lib/contrast/agent/reporting/reporting_events/observed_library_usage.rb +3 -11
- data/lib/contrast/agent/reporting/reporting_events/observed_route.rb +10 -16
- data/lib/contrast/agent/reporting/reporting_events/poll.rb +2 -2
- data/lib/contrast/agent/reporting/reporting_events/preflight.rb +13 -2
- data/lib/contrast/agent/reporting/reporting_events/preflight_message.rb +5 -13
- data/lib/contrast/agent/reporting/reporting_events/reportable_hash.rb +47 -0
- data/lib/contrast/agent/reporting/reporting_events/reporting_event.rb +4 -35
- data/lib/contrast/agent/reporting/reporting_events/route_coverage.rb +1 -3
- data/lib/contrast/agent/reporting/reporting_events/route_discovery.rb +9 -13
- data/lib/contrast/agent/reporting/reporting_events/route_discovery_observation.rb +9 -13
- data/lib/contrast/agent/reporting/reporting_events/server_reporting_event.rb +1 -1
- data/lib/contrast/agent/reporting/reporting_events/server_settings.rb +2 -2
- data/lib/contrast/agent/reporting/reporting_utilities/audit.rb +5 -2
- data/lib/contrast/agent/reporting/reporting_utilities/build_preflight.rb +5 -2
- data/lib/contrast/agent/reporting/reporting_utilities/endpoints.rb +8 -8
- data/lib/contrast/agent/reporting/reporting_utilities/headers.rb +6 -3
- data/lib/contrast/agent/reporting/reporting_utilities/ng_response_extractor.rb +4 -4
- data/lib/contrast/agent/reporting/reporting_utilities/reporter_client.rb +6 -19
- data/lib/contrast/agent/reporting/reporting_utilities/reporter_client_utils.rb +20 -3
- data/lib/contrast/agent/reporting/reporting_utilities/reporting_storage.rb +1 -1
- data/lib/contrast/agent/reporting/reporting_utilities/response.rb +1 -1
- data/lib/contrast/agent/reporting/reporting_utilities/response_extractor.rb +2 -22
- data/lib/contrast/agent/reporting/reporting_utilities/response_handler.rb +1 -1
- data/lib/contrast/agent/reporting/reporting_utilities/response_handler_mode.rb +1 -1
- data/lib/contrast/agent/reporting/reporting_utilities/response_handler_utils.rb +26 -9
- data/lib/contrast/agent/reporting/reporting_workers/application_server_worker.rb +1 -1
- data/lib/contrast/agent/reporting/reporting_workers/reporter_heartbeat.rb +1 -1
- data/lib/contrast/agent/reporting/reporting_workers/reporting_workers.rb +1 -1
- data/lib/contrast/agent/reporting/reporting_workers/server_settings_worker.rb +1 -1
- data/lib/contrast/agent/reporting/settings/application_settings.rb +1 -1
- data/lib/contrast/agent/reporting/settings/assess.rb +1 -1
- data/lib/contrast/agent/reporting/settings/assess_rule.rb +1 -1
- data/lib/contrast/agent/reporting/settings/assess_server_feature.rb +1 -1
- data/lib/contrast/agent/reporting/settings/bot_blocker.rb +1 -1
- data/lib/contrast/agent/reporting/settings/exclusion_base.rb +90 -12
- data/lib/contrast/agent/reporting/settings/exclusions.rb +11 -31
- data/lib/contrast/agent/reporting/settings/helpers.rb +41 -5
- data/lib/contrast/agent/reporting/settings/input_exclusion.rb +54 -10
- data/lib/contrast/agent/reporting/settings/ip_filter.rb +1 -1
- data/lib/contrast/agent/reporting/settings/keyword.rb +1 -1
- data/lib/contrast/agent/reporting/settings/log_enhancer.rb +1 -1
- data/lib/contrast/agent/reporting/settings/protect.rb +1 -1
- data/lib/contrast/agent/reporting/settings/protect_rule.rb +1 -1
- data/lib/contrast/agent/reporting/settings/protect_server_feature.rb +1 -1
- data/lib/contrast/agent/reporting/settings/reaction.rb +1 -1
- data/lib/contrast/agent/reporting/settings/rule_definition.rb +1 -1
- data/lib/contrast/agent/reporting/settings/sampling.rb +1 -1
- data/lib/contrast/agent/reporting/settings/sanitizer.rb +1 -1
- data/lib/contrast/agent/reporting/settings/security_logger.rb +1 -1
- data/lib/contrast/agent/reporting/settings/sensitive_data_masking.rb +1 -1
- data/lib/contrast/agent/reporting/settings/sensitive_data_masking_rule.rb +1 -1
- data/lib/contrast/agent/reporting/settings/server_features.rb +1 -1
- data/lib/contrast/agent/reporting/settings/syslog.rb +1 -1
- data/lib/contrast/agent/reporting/settings/url_exclusion.rb +2 -26
- data/lib/contrast/agent/reporting/settings/validator.rb +1 -1
- data/lib/contrast/agent/reporting/settings/virtual_patch.rb +1 -1
- data/lib/contrast/agent/reporting/settings/virtual_patch_condition.rb +1 -1
- data/lib/contrast/agent/request.rb +1 -1
- data/lib/contrast/agent/request_context.rb +1 -1
- data/lib/contrast/agent/request_context_extend.rb +1 -1
- data/lib/contrast/agent/request_handler.rb +1 -1
- data/lib/contrast/agent/response.rb +1 -1
- data/lib/contrast/agent/rule_set.rb +1 -1
- data/lib/contrast/agent/scope.rb +9 -1
- data/lib/contrast/agent/static_analysis.rb +1 -1
- data/lib/contrast/agent/telemetry/base.rb +23 -17
- data/lib/contrast/agent/telemetry/client.rb +109 -0
- data/lib/contrast/agent/telemetry/{events/event.rb → event.rb} +1 -1
- data/lib/contrast/agent/telemetry/{events/exceptions/telemetry_exception_base.rb → exception/base.rb} +2 -2
- data/lib/contrast/agent/telemetry/{events/exceptions/telemetry_exception_event.rb → exception/event.rb} +10 -10
- data/lib/contrast/agent/telemetry/{events/exceptions/telemetry_exception_message.rb → exception/message.rb} +9 -9
- data/lib/contrast/agent/telemetry/{events/exceptions/telemetry_exception_message_exception.rb → exception/message_exception.rb} +9 -9
- data/lib/contrast/agent/telemetry/{events/exceptions/telemetry_exception_stack_frame.rb → exception/stack_frame.rb} +4 -4
- data/lib/contrast/agent/telemetry/exception.rb +19 -0
- data/lib/contrast/agent/telemetry/hash.rb +71 -0
- data/lib/contrast/{utils/telemetry_identifier.rb → agent/telemetry/identifier.rb} +5 -5
- data/lib/contrast/agent/telemetry/{events/metric_event.rb → metric_event.rb} +2 -2
- data/lib/contrast/agent/telemetry/{events/startup_metrics_event.rb → startup_metrics_event.rb} +2 -2
- data/lib/contrast/{utils → agent}/telemetry.rb +4 -4
- data/lib/contrast/agent/thread.rb +1 -1
- data/lib/contrast/agent/thread_watcher.rb +28 -31
- data/lib/contrast/agent/tracepoint_hook.rb +1 -1
- data/lib/contrast/agent/version.rb +2 -2
- data/lib/contrast/agent/worker_thread.rb +1 -1
- data/lib/contrast/agent.rb +6 -2
- data/lib/contrast/agent_lib/api/command_injection.rb +1 -1
- data/lib/contrast/agent_lib/api/init.rb +1 -1
- data/lib/contrast/agent_lib/api/input_tracing.rb +1 -1
- data/lib/contrast/agent_lib/api/panic.rb +1 -1
- data/lib/contrast/agent_lib/api/path_semantic_file_security_bypass.rb +1 -1
- data/lib/contrast/agent_lib/interface.rb +1 -1
- data/lib/contrast/agent_lib/interface_base.rb +2 -2
- data/lib/contrast/agent_lib/return_types/eval_result.rb +1 -1
- data/lib/contrast/agent_lib/test.rb +1 -1
- data/lib/contrast/components/agent.rb +1 -1
- data/lib/contrast/components/api.rb +1 -1
- data/lib/contrast/components/app_context.rb +1 -1
- data/lib/contrast/components/app_context_extend.rb +1 -1
- data/lib/contrast/components/assess.rb +1 -1
- data/lib/contrast/components/assess_rules.rb +1 -1
- data/lib/contrast/components/base.rb +1 -1
- data/lib/contrast/components/config/sources.rb +1 -1
- data/lib/contrast/components/config.rb +2 -2
- data/lib/contrast/components/heap_dump.rb +1 -1
- data/lib/contrast/components/inventory.rb +1 -1
- data/lib/contrast/components/logger.rb +1 -1
- data/lib/contrast/components/polling.rb +4 -4
- data/lib/contrast/components/protect.rb +1 -1
- data/lib/contrast/components/ruby_component.rb +45 -6
- data/lib/contrast/components/sampling.rb +6 -6
- data/lib/contrast/components/scope.rb +9 -1
- data/lib/contrast/components/security_logger.rb +1 -1
- data/lib/contrast/components/settings.rb +13 -12
- data/lib/contrast/config/api_proxy_configuration.rb +1 -1
- data/lib/contrast/config/base_configuration.rb +1 -1
- data/lib/contrast/config/certification_configuration.rb +1 -1
- data/lib/contrast/config/config.rb +14 -12
- data/lib/contrast/config/diagnostics.rb +12 -3
- data/lib/contrast/config/diagnostics_tools.rb +2 -1
- data/lib/contrast/config/effective_config.rb +81 -15
- data/lib/contrast/config/effective_config_value.rb +4 -4
- data/lib/contrast/config/env_variables.rb +1 -1
- data/lib/contrast/config/exception_configuration.rb +1 -1
- data/lib/contrast/config/protect_rule_configuration.rb +1 -1
- data/lib/contrast/config/protect_rules_configuration.rb +1 -1
- data/lib/contrast/config/request_audit_configuration.rb +1 -1
- data/lib/contrast/config/server_configuration.rb +2 -2
- data/lib/contrast/config.rb +1 -1
- data/lib/contrast/configuration.rb +1 -1
- data/lib/contrast/extension/assess/array.rb +1 -1
- data/lib/contrast/extension/assess/erb.rb +1 -1
- data/lib/contrast/extension/assess/eval_trigger.rb +1 -1
- data/lib/contrast/extension/assess/exec_trigger.rb +1 -1
- data/lib/contrast/extension/assess/fiber.rb +1 -1
- data/lib/contrast/extension/assess/hash.rb +1 -1
- data/lib/contrast/extension/assess/kernel.rb +1 -1
- data/lib/contrast/extension/assess/marshal.rb +1 -1
- data/lib/contrast/extension/assess/regexp.rb +1 -1
- data/lib/contrast/extension/assess/string.rb +1 -1
- data/lib/contrast/extension/assess.rb +1 -1
- data/lib/contrast/extension/delegator.rb +1 -1
- data/lib/contrast/extension/extension.rb +1 -1
- data/lib/contrast/extension/inventory.rb +1 -1
- data/lib/contrast/extension/module.rb +1 -1
- data/lib/contrast/extension/object.rb +1 -1
- data/lib/contrast/extension/protect/psych.rb +1 -1
- data/lib/contrast/extension/protect.rb +1 -1
- data/lib/contrast/extension/thread.rb +1 -1
- data/lib/contrast/framework/base_support.rb +1 -1
- data/lib/contrast/framework/grape/support.rb +1 -1
- data/lib/contrast/framework/manager.rb +1 -1
- data/lib/contrast/framework/manager_extend.rb +1 -1
- data/lib/contrast/framework/rack/patch/session_cookie.rb +3 -2
- data/lib/contrast/framework/rack/patch/support.rb +1 -1
- data/lib/contrast/framework/rack/support.rb +1 -1
- data/lib/contrast/framework/rails/patch/action_controller_live_buffer.rb +1 -1
- data/lib/contrast/framework/rails/patch/assess_configuration.rb +1 -1
- data/lib/contrast/framework/rails/patch/rails_application_configuration.rb +1 -1
- data/lib/contrast/framework/rails/patch/support.rb +1 -1
- data/lib/contrast/framework/rails/railtie.rb +1 -1
- data/lib/contrast/framework/rails/support.rb +1 -1
- data/lib/contrast/framework/sinatra/patch/encrypted_session_cookie.rb +39 -0
- data/lib/contrast/framework/sinatra/support.rb +14 -1
- data/lib/contrast/funchook/funchook.rb +1 -1
- data/lib/contrast/logger/aliased_logging.rb +12 -14
- data/lib/contrast/logger/application.rb +1 -1
- data/lib/contrast/logger/cef_log.rb +1 -1
- data/lib/contrast/logger/format.rb +1 -1
- data/lib/contrast/logger/log.rb +1 -1
- data/lib/contrast/logger/request.rb +1 -1
- data/lib/contrast/logger/time.rb +1 -1
- data/lib/contrast/security_exception.rb +1 -1
- data/lib/contrast/tasks/config.rb +1 -1
- data/lib/contrast/utils/assess/event_limit_utils.rb +1 -1
- data/lib/contrast/utils/assess/object_store.rb +1 -1
- data/lib/contrast/utils/assess/propagation_method_utils.rb +1 -1
- data/lib/contrast/utils/assess/property/tagged_utils.rb +1 -1
- data/lib/contrast/utils/assess/sampling_util.rb +1 -1
- data/lib/contrast/utils/assess/source_method_utils.rb +1 -1
- data/lib/contrast/utils/assess/split_utils.rb +1 -1
- data/lib/contrast/utils/assess/tracking_util.rb +1 -1
- data/lib/contrast/utils/assess/trigger_method_utils.rb +1 -1
- data/lib/contrast/utils/class_util.rb +1 -1
- data/lib/contrast/utils/duck_utils.rb +19 -1
- data/lib/contrast/utils/env_configuration_item.rb +1 -1
- data/lib/contrast/utils/findings.rb +1 -1
- data/lib/contrast/utils/hash_digest.rb +1 -1
- data/lib/contrast/utils/hash_digest_extend.rb +1 -1
- data/lib/contrast/utils/head_dump_utils_extend.rb +1 -1
- data/lib/contrast/utils/heap_dump_util.rb +2 -2
- data/lib/contrast/utils/input_classification_base.rb +2 -5
- data/lib/contrast/utils/invalid_configuration_util.rb +1 -1
- data/lib/contrast/utils/io_util.rb +1 -1
- data/lib/contrast/utils/job_servers_running.rb +1 -1
- data/lib/contrast/utils/log_utils.rb +3 -3
- data/lib/contrast/utils/lru_cache.rb +1 -1
- data/lib/contrast/utils/metrics_hash.rb +1 -1
- data/lib/contrast/utils/middleware_utils.rb +5 -5
- data/lib/contrast/utils/net_http_base.rb +3 -3
- data/lib/contrast/utils/object_share.rb +2 -1
- data/lib/contrast/utils/os.rb +1 -1
- data/lib/contrast/utils/patching/policy/patch_utils.rb +3 -3
- data/lib/contrast/utils/patching/policy/patcher_utils.rb +1 -1
- data/lib/contrast/utils/reporting/application_activity_batch_utils.rb +12 -4
- data/lib/contrast/utils/request_utils.rb +1 -1
- data/lib/contrast/utils/resource_loader.rb +1 -1
- data/lib/contrast/utils/response_utils.rb +1 -1
- data/lib/contrast/utils/routes_sent.rb +5 -2
- data/lib/contrast/utils/sha256_builder.rb +1 -1
- data/lib/contrast/utils/silence_maker.rb +16 -0
- data/lib/contrast/utils/stack_trace_utils.rb +1 -1
- data/lib/contrast/utils/string_utils.rb +1 -1
- data/lib/contrast/utils/tag_util.rb +1 -1
- data/lib/contrast/utils/thread_tracker.rb +1 -1
- data/lib/contrast/utils/timer.rb +1 -1
- data/lib/contrast-agent.rb +1 -1
- data/lib/contrast.rb +7 -6
- data/ruby-agent.gemspec +6 -6
- metadata +41 -40
- data/lib/contrast/agent/reporting/settings/code_exclusion.rb +0 -32
- data/lib/contrast/agent/telemetry/events/exceptions/obfuscate.rb +0 -124
- data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exceptions.rb +0 -19
- data/lib/contrast/utils/telemetry_client.rb +0 -107
- data/lib/contrast/utils/telemetry_hash.rb +0 -65
@@ -1,124 +0,0 @@
|
|
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
|
-
module Contrast
|
5
|
-
module Agent
|
6
|
-
module Telemetry
|
7
|
-
module TelemetryException
|
8
|
-
# Here will be all known gems to obfuscate during the building of TelemetryExceptions
|
9
|
-
module Obfuscate
|
10
|
-
# TODO: RUBY-1984 Re-enable/Remove Telemetry Obfuscation.
|
11
|
-
#
|
12
|
-
# List of known gems to be third parties not containing any
|
13
|
-
# user sensitive data.
|
14
|
-
# KNOWN_GEMS = %w[
|
15
|
-
# activesupport redis-activesupport redis builder dry-types rails rails-html-sanitizer rails-observers
|
16
|
-
# sinatra
|
17
|
-
# benchmark-ips bundler climate_control execjs factory_bot debride fake_ftp fasterer flay openssl
|
18
|
-
# parallel_tests contrast contrast-agent ruby pry-byebug byebug pry resolv ougai protobuf async nokogiri
|
19
|
-
# benchmark grape-order grape-activerecord newrelic newrelic-grape grape-rails-cache grape-msgpack
|
20
|
-
# grape-batch rspec rake rubocop grape-jbuilder rack-test rack-protection minitest grape-instrumentation
|
21
|
-
# minitest-global_expectations rack-proxy rack-attack rack-ssl grape-cancan grape-attack grape-rake-tasks
|
22
|
-
# grape-route-helpers benchmark-memory grape-rabl grape-kaminari grape-path-helpers grape-swagger-entity
|
23
|
-
# grape-swagger-rails grape-roar newrelic-rake grapes-wagger-representative grape-forgery_protection
|
24
|
-
# grape-papertrail grape-app grape-middleware-logger rack-protection rake-compile rhino rspec-benchmark
|
25
|
-
# rspec_junit_formatter rspec-rails rake-performance rubocop-rails rubocop-rake rubocop-rspec
|
26
|
-
# ruby-debug-ide simplecov sqlite steep tilt tzinfo-data warning xpath sinatra-activerecord sinatra-param
|
27
|
-
# sinatra-partial sinatra-flash sinatra-reloader sinatra-sinatra rake_fly rack rack-accept grape
|
28
|
-
# grape-entity
|
29
|
-
# sinatra-advanced-routes sinatra-warden grape_logging grape-swagger sinatra-namespace sinatra-resource
|
30
|
-
# sinatra-hashfix sinatra-instrumentation sinatra-helpers redis-rack sinatra-support sinatra-assetpack
|
31
|
-
# sinatra-router sinatra-cross_origin sinatra_more sinatra-jsonp faraday-rack zlib mustermann
|
32
|
-
# mustermann-grape
|
33
|
-
# rspec-expectations rspec-core rspec-mocks rspec-sidekiq
|
34
|
-
# ].cs__freeze
|
35
|
-
# KNOWN_ERRORS = %w[
|
36
|
-
# ActiveModel Error Errors Resolv Rspec ActiveRecord nil NilClass NoMemoryError ScriptError
|
37
|
-
# LoadError NotImplementedError SyntaxError SecurityError SignalException Interrupt
|
38
|
-
# StandardError ArgumentError UncaughtThrowError FiberError IOError EOFError IndexError KeyError
|
39
|
-
# StopIteration LocalJumpError NameError NoMethodError RangeError FloatDomainError RegexpError
|
40
|
-
# RuntimeError FrozenError SystemCallError ThreadError TypeError ZeroDivisionError SystemExit
|
41
|
-
# SystemStackError fatal Warning buffer OpenSSL SSL SSLError Errno Timeout Exception EOFError
|
42
|
-
# ECONNRESET ECONNREFUSED ETIMEDOUT EINVAL ESHUTDOWN EHOSTDOWN EHOSTUNREACH EISCONN
|
43
|
-
# ECONNABORTED ENETRESET ENETUNREACH Net HTTPBadResponse HTTPHeaderSyntaxError ProtocolError
|
44
|
-
# Faraday BadRequestError UnauthorizedError ForbiddenError ResourceNotFound ProxyAuthError
|
45
|
-
# ConflictError UnprocessableEntityError ClientError
|
46
|
-
# ].cs__freeze
|
47
|
-
# CHARS = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'.cs__freeze
|
48
|
-
# # This will generate different chars for each agent startup but will be constant
|
49
|
-
# # for current run and will make identical obfuscation to be compared if given type
|
50
|
-
# # is the same.
|
51
|
-
# CYPHER = CHARS.chars.shuffle.join
|
52
|
-
#
|
53
|
-
# class << self
|
54
|
-
# # Returns paths for known gems.
|
55
|
-
# #
|
56
|
-
# # @return [Array<Regexp>] known paths
|
57
|
-
# def known_gem_paths
|
58
|
-
# @_known_gem_paths ||= KNOWN_GEMS.map do |gem_name|
|
59
|
-
# to_regexp(File.join(
|
60
|
-
# 'gems', gem_name.tr('-', ''), 'lib'))
|
61
|
-
# end
|
62
|
-
# end
|
63
|
-
#
|
64
|
-
# # Returns known modules names.
|
65
|
-
# #
|
66
|
-
# # @return [Array<Regexp>] known modules
|
67
|
-
# def known_modules
|
68
|
-
# @_known_modules ||= KNOWN_ERRORS.map { |module_name| to_regexp(module_name) }
|
69
|
-
# end
|
70
|
-
#
|
71
|
-
# # Obfuscate a type and replace it with random characters.
|
72
|
-
# #
|
73
|
-
# # @param type [String] the StackFrame type to obfuscate
|
74
|
-
# # @return [String] obfuscated type
|
75
|
-
# def obfuscate_type type
|
76
|
-
# return unless type
|
77
|
-
#
|
78
|
-
# check = type.tr('[^0-9].-', '')
|
79
|
-
# type = cypher(type) unless match_known(known_gem_paths, check)
|
80
|
-
# type
|
81
|
-
# end
|
82
|
-
#
|
83
|
-
# # Obfuscate a type and replace it with random characters.
|
84
|
-
# #
|
85
|
-
# # @param exception_type [String] the exception type to obfuscate
|
86
|
-
# # @return [String] obfuscated exception type
|
87
|
-
# def obfuscate_exception_type exception_type
|
88
|
-
# return unless exception_type
|
89
|
-
#
|
90
|
-
# exceptions = exception_type.split('::').each do |exception|
|
91
|
-
# cypher(exception) unless match_known(known_modules, exception)
|
92
|
-
# end
|
93
|
-
# exceptions.join('::')
|
94
|
-
# end
|
95
|
-
#
|
96
|
-
# private
|
97
|
-
#
|
98
|
-
# # Transforms string to regexp
|
99
|
-
# #
|
100
|
-
# # @param string [String]
|
101
|
-
# def to_regexp string
|
102
|
-
# /#{ string }/
|
103
|
-
# end
|
104
|
-
#
|
105
|
-
# # Add cypher to path to make it obscure, but unique enough for
|
106
|
-
# # comparisons. Mutates original or duplicate if frozen string.
|
107
|
-
# #
|
108
|
-
# # @param string [String] string to be transformed.
|
109
|
-
# def cypher string
|
110
|
-
# string = string.dup if string.cs__frozen?
|
111
|
-
# string.to_s.tr!(CHARS, CYPHER)
|
112
|
-
# end
|
113
|
-
#
|
114
|
-
# # @param known [Array<Regexp>] Array of regexp to match against
|
115
|
-
# # @param type [String] type to check
|
116
|
-
# def match_known known, type
|
117
|
-
# known.any? { |regexp| type =~ regexp }
|
118
|
-
# end
|
119
|
-
# end
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
@@ -1,19 +0,0 @@
|
|
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
|
-
module Contrast
|
5
|
-
module Agent
|
6
|
-
module Telemetry
|
7
|
-
# This is the module that will include every information created and stored for the
|
8
|
-
# Telemetry Exceptions
|
9
|
-
module TelemetryException
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
require 'contrast/agent/telemetry/events/exceptions/telemetry_exception_base'
|
16
|
-
require 'contrast/agent/telemetry/events/exceptions/telemetry_exception_stack_frame'
|
17
|
-
require 'contrast/agent/telemetry/events/exceptions/telemetry_exception_message_exception'
|
18
|
-
require 'contrast/agent/telemetry/events/exceptions/telemetry_exception_message'
|
19
|
-
require 'contrast/agent/telemetry/events/exceptions/telemetry_exception_event'
|
@@ -1,107 +0,0 @@
|
|
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 'net/http'
|
5
|
-
require 'contrast/utils/net_http_base'
|
6
|
-
require 'contrast/components/logger'
|
7
|
-
require 'contrast/utils/object_share'
|
8
|
-
require 'contrast/agent/version'
|
9
|
-
require 'json'
|
10
|
-
|
11
|
-
module Contrast
|
12
|
-
module Utils
|
13
|
-
# This module creates a Net::HTTP client and initiates a connection to the provided result
|
14
|
-
class TelemetryClient < NetHttpBase
|
15
|
-
include Contrast::Components::Logger::InstanceMethods
|
16
|
-
ENDPOINT = 'api/v1/telemetry/metrics' # /TelemetryEvent.path
|
17
|
-
EXCEPTIONS = 'api/v1/telemetry/exceptions' # /TelemetryExceptions::Event.path
|
18
|
-
SERVICE_NAME = 'Telemetry'
|
19
|
-
# This method initializes the Net::HTTP client we'll need. it will validate
|
20
|
-
# the connection and make the first request. If connection is valid and response
|
21
|
-
# is available then the open connection is returned.
|
22
|
-
#
|
23
|
-
# @param url [String]
|
24
|
-
# @return [Net::HTTP, nil] Return open connection or nil
|
25
|
-
def initialize_connection url
|
26
|
-
super(SERVICE_NAME, url, use_proxy: false, use_custom_cert: false)
|
27
|
-
end
|
28
|
-
|
29
|
-
# This method will be responsible for building the request. Because the telemetry collector expects to receive
|
30
|
-
# multiple events in a single request, we must always wrap the event in an array, even if there is only one.
|
31
|
-
#
|
32
|
-
# @param event [Contrast::Agent::Telemetry::Event, Array<Contrast::Agent::Telemetry::TelemetryException::Event>]
|
33
|
-
# @return [Net::HTTP::Post]
|
34
|
-
def build_request event
|
35
|
-
return unless valid_event?(event)
|
36
|
-
|
37
|
-
header = {
|
38
|
-
'User-Agent' => "<#{ Contrast::Utils::ObjectShare::RUBY }>-<#{ Contrast::Agent::VERSION }>",
|
39
|
-
'Content-Type' => 'application/json'
|
40
|
-
}
|
41
|
-
request = Net::HTTP::Post.new(build_path(event), header)
|
42
|
-
request.body = get_event_json(event)
|
43
|
-
request
|
44
|
-
end
|
45
|
-
|
46
|
-
# This method will create the actual request and send it
|
47
|
-
# @param event[Contrast::Agent::Telemetry::Event]
|
48
|
-
# @param connection[Net::HTTP]
|
49
|
-
def send_request event, connection
|
50
|
-
return if connection.nil? || event.nil?
|
51
|
-
return unless valid_event?(event)
|
52
|
-
|
53
|
-
req = build_request(event)
|
54
|
-
connection.request(req)
|
55
|
-
end
|
56
|
-
|
57
|
-
# This method will handle the response from the tenant
|
58
|
-
# @param res [Net::HTTPResponse]
|
59
|
-
# @return sleep_time [Integer, nil]
|
60
|
-
def handle_response res
|
61
|
-
status_code = res.code.to_i
|
62
|
-
ready_after = if res.to_hash.keys.map(&:downcase).include?('ready-after')
|
63
|
-
res['Ready-After']
|
64
|
-
else
|
65
|
-
60
|
66
|
-
end
|
67
|
-
ready_after if status_code == 429
|
68
|
-
end
|
69
|
-
|
70
|
-
# This method will be responsible for validating the event. Valid if event is of a known
|
71
|
-
# Contrast::Agent::Telemetry type
|
72
|
-
#
|
73
|
-
# @param event [Object]
|
74
|
-
def valid_event? event
|
75
|
-
return true if event.cs__is_a?(Contrast::Agent::Telemetry::Event)
|
76
|
-
return true if event.cs__is_a?(Contrast::Agent::Telemetry::StartupMetricsEvent)
|
77
|
-
return true if event.cs__is_a?(Contrast::Agent::Telemetry::TelemetryException::Event)
|
78
|
-
|
79
|
-
false
|
80
|
-
end
|
81
|
-
|
82
|
-
private
|
83
|
-
|
84
|
-
# The telemetry instance accepts any path to #{ Contrast::Agent::Telemetry::URL }#{ ENDPOINT }, using the
|
85
|
-
# remainder of the path to segregate messages.
|
86
|
-
#
|
87
|
-
# @param event [Contrast::Agent::Telemetry::Event, Contrast::Agent::Telemetry::TelemetryException::Event]
|
88
|
-
# @return [String] the fully qualified path to send the request
|
89
|
-
def build_path event
|
90
|
-
endpoint = Array(event).all?(Contrast::Agent::Telemetry::TelemetryException::Event) ? EXCEPTIONS : ENDPOINT
|
91
|
-
path = endpoint == EXCEPTIONS ? Contrast::Agent::Telemetry::TelemetryException::Event.path : event.path
|
92
|
-
"#{ Contrast::Agent::Telemetry::Base::URL }#{ endpoint }#{ path }"
|
93
|
-
end
|
94
|
-
|
95
|
-
# Helper Method to get json representation of Telemetry Event data, handles error on to_json
|
96
|
-
#
|
97
|
-
# @param event [Contrast::Agent::Telemetry::Event, Array<Contrast::Agent::Telemetry::TelemetryException::Event>]
|
98
|
-
# @return [String] - JSON
|
99
|
-
def get_event_json event
|
100
|
-
Array(event.to_controlled_hash).to_json
|
101
|
-
rescue Exception => e # rubocop:disable Lint/RescueException
|
102
|
-
logger.error('[Telemetry] Unable to convert TelemetryEvent to JSON string', e, hsh)
|
103
|
-
raise(e)
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
@@ -1,65 +0,0 @@
|
|
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/components/logger'
|
5
|
-
require 'contrast/agent/telemetry/events/exceptions/telemetry_exception_event'
|
6
|
-
|
7
|
-
module Contrast
|
8
|
-
module Utils
|
9
|
-
# This is the TelemetryHash, which will store Contrast::Agent::Telemetry::TelemetryException::Event, so we can push
|
10
|
-
# freely, without worrying about validating the event before that. TelemetryHash has a max size of events,
|
11
|
-
# default is 10 events
|
12
|
-
class TelemetryHash < Hash
|
13
|
-
include Contrast::Components::Logger::InstanceMethods
|
14
|
-
HASH_SIZE_LIMIT = 10
|
15
|
-
|
16
|
-
# Wrapper to set a value in this TelemetryHash only if the provided value is of the data_type for this
|
17
|
-
# TelemetryHash or the hash has not reached its limit of for unique keys
|
18
|
-
#
|
19
|
-
# @param key [Object] the key to which to associate the value
|
20
|
-
# @param value [Object] the value to store
|
21
|
-
# @return [Object, nil] echo back out the value as the Hash#[]= method does, or nil if not of the expected
|
22
|
-
# data_type
|
23
|
-
def []= key, value
|
24
|
-
return if exception_limit?
|
25
|
-
return unless valid_value?(value)
|
26
|
-
|
27
|
-
super(key, value)
|
28
|
-
end
|
29
|
-
|
30
|
-
# Increment the occurrences for the exception object contained in this TelemetryHash
|
31
|
-
#
|
32
|
-
# @param key [Object] the key to check for the exception stored in this TelemetryHash
|
33
|
-
def increment key
|
34
|
-
value = self[key]
|
35
|
-
return unless value&.exceptions&.any?
|
36
|
-
|
37
|
-
value.exceptions[0].increment_occurrences
|
38
|
-
end
|
39
|
-
|
40
|
-
# Determine if hash has reached exception event limit
|
41
|
-
# @return [Boolean]
|
42
|
-
def exception_limit?
|
43
|
-
unless size < HASH_SIZE_LIMIT
|
44
|
-
logger.debug("Number of TelemetryExceptions exceeds limit of #{ HASH_SIZE_LIMIT }")
|
45
|
-
return true
|
46
|
-
end
|
47
|
-
false
|
48
|
-
end
|
49
|
-
|
50
|
-
private
|
51
|
-
|
52
|
-
# Determine if the given value is valid based on the datatype which this TelemetryHash contains
|
53
|
-
# @param value [Object]
|
54
|
-
# @return boolean
|
55
|
-
def valid_value? value
|
56
|
-
unless value.cs__is_a?(Contrast::Agent::Telemetry::TelemetryException::Event)
|
57
|
-
logger.debug('The following key will be omitted', value: value)
|
58
|
-
return false
|
59
|
-
end
|
60
|
-
|
61
|
-
true
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|