contrast-agent 4.13.0 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.simplecov +2 -1
- data/Gemfile +1 -1
- data/LICENSE.txt +1 -1
- data/Rakefile +1 -1
- data/exe/contrast_service +1 -1
- data/ext/build_funchook.rb +1 -1
- data/ext/cs__assess_array/cs__assess_array.c +1 -1
- 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 +1 -1
- 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_interpolation26/cs__assess_string_interpolation26.c +1 -1
- data/ext/cs__assess_string_interpolation26/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 +1 -1
- 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/extconf_common.rb +1 -1
- data/lib/contrast/agent/assess/contrast_event.rb +7 -11
- data/lib/contrast/agent/assess/contrast_object.rb +1 -1
- data/lib/contrast/agent/assess/events/event_data.rb +30 -0
- data/lib/contrast/agent/assess/events/event_factory.rb +14 -6
- data/lib/contrast/agent/assess/events/source_event.rb +22 -3
- 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 +7 -7
- data/lib/contrast/agent/assess/policy/patcher.rb +1 -35
- data/lib/contrast/agent/assess/policy/policy.rb +1 -1
- data/lib/contrast/agent/assess/policy/policy_node.rb +7 -7
- data/lib/contrast/agent/assess/policy/policy_scanner.rb +6 -1
- data/lib/contrast/agent/assess/policy/preshift.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagation_method.rb +55 -28
- 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/center.rb +2 -2
- data/lib/contrast/agent/assess/policy/propagator/custom.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/database_write.rb +6 -2
- data/lib/contrast/agent/assess/policy/propagator/insert.rb +5 -2
- data/lib/contrast/agent/assess/policy/propagator/keep.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/match_data.rb +7 -3
- 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 +3 -2
- data/lib/contrast/agent/assess/policy/propagator/splat.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/split.rb +27 -25
- data/lib/contrast/agent/assess/policy/propagator/substitution.rb +3 -157
- data/lib/contrast/agent/assess/policy/propagator/substitution_utils.rb +190 -0
- data/lib/contrast/agent/assess/policy/propagator/trim.rb +9 -4
- data/lib/contrast/agent/assess/policy/propagator.rb +1 -1
- data/lib/contrast/agent/assess/policy/source_method.rb +39 -26
- 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 +7 -2
- data/lib/contrast/agent/assess/policy/trigger/xpath.rb +1 -1
- data/lib/contrast/agent/assess/policy/trigger_method.rb +68 -18
- data/lib/contrast/agent/assess/policy/trigger_node.rb +15 -7
- 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 +2 -2
- data/lib/contrast/agent/assess/properties.rb +1 -1
- data/lib/contrast/agent/assess/property/evented.rb +25 -12
- data/lib/contrast/agent/assess/property/tagged.rb +52 -58
- data/lib/contrast/agent/assess/property/updated.rb +1 -1
- data/lib/contrast/agent/assess/rule/provider/hardcoded_key.rb +1 -19
- data/lib/contrast/agent/assess/rule/provider/hardcoded_password.rb +1 -13
- data/lib/contrast/agent/assess/rule/provider/hardcoded_value_rule.rb +42 -60
- data/lib/contrast/agent/assess/rule/provider.rb +1 -1
- data/lib/contrast/agent/assess/rule/response/autocomplete_rule.rb +130 -0
- data/lib/contrast/agent/assess/rule/response/base_rule.rb +117 -0
- 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 -2
- data/lib/contrast/agent/at_exit_hook.rb +1 -1
- data/lib/contrast/agent/deadzone/policy/deadzone_node.rb +13 -8
- data/lib/contrast/agent/deadzone/policy/policy.rb +1 -1
- data/lib/contrast/agent/disable_reaction.rb +1 -1
- data/lib/contrast/agent/exclusion_matcher.rb +1 -1
- data/lib/contrast/agent/inventory/database_config.rb +115 -77
- 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 +3 -3
- 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/metric_telemetry_event.rb +3 -3
- data/lib/contrast/agent/middleware.rb +8 -77
- 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 +31 -104
- data/lib/contrast/agent/patching/policy/method_policy_extend.rb +113 -0
- 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 +2 -26
- data/lib/contrast/agent/patching/policy/patcher.rb +13 -13
- 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 +1 -1
- 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 +1 -1
- 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 +1 -1
- data/lib/contrast/agent/protect/policy/trigger_node.rb +1 -1
- data/lib/contrast/agent/protect/rule/base.rb +1 -1
- data/lib/contrast/agent/protect/rule/base_service.rb +1 -1
- data/lib/contrast/agent/protect/rule/cmd_injection.rb +1 -1
- data/lib/contrast/agent/protect/rule/default_scanner.rb +1 -1
- data/lib/contrast/agent/protect/rule/deserialization.rb +1 -1
- data/lib/contrast/agent/protect/rule/http_method_tampering.rb +1 -1
- data/lib/contrast/agent/protect/rule/no_sqli/mongo_no_sql_scanner.rb +1 -1
- data/lib/contrast/agent/protect/rule/no_sqli.rb +1 -1
- data/lib/contrast/agent/protect/rule/path_traversal.rb +1 -1
- 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 -2
- data/lib/contrast/agent/protect/rule/sqli/sqlite_sql_scanner.rb +1 -1
- data/lib/contrast/agent/protect/rule/sqli.rb +1 -1
- data/lib/contrast/agent/protect/rule/unsafe_file_upload.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 +1 -1
- data/lib/contrast/agent/protect/rule.rb +1 -1
- data/lib/contrast/agent/reaction_processor.rb +1 -1
- data/lib/contrast/agent/reporting/report.rb +27 -0
- data/lib/contrast/agent/reporting/reporter.rb +115 -0
- data/lib/contrast/agent/reporting/reporting_events/application_inventory.rb +49 -0
- data/lib/contrast/agent/reporting/reporting_events/application_update.rb +82 -0
- data/lib/contrast/agent/reporting/reporting_events/architecture_component.rb +80 -0
- data/lib/contrast/agent/reporting/reporting_events/discovered_route.rb +59 -0
- data/lib/contrast/agent/reporting/reporting_events/finding.rb +185 -0
- data/lib/contrast/agent/reporting/reporting_events/finding_event.rb +264 -0
- data/lib/contrast/agent/reporting/reporting_events/finding_event_source.rb +57 -0
- data/lib/contrast/agent/reporting/reporting_events/finding_object.rb +90 -0
- data/lib/contrast/agent/reporting/reporting_events/finding_request.rb +121 -0
- data/lib/contrast/agent/reporting/reporting_events/finding_signature.rb +105 -0
- data/lib/contrast/agent/reporting/reporting_events/finding_stack.rb +67 -0
- data/lib/contrast/agent/reporting/reporting_events/finding_taint_range.rb +58 -0
- data/lib/contrast/agent/reporting/reporting_events/library_discovery.rb +93 -0
- data/lib/contrast/agent/reporting/reporting_events/library_usage_observation.rb +50 -0
- data/lib/contrast/agent/reporting/reporting_events/observed_library_usage.rb +54 -0
- data/lib/contrast/agent/reporting/reporting_events/observed_route.rb +66 -0
- data/lib/contrast/agent/reporting/reporting_events/preflight.rb +39 -0
- data/lib/contrast/agent/reporting/reporting_events/preflight_message.rb +75 -0
- data/lib/contrast/agent/reporting/reporting_events/reporting_event.rb +47 -0
- data/lib/contrast/agent/reporting/reporting_events/route_coverage.rb +76 -0
- data/lib/contrast/agent/reporting/reporting_events/route_discovery.rb +66 -0
- data/lib/contrast/agent/reporting/reporting_events/route_discovery_observation.rb +65 -0
- data/lib/contrast/agent/reporting/reporting_events/server_activity.rb +52 -0
- data/lib/contrast/agent/reporting/reporting_events/trace_event_source.rb +30 -0
- data/lib/contrast/agent/reporting/reporting_utilities/audit.rb +137 -0
- data/lib/contrast/agent/reporting/reporting_utilities/dtm_message.rb +67 -0
- data/lib/contrast/agent/reporting/reporting_utilities/endpoints.rb +165 -0
- data/lib/contrast/agent/reporting/reporting_utilities/headers.rb +55 -0
- data/lib/contrast/agent/reporting/reporting_utilities/reporter_client.rb +86 -0
- data/lib/contrast/agent/reporting/reporting_utilities/reporter_client_utils.rb +154 -0
- data/lib/contrast/agent/reporting/reporting_utilities/reporting_storage.rb +66 -0
- data/lib/contrast/agent/reporting/reporting_utilities/response.rb +30 -0
- data/lib/contrast/agent/reporting/reporting_utilities/response_handler.rb +57 -0
- data/lib/contrast/agent/reporting/reporting_utilities/response_handler_utils.rb +196 -0
- data/lib/contrast/agent/reporting/settings/application_settings.rb +67 -0
- data/lib/contrast/agent/reporting/settings/assess.rb +45 -0
- data/lib/contrast/agent/reporting/settings/assess_server_feature.rb +136 -0
- data/lib/contrast/agent/reporting/settings/exclusions.rb +123 -0
- data/lib/contrast/agent/reporting/settings/protect.rb +89 -0
- data/lib/contrast/agent/reporting/settings/protect_server_feature.rb +243 -0
- data/lib/contrast/agent/reporting/settings/reaction.rb +30 -0
- data/lib/contrast/agent/reporting/settings/server_features.rb +78 -0
- data/lib/contrast/agent/request.rb +46 -84
- data/lib/contrast/agent/request_context.rb +20 -131
- data/lib/contrast/agent/request_context_extend.rb +163 -0
- data/lib/contrast/agent/request_handler.rb +41 -5
- data/lib/contrast/agent/response.rb +25 -88
- data/lib/contrast/agent/rule_set.rb +1 -1
- data/lib/contrast/agent/scope.rb +1 -1
- data/lib/contrast/agent/service_heartbeat.rb +1 -1
- data/lib/contrast/agent/startup_metrics_telemetry_event.rb +73 -23
- data/lib/contrast/agent/static_analysis.rb +14 -4
- data/lib/contrast/agent/telemetry.rb +16 -8
- data/lib/contrast/agent/telemetry_event.rb +9 -10
- data/lib/contrast/agent/thread.rb +1 -1
- data/lib/contrast/agent/thread_watcher.rb +32 -6
- data/lib/contrast/agent/tracepoint_hook.rb +1 -4
- data/lib/contrast/agent/version.rb +2 -2
- data/lib/contrast/agent/worker_thread.rb +1 -1
- data/lib/contrast/agent.rb +16 -1
- data/lib/contrast/api/communication/connection_status.rb +11 -8
- data/lib/contrast/api/communication/messaging_queue.rb +38 -4
- data/lib/contrast/api/communication/response_processor.rb +22 -11
- data/lib/contrast/api/communication/service_lifecycle.rb +14 -4
- data/lib/contrast/api/communication/socket.rb +7 -9
- data/lib/contrast/api/communication/socket_client.rb +33 -13
- data/lib/contrast/api/communication/speedracer.rb +38 -2
- data/lib/contrast/api/communication/tcp_socket.rb +5 -4
- data/lib/contrast/api/communication/unix_socket.rb +2 -1
- data/lib/contrast/api/communication.rb +1 -1
- data/lib/contrast/api/decorators/address.rb +1 -1
- data/lib/contrast/api/decorators/agent_startup.rb +1 -1
- data/lib/contrast/api/decorators/application_settings.rb +1 -1
- data/lib/contrast/api/decorators/application_startup.rb +1 -1
- data/lib/contrast/api/decorators/application_update.rb +1 -1
- data/lib/contrast/api/decorators/architecture_component.rb +36 -0
- data/lib/contrast/api/decorators/finding.rb +29 -0
- data/lib/contrast/api/decorators/http_request.rb +3 -2
- data/lib/contrast/api/decorators/input_analysis.rb +1 -1
- data/lib/contrast/api/decorators/instrumentation_mode.rb +1 -1
- data/lib/contrast/api/decorators/library.rb +1 -1
- data/lib/contrast/api/decorators/library_usage_update.rb +1 -1
- data/lib/contrast/api/decorators/message.rb +1 -1
- data/lib/contrast/api/decorators/rasp_rule_sample.rb +1 -1
- data/lib/contrast/api/decorators/route_coverage.rb +1 -1
- data/lib/contrast/api/decorators/server_features.rb +1 -1
- data/lib/contrast/api/decorators/trace_event.rb +1 -1
- data/lib/contrast/api/decorators/trace_event_object.rb +1 -1
- data/lib/contrast/api/decorators/trace_event_signature.rb +1 -1
- data/lib/contrast/api/decorators/trace_taint_range.rb +1 -1
- data/lib/contrast/api/decorators/trace_taint_range_tags.rb +1 -1
- data/lib/contrast/api/decorators/user_input.rb +1 -1
- data/lib/contrast/api/decorators.rb +2 -1
- data/lib/contrast/api.rb +1 -1
- data/lib/contrast/components/agent.rb +5 -24
- data/lib/contrast/components/api.rb +67 -2
- data/lib/contrast/components/app_context.rb +12 -66
- data/lib/contrast/components/app_context_extend.rb +78 -0
- data/lib/contrast/components/assess.rb +12 -8
- data/lib/contrast/components/base.rb +24 -1
- data/lib/contrast/components/config.rb +38 -23
- data/lib/contrast/components/contrast_service.rb +6 -1
- data/lib/contrast/components/heap_dump.rb +1 -1
- data/lib/contrast/components/inventory.rb +5 -1
- data/lib/contrast/components/logger.rb +1 -1
- data/lib/contrast/components/protect.rb +6 -2
- data/lib/contrast/components/sampling.rb +3 -3
- data/lib/contrast/components/scope.rb +1 -1
- data/lib/contrast/components/settings.rb +25 -12
- data/lib/contrast/config/agent_configuration.rb +2 -2
- data/lib/contrast/config/api_configuration.rb +9 -4
- data/lib/contrast/config/api_proxy_configuration.rb +14 -0
- data/lib/contrast/config/application_configuration.rb +3 -4
- data/lib/contrast/config/assess_configuration.rb +4 -4
- data/lib/contrast/config/assess_rules_configuration.rb +1 -1
- data/lib/contrast/config/base_configuration.rb +18 -29
- data/lib/contrast/config/certification_configuration.rb +15 -0
- data/lib/contrast/config/env_variables.rb +3 -10
- data/lib/contrast/config/exception_configuration.rb +1 -1
- data/lib/contrast/config/heap_dump_configuration.rb +7 -7
- data/lib/contrast/config/inventory_configuration.rb +2 -6
- data/lib/contrast/config/logger_configuration.rb +1 -1
- data/lib/contrast/config/protect_configuration.rb +1 -1
- data/lib/contrast/config/protect_rule_configuration.rb +2 -2
- data/lib/contrast/config/protect_rules_configuration.rb +1 -1
- data/lib/contrast/config/request_audit_configuration.rb +18 -0
- data/lib/contrast/config/root_configuration.rb +1 -1
- data/lib/contrast/config/ruby_configuration.rb +10 -7
- data/lib/contrast/config/sampling_configuration.rb +1 -1
- data/lib/contrast/config/server_configuration.rb +1 -1
- data/lib/contrast/config/service_configuration.rb +2 -3
- data/lib/contrast/config.rb +1 -2
- data/lib/contrast/configuration.rb +2 -3
- data/lib/contrast/extension/assess/array.rb +9 -9
- data/lib/contrast/extension/assess/erb.rb +15 -5
- data/lib/contrast/extension/assess/eval_trigger.rb +3 -1
- data/lib/contrast/extension/assess/exec_trigger.rb +2 -1
- data/lib/contrast/extension/assess/fiber.rb +6 -3
- data/lib/contrast/extension/assess/hash.rb +1 -1
- data/lib/contrast/extension/assess/kernel.rb +8 -3
- data/lib/contrast/extension/assess/marshal.rb +6 -2
- data/lib/contrast/extension/assess/regexp.rb +8 -2
- data/lib/contrast/extension/assess/string.rb +8 -2
- data/lib/contrast/extension/assess.rb +1 -1
- data/lib/contrast/extension/delegator.rb +1 -1
- data/lib/contrast/extension/extension.rb +2 -4
- data/lib/contrast/extension/inventory.rb +1 -1
- data/lib/contrast/extension/kernel.rb +1 -1
- data/lib/contrast/extension/module.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 +32 -13
- data/lib/contrast/framework/base_support.rb +5 -1
- data/lib/contrast/framework/grape/support.rb +25 -1
- data/lib/contrast/framework/manager.rb +33 -36
- data/lib/contrast/framework/manager_extend.rb +50 -0
- data/lib/contrast/framework/platform_version.rb +1 -1
- data/lib/contrast/framework/rack/patch/session_cookie.rb +1 -1
- 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 +2 -2
- data/lib/contrast/framework/rails/support.rb +46 -2
- data/lib/contrast/framework/sinatra/support.rb +26 -3
- data/lib/contrast/funchook/funchook.rb +21 -18
- data/lib/contrast/logger/application.rb +1 -1
- data/lib/contrast/logger/format.rb +1 -1
- data/lib/contrast/logger/log.rb +9 -104
- 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/tasks/service.rb +1 -1
- data/lib/contrast/utils/assess/propagation_method_utils.rb +1 -1
- data/lib/contrast/utils/assess/property/tagged_utils.rb +24 -1
- data/lib/contrast/utils/assess/sampling_util.rb +4 -4
- data/lib/contrast/utils/assess/source_method_utils.rb +1 -1
- data/lib/contrast/utils/assess/split_utils.rb +23 -0
- data/lib/contrast/utils/assess/tracking_util.rb +21 -16
- data/lib/contrast/utils/assess/trigger_method_utils.rb +4 -3
- data/lib/contrast/utils/class_util.rb +19 -15
- data/lib/contrast/utils/duck_utils.rb +1 -1
- data/lib/contrast/utils/env_configuration_item.rb +2 -2
- data/lib/contrast/utils/exclude_key.rb +1 -1
- data/lib/contrast/utils/findings.rb +65 -0
- data/lib/contrast/utils/hash_digest.rb +46 -79
- data/lib/contrast/utils/hash_digest_extend.rb +129 -0
- data/lib/contrast/utils/head_dump_utils_extend.rb +74 -0
- data/lib/contrast/utils/heap_dump_util.rb +3 -66
- data/lib/contrast/utils/invalid_configuration_util.rb +32 -2
- data/lib/contrast/utils/io_util.rb +2 -2
- data/lib/contrast/utils/job_servers_running.rb +1 -1
- data/lib/contrast/utils/log_utils.rb +108 -0
- data/lib/contrast/utils/lru_cache.rb +1 -1
- data/lib/contrast/utils/metrics_hash.rb +2 -2
- data/lib/contrast/utils/middleware_utils.rb +87 -0
- data/lib/contrast/utils/net_http_base.rb +165 -0
- data/lib/contrast/utils/object_share.rb +2 -6
- data/lib/contrast/utils/os.rb +9 -5
- data/lib/contrast/utils/patching/policy/patch_utils.rb +63 -99
- data/lib/contrast/utils/patching/policy/patcher_utils.rb +1 -1
- data/lib/contrast/utils/preflight_util.rb +1 -1
- data/lib/contrast/utils/request_utils.rb +96 -0
- data/lib/contrast/utils/resource_loader.rb +1 -1
- data/lib/contrast/utils/response_utils.rb +97 -0
- data/lib/contrast/utils/sha256_builder.rb +1 -1
- data/lib/contrast/utils/stack_trace_utils.rb +1 -1
- data/lib/contrast/utils/string_utils.rb +69 -67
- data/lib/contrast/utils/tag_util.rb +11 -10
- data/lib/contrast/utils/telemetry.rb +11 -10
- data/lib/contrast/utils/telemetry_client.rb +90 -0
- data/lib/contrast/utils/telemetry_identifier.rb +18 -25
- 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 +1 -1
- data/ruby-agent.gemspec +9 -10
- metadata +102 -49
- data/ext/cs__assess_active_record_named/cs__active_record_named.c +0 -46
- data/ext/cs__assess_active_record_named/cs__active_record_named.h +0 -11
- data/ext/cs__assess_active_record_named/extconf.rb +0 -5
- data/lib/contrast/agent/assess/policy/rewriter_patch.rb +0 -95
- data/lib/contrast/agent/class_reopener.rb +0 -258
- data/lib/contrast/agent/rewriter.rb +0 -259
- data/lib/contrast/config/default_value.rb +0 -17
- data/lib/contrast/framework/rails/rewrite/action_controller_railties_helper_inherited.rb +0 -37
- data/lib/contrast/framework/rails/rewrite/active_record_attribute_methods_read.rb +0 -41
- data/lib/contrast/framework/rails/rewrite/active_record_named.rb +0 -75
- data/lib/contrast/framework/rails/rewrite/active_record_time_zone_inherited.rb +0 -35
- data/lib/contrast/utils/requests_client.rb +0 -150
- data/lib/contrast/utils/ruby_ast_rewriter.rb +0 -82
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c)
|
1
|
+
# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require 'contrast/agent/reaction_processor'
|
@@ -7,10 +7,17 @@ require 'contrast/components/logger'
|
|
7
7
|
module Contrast
|
8
8
|
module Api
|
9
9
|
module Communication
|
10
|
-
# Handles processing deferred messages
|
10
|
+
# Handles processing deferred messages sent to SpeedRacer.
|
11
|
+
#
|
12
|
+
# @attr_reader last_app_update_ms [Integer] the time, in ms, that application settings last changed
|
13
|
+
# @attr_reader last_server_update_ms [Integer] the time, in ms, that server settings last changed
|
11
14
|
class ResponseProcessor
|
12
15
|
include Contrast::Components::Logger::InstanceMethods
|
16
|
+
attr_reader :last_app_update_ms, :last_server_update_ms
|
13
17
|
|
18
|
+
# Use the given response to update the Agent's server features and application settings, allowing it to reflect
|
19
|
+
# the latest options configured by the user in TeamServer
|
20
|
+
#
|
14
21
|
# @param response [Contrast::Api::Settings::AgentSettings]
|
15
22
|
def process response
|
16
23
|
logger.debug('Received a response', sent_ms: response&.sent_ms)
|
@@ -18,8 +25,8 @@ module Contrast
|
|
18
25
|
server_features = process_server_response(response)
|
19
26
|
app_settings = process_application_response(response)
|
20
27
|
|
21
|
-
# ReactionProcessor is a design pattern from TeamServer.
|
22
|
-
#
|
28
|
+
# ReactionProcessor is a design pattern from TeamServer. Right now, there's one potential reaction, which is
|
29
|
+
# disabling the agent
|
23
30
|
Contrast::Agent::ReactionProcessor.process(response&.application_settings)
|
24
31
|
|
25
32
|
Contrast::Logger::Log.instance.update(server_features&.log_file, server_features&.log_level)
|
@@ -30,10 +37,10 @@ module Contrast
|
|
30
37
|
|
31
38
|
private
|
32
39
|
|
33
|
-
# Given some protobuf messages, update server features.
|
34
|
-
# This is the bridge between Contrast Service <-> Settings.
|
40
|
+
# Given some protobuf messages, update server features. This is the bridge between SpeedRacer <-> Settings.
|
35
41
|
#
|
36
42
|
# @param response [Contrast::Api::Settings::AgentSettings]
|
43
|
+
# @return [Contrast::Api::Settings::ServerFeatures]
|
37
44
|
def process_server_response response
|
38
45
|
server_features = response&.server_features
|
39
46
|
return unless server_features
|
@@ -41,14 +48,15 @@ module Contrast
|
|
41
48
|
logger.trace('Agent: Received updated server features')
|
42
49
|
|
43
50
|
::Contrast::SETTINGS.update_from_server_features(server_features)
|
44
|
-
|
51
|
+
@last_server_update_ms = Contrast::Utils::Timer.now_ms
|
45
52
|
server_features
|
46
53
|
end
|
47
54
|
|
48
|
-
# Given some protobuf messages, update application settings.
|
49
|
-
#
|
55
|
+
# Given some protobuf messages, update application settings. This is the bridge between SpeedRacer <->
|
56
|
+
# Settings.
|
50
57
|
#
|
51
58
|
# @param response [Contrast::Api::Settings::AgentSettings]
|
59
|
+
# @return [Contrast::Api::Settings::ApplicationSettings]
|
52
60
|
def process_application_response response
|
53
61
|
app_settings = response&.application_settings
|
54
62
|
return unless app_settings
|
@@ -56,12 +64,15 @@ module Contrast
|
|
56
64
|
logger.debug('Agent: Received updated application settings')
|
57
65
|
|
58
66
|
::Contrast::SETTINGS.update_from_application_settings(app_settings)
|
59
|
-
|
67
|
+
@last_app_update_ms = Contrast::Utils::Timer.now_ms
|
60
68
|
app_settings
|
61
69
|
end
|
62
70
|
|
63
71
|
# This can't go in the Settings component because protect and assess depend on settings
|
64
|
-
# I don't think it should go into contrast_service because that only handles connection specific data
|
72
|
+
# I don't think it should go into contrast_service because that only handles connection specific data.
|
73
|
+
#
|
74
|
+
# @param server_features [Contrast::Api::Settings::AgentSettings, Array]
|
75
|
+
# @param app_settings [Contrast::Api::Settings::ApplicationSettings, Array]
|
65
76
|
def update_features server_features, app_settings
|
66
77
|
return unless !!(server_features || app_settings)
|
67
78
|
return unless ::Contrast::AGENT.enabled?
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c)
|
1
|
+
# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require 'contrast/components/logger'
|
@@ -13,6 +13,10 @@ module Contrast
|
|
13
13
|
|
14
14
|
private
|
15
15
|
|
16
|
+
# Attempt to start up a local process with SpeedRacer. This will ensure the process isn't just a zombie and is
|
17
|
+
# a real functioning process.
|
18
|
+
#
|
19
|
+
# @return [Boolean] Did the SpeedRacer process start?
|
16
20
|
def attempt_local_service_startup
|
17
21
|
zombie_check
|
18
22
|
service_starter_thread.join(5)
|
@@ -25,8 +29,8 @@ module Contrast
|
|
25
29
|
is_service_started
|
26
30
|
end
|
27
31
|
|
28
|
-
#
|
29
|
-
# to initialize
|
32
|
+
# Check if there's a zombie service that exists, and wait on it if so. Currently, this only happens when trying
|
33
|
+
# to initialize SpeedRacer. If there is a zombie, we'll wait until the zombie completes.
|
30
34
|
def zombie_check
|
31
35
|
zombie_pid_list = Contrast::Utils::OS.zombie_pids
|
32
36
|
zombie_pid_list.each do |pid|
|
@@ -36,6 +40,10 @@ module Contrast
|
|
36
40
|
end
|
37
41
|
end
|
38
42
|
|
43
|
+
# Determine the options used to set up the SpeedRacer process. Specifically, this handles if we need to adjust
|
44
|
+
# where the process needs to log.
|
45
|
+
#
|
46
|
+
# @return [Hash] options used to spawn the SpeedRacer process
|
39
47
|
def determine_startup_options
|
40
48
|
return { out: :out, err: :out } if ::Contrast::CONTRAST_SERVICE.logger_path == 'STDOUT'
|
41
49
|
return { out: :err, err: :err } if ::Contrast::CONTRAST_SERVICE.logger_path == 'STDERR'
|
@@ -43,13 +51,15 @@ module Contrast
|
|
43
51
|
{ out: File::NULL, err: File::NULL }
|
44
52
|
end
|
45
53
|
|
46
|
-
# This is a separate method so we can overwrite it globally in specs
|
54
|
+
# Create a new process for the SpeedRacer. This is a separate method so we can overwrite it globally in specs.
|
47
55
|
def spawn_service
|
48
56
|
options = determine_startup_options
|
49
57
|
logger.debug('Spawning service')
|
50
58
|
spawn 'contrast_service', options
|
51
59
|
end
|
52
60
|
|
61
|
+
# Create a thread to start the SpeedRacer, making calls to spawn until one starts successfully. As soon as the
|
62
|
+
# SpeedRacer process starts, this thread terminates.
|
53
63
|
def service_starter_thread
|
54
64
|
Contrast::Agent::Thread.new do
|
55
65
|
# Always check to see if it already started
|
@@ -1,19 +1,18 @@
|
|
1
|
-
# Copyright (c)
|
1
|
+
# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
module Contrast
|
5
5
|
module Api
|
6
6
|
module Communication
|
7
|
-
# Behavior common to all sockets used
|
8
|
-
# to communicate with the Contrast Service.
|
7
|
+
# Behavior common to all sockets used to communicate with the Contrast Service.
|
9
8
|
module Socket
|
10
9
|
SOCKET_MONITOR = Monitor.new
|
11
10
|
|
12
11
|
# Send a message across the socket and read back the response.
|
13
|
-
# @param marshaled [String] some marshaled form of data to be sent across
|
14
|
-
#
|
15
|
-
# @return [String] some marshalled form of data returned by the socket.
|
16
|
-
#
|
12
|
+
# @param marshaled [String] some marshaled form of data to be sent across the socket. Typically an encoded form
|
13
|
+
# of Contrast::Api::Dtm::Message.
|
14
|
+
# @return [String] some marshalled form of data returned by the socket. Typically an encoded form of
|
15
|
+
# Contrast::Api::Settings::AgentSettings.
|
17
16
|
def send_marshaled marshaled
|
18
17
|
SOCKET_MONITOR.synchronize do
|
19
18
|
socket = new_socket
|
@@ -34,8 +33,7 @@ module Contrast
|
|
34
33
|
end
|
35
34
|
end
|
36
35
|
|
37
|
-
# Override this method to return a socket.
|
38
|
-
# Should be interface compatible with TCPSocket, UNIXSocket, etc.
|
36
|
+
# Override this method to return a socket. Should be interface compatible with TCPSocket, UNIXSocket, etc.
|
39
37
|
def new_socket
|
40
38
|
raise NoMethodError, 'This is abstract, override it.'
|
41
39
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c)
|
1
|
+
# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require 'socket'
|
@@ -11,8 +11,8 @@ require 'contrast/components/logger'
|
|
11
11
|
module Contrast
|
12
12
|
module Api
|
13
13
|
module Communication
|
14
|
-
# SocketClient acts as a interface between the agent and the service. It instantiates a
|
15
|
-
#
|
14
|
+
# SocketClient acts as a interface between the agent and the service. It instantiates a service proxy and tracks
|
15
|
+
# the state of that proxy.
|
16
16
|
class SocketClient
|
17
17
|
include Contrast::Components::Logger::InstanceMethods
|
18
18
|
|
@@ -20,12 +20,13 @@ module Contrast
|
|
20
20
|
@socket = init_connection
|
21
21
|
end
|
22
22
|
|
23
|
-
# Wrap the given DTM in a Contrast::Api::Dtm::Message and send it to the
|
24
|
-
#
|
23
|
+
# Wrap the given DTM in a Contrast::Api::Dtm::Message and send it to the SpeedRacer for processing. The
|
24
|
+
# Message is the top level object required to communicate to SpeedRacer as it encompasses the information
|
25
|
+
# needed to find this process' context.
|
25
26
|
#
|
26
27
|
# @param event [Contrast::Api::Dtm] One of the DTMs valid for the event field of
|
27
28
|
# Contrast::Api::Dtm::Message
|
28
|
-
# @return [Contrast::Api::Settings::AgentSettings]
|
29
|
+
# @return [Contrast::Api::Settings::AgentSettings, nil]
|
29
30
|
def send_one event
|
30
31
|
msg = Contrast::Api::Dtm::Message.build(event)
|
31
32
|
send_message(msg)
|
@@ -33,6 +34,12 @@ module Contrast
|
|
33
34
|
|
34
35
|
private
|
35
36
|
|
37
|
+
# Initialize the connection to the SpeedRacer process based on the configuration provided by the user. This can
|
38
|
+
# be either TCP or UDP. Note that unlike the Go and the Node Agents, we cannot use the GRPC communication
|
39
|
+
# option as we cannot use Google's protobuf gems; they do not compile reliably and result in segmentation
|
40
|
+
# faults in customer environments.
|
41
|
+
#
|
42
|
+
# @return [Contrast::Api::Communication::TcpSocket, Contrast::Api::Communication::UnixSocket]
|
36
43
|
def init_connection
|
37
44
|
log_connection
|
38
45
|
if ::Contrast::CONTRAST_SERVICE.use_tcp?
|
@@ -43,6 +50,7 @@ module Contrast
|
|
43
50
|
end
|
44
51
|
end
|
45
52
|
|
53
|
+
# Log information about the connection being used to communicate between the Agent and SpeedRacer.
|
46
54
|
def log_connection
|
47
55
|
# The socket is set,
|
48
56
|
if ::Contrast::CONFIG.root.agent.service.socket
|
@@ -72,19 +80,24 @@ module Contrast
|
|
72
80
|
def log_connection_error_msg
|
73
81
|
if ::Contrast::CONFIG.root.agent.service.host
|
74
82
|
'Missing a required connection value to the Contrast Service. ' \
|
75
|
-
|
76
|
-
|
83
|
+
'`agent.service.port` is not set. ' \
|
84
|
+
'Falling back to default TCP socket port.'
|
77
85
|
elsif ::Contrast::CONFIG.root.agent.service.port
|
78
86
|
'Missing a required connection value to the Contrast Service. ' \
|
79
|
-
|
80
|
-
|
87
|
+
'`agent.service.host` is not set. ' \
|
88
|
+
'Falling back to default TCP socket host.'
|
81
89
|
else
|
82
90
|
'Missing a required connection value to the Contrast Service. ' \
|
83
|
-
|
84
|
-
|
91
|
+
'Neither `agent.service.socket` nor the pair of `agent.service.host` and `agent.service.port` are set. '\
|
92
|
+
'Falling back to default TCP socket.'
|
85
93
|
end
|
86
94
|
end
|
87
95
|
|
96
|
+
# Send the given message to SpeedRacer and return the response from it.
|
97
|
+
#
|
98
|
+
# @param msg [Contrast::Api::Dtm::Message] the packaged message to send to SpeedRacer
|
99
|
+
# @return [Contrast::Api::Settings::AgentSettings, nil]
|
100
|
+
# @raise [StandardError] if unable to send a message to SpeedRacer
|
88
101
|
def send_message msg
|
89
102
|
return unless msg
|
90
103
|
|
@@ -92,15 +105,22 @@ module Contrast
|
|
92
105
|
to_service = Contrast::Api::Dtm::Message.encode(msg)
|
93
106
|
from_service = send_marshaled(to_service)
|
94
107
|
response = Contrast::Api::Settings::AgentSettings.decode(from_service)
|
108
|
+
logger.debug('RESPONSE FROM TS')
|
109
|
+
logger.debug(from_service)
|
110
|
+
logger.debug('RESPONSE FROM TS')
|
95
111
|
logger.debug('Received response.', msg_id: msg.__id__, p_id: msg.pid, msg_count: msg.message_count,
|
96
112
|
response_id: response&.__id__)
|
97
113
|
response
|
98
114
|
rescue StandardError => e
|
99
115
|
logger.error('Sending failed for message.', e, msg_id: msg.__id__, p_id: msg.pid,
|
100
116
|
msg_count: msg.message_count, response_id: response&.__id__)
|
101
|
-
raise e # reraise to let
|
117
|
+
raise e # reraise to let SpeedRacer manage the connection
|
102
118
|
end
|
103
119
|
|
120
|
+
# Send the marshaled Contrast::Api::Dtm::Message across the socket used to talk to SpeedRacer
|
121
|
+
#
|
122
|
+
# @param marshaled [String]
|
123
|
+
# @return [String] the marshaled from of Contrast::Api::Settings::AgentSettings
|
104
124
|
def send_marshaled marshaled
|
105
125
|
@socket.send_marshaled(marshaled)
|
106
126
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c)
|
1
|
+
# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require 'contrast/components/logger'
|
@@ -6,7 +6,10 @@ require 'contrast/components/logger'
|
|
6
6
|
module Contrast
|
7
7
|
module Api
|
8
8
|
module Communication
|
9
|
-
# Wraps all connection data to
|
9
|
+
# Wraps all connection data to SpeedRacer. SpeedRacer, also known as the Contrast Service, is a standalone
|
10
|
+
# executable that sits between the Agent and TeamServer. It handles converting our Protobuf messages into a
|
11
|
+
# format consumable by TeamServer. The Agent requires a SpeedRacer process to be running somewhere to which it
|
12
|
+
# can connect, as specified by the user configuration, in order to function.
|
10
13
|
class Speedracer
|
11
14
|
include Contrast::Api::Communication::ServiceLifecycle
|
12
15
|
include Contrast::Components::Logger::InstanceMethods
|
@@ -20,6 +23,14 @@ module Contrast
|
|
20
23
|
@ensure_running = Mutex.new
|
21
24
|
end
|
22
25
|
|
26
|
+
# If there is not a SpeedRacer at the location specified by the configuration of this Agent and the Agent is
|
27
|
+
# set such that it should manage one, start up a new child process to run the SpeedRacer executable. If a
|
28
|
+
# connection has not already been made to that process, after starting it, this method will also send the
|
29
|
+
# messages necessary to create a context for this Agent process in the SpeedRacer as well as trigger
|
30
|
+
# SpeedRacer's sending of startup messages which will return features and settings from TeamServer.
|
31
|
+
#
|
32
|
+
# This operation is synchronous and blocking, so it will only happen one at a time per process and will halt
|
33
|
+
# Thread execution here until completion.
|
23
34
|
def ensure_startup!
|
24
35
|
return if status.connected?
|
25
36
|
|
@@ -40,12 +51,24 @@ module Contrast
|
|
40
51
|
end
|
41
52
|
end
|
42
53
|
|
54
|
+
# Send the given Event to SpeedRacer, returning the response from it. This response will either be new settings
|
55
|
+
# if anything's changed in TeamServer meaning the Agent needs to replace its current settings or there is
|
56
|
+
# Protect analysis information or nil if the current Agent settings do not need updating.
|
57
|
+
#
|
58
|
+
# @param event [Contrast::Api::Dtm] One of the DTMs valid for the event field of
|
59
|
+
# Contrast::Api::Dtm::Message|Contrast::Api::Dtm::Activity
|
60
|
+
# @return [Contrast::Api::Settings::AgentSettings,nil]
|
43
61
|
def return_response event
|
44
62
|
send_to_speedracer(event) do |response|
|
45
63
|
return response
|
46
64
|
end
|
47
65
|
end
|
48
66
|
|
67
|
+
# Send the given Event to SpeedRacer and pass the result to our Contrast::Api::Communication::ResponseProcessor
|
68
|
+
# as there is no immediate action required from sending this Event.
|
69
|
+
#
|
70
|
+
# @param event [Contrast::Api::Dtm] One of the DTMs valid for the event field of
|
71
|
+
# Contrast::Api::Dtm::Message|Contrast::Api::Dtm::Activity
|
49
72
|
def process_internally event
|
50
73
|
send_to_speedracer(event) do |response|
|
51
74
|
response_processor.process(response)
|
@@ -54,6 +77,12 @@ module Contrast
|
|
54
77
|
|
55
78
|
private
|
56
79
|
|
80
|
+
# Ensure there is a running SpeedRacer and then send the given Event to it. It is necessary to ensure the
|
81
|
+
# SpeedRacer is running as, if the process has crashed or restarted, we must rebuild our context there.
|
82
|
+
#
|
83
|
+
# @param event [Contrast::Api::Dtm] One of the DTMs valid for the event field of
|
84
|
+
# Contrast::Api::Dtm::Message|Contrast::Api::Dtm::Activity
|
85
|
+
# @return [Contrast::Api::Settings::AgentSettings, nil]
|
57
86
|
def send_to_speedracer event
|
58
87
|
ensure_startup!
|
59
88
|
|
@@ -68,6 +97,9 @@ module Contrast
|
|
68
97
|
nil
|
69
98
|
end
|
70
99
|
|
100
|
+
# Send those messages which are required to build a context for this Agent process on SpeedRacer as well as
|
101
|
+
# report server and application startup to TeamServer. With these messages, the SpeedRacer will be able to
|
102
|
+
# retrieve settings from TeamServer and provide those for the Agent to complete its initialization.
|
71
103
|
def send_initialization_messages
|
72
104
|
agent_startup_msg = ::Contrast::APP_CONTEXT.build_agent_startup_message
|
73
105
|
|
@@ -97,6 +129,10 @@ module Contrast
|
|
97
129
|
nil
|
98
130
|
end
|
99
131
|
|
132
|
+
# Log the startup message we're sending to SpeedRacer
|
133
|
+
#
|
134
|
+
# @param event [Contrast::Api::Dtm] One of the DTMs valid for the event field of
|
135
|
+
# Contrast::Api::Dtm::Message|Contrast::Api::Dtm::Activity
|
100
136
|
def log_send_event event
|
101
137
|
logger.debug('Immediately sending event.', event_id: event.__id__, event_type: event.cs__class.cs__name)
|
102
138
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c)
|
1
|
+
# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require 'contrast/api/communication/socket'
|
@@ -6,15 +6,15 @@ require 'contrast/api/communication/socket'
|
|
6
6
|
module Contrast
|
7
7
|
module Api
|
8
8
|
module Communication
|
9
|
-
# This class allows us to create a TCP Socket to communicate to the Service
|
10
|
-
#
|
11
|
-
# by the configuration options set for Service communication.
|
9
|
+
# This class allows us to create a TCP Socket to communicate to the Service (Speed Racer). Either it or the Unix
|
10
|
+
# Socket will be used, as determined by the configuration options set for Service communication.
|
12
11
|
class TcpSocket
|
13
12
|
include Contrast::Api::Communication::Socket
|
14
13
|
|
15
14
|
attr_reader :host, :port
|
16
15
|
|
17
16
|
# Create the socket
|
17
|
+
#
|
18
18
|
# @param host [String] socket target hostname or IP address
|
19
19
|
# @param port [String,Integer] socket target port
|
20
20
|
def initialize host, port
|
@@ -22,6 +22,7 @@ module Contrast
|
|
22
22
|
@port = port.to_i
|
23
23
|
end
|
24
24
|
|
25
|
+
# @return [::TCPSocket]
|
25
26
|
def new_socket
|
26
27
|
::TCPSocket.new(host, port)
|
27
28
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c)
|
1
|
+
# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require 'contrast/api/communication/socket'
|
@@ -18,6 +18,7 @@ module Contrast
|
|
18
18
|
@path = path
|
19
19
|
end
|
20
20
|
|
21
|
+
# @return [::UNIXSocket]
|
21
22
|
def new_socket
|
22
23
|
::UNIXSocket.new(path)
|
23
24
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c)
|
1
|
+
# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
module Contrast
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c)
|
1
|
+
# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require 'contrast/api/dtm.pb'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c)
|
1
|
+
# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require 'contrast/api/dtm.pb'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c)
|
1
|
+
# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require 'contrast/utils/string_utils'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c)
|
1
|
+
# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require 'contrast/api/dtm.pb'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c)
|
1
|
+
# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require 'contrast/utils/string_utils'
|
@@ -0,0 +1,36 @@
|
|
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/utils/string_utils'
|
5
|
+
|
6
|
+
module Contrast
|
7
|
+
module Api
|
8
|
+
module Decorators
|
9
|
+
# Used to decorate the {Contrast::Api::Dtm::ArchitectureComponent} protobuf model so it can own some of the data
|
10
|
+
# massaging required for AppUpdate and Activity dtms.
|
11
|
+
module ArchitectureComponent
|
12
|
+
def self.included klass
|
13
|
+
klass.extend(ClassMethods)
|
14
|
+
end
|
15
|
+
|
16
|
+
# Used to add class methods to the ApplicationUpdate class on inclusion of the decorator
|
17
|
+
module ClassMethods
|
18
|
+
# TeamServer only accepts certain values for ArchitectureComponents.
|
19
|
+
# DO NOT CHANGE THIS!
|
20
|
+
AC_TYPE_DB = 'db'
|
21
|
+
|
22
|
+
# Create a Contrast::Api::Dtm::ArchitectureComponent of the database type.
|
23
|
+
#
|
24
|
+
# @return [Contrast::Api::Dtm::ArchitectureComponent]
|
25
|
+
def build_database
|
26
|
+
msg = Contrast::Api::Dtm::ArchitectureComponent.new
|
27
|
+
msg.type = AC_TYPE_DB
|
28
|
+
msg
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
Contrast::Api::Dtm::ArchitectureComponent.include(Contrast::Api::Decorators::ArchitectureComponent)
|
@@ -0,0 +1,29 @@
|
|
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/api/dtm.pb'
|
5
|
+
require 'contrast/utils/string_utils'
|
6
|
+
require 'contrast/components/base'
|
7
|
+
|
8
|
+
module Contrast
|
9
|
+
module Api
|
10
|
+
module Decorators
|
11
|
+
# Used to decorate the {Contrast::Api::Dtm::Finding} protobuf
|
12
|
+
# model so it can own the request which its data is for.
|
13
|
+
module Finding
|
14
|
+
def self.included klass
|
15
|
+
klass.extend(ClassMethods)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Used to add class methods to the AgentStartup class on inclusion of the decorator
|
19
|
+
module ClassMethods
|
20
|
+
def build
|
21
|
+
new
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
Contrast::Api::Dtm::Finding.include(Contrast::Api::Decorators::Finding)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c)
|
1
|
+
# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require 'contrast/api/dtm.pb'
|
@@ -33,9 +33,10 @@ module Contrast
|
|
33
33
|
# @param request [Contrast::Agent::Request]
|
34
34
|
def append_connection request
|
35
35
|
self.protocol = Contrast::Utils::StringUtils.force_utf8(request.scheme)
|
36
|
-
self.version =
|
36
|
+
self.version = Contrast::Utils::StringUtils.force_utf8(request.version)
|
37
37
|
self.method = Contrast::Utils::StringUtils.force_utf8(request.request_method)
|
38
38
|
self.raw = Contrast::Utils::StringUtils.force_utf8(request.rack_request.path_info)
|
39
|
+
self.uri = Contrast::Utils::StringUtils.force_utf8(request.rack_request.path_info)
|
39
40
|
end
|
40
41
|
|
41
42
|
# Append the parameters to self, using the preferred
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c)
|
1
|
+
# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require 'contrast/utils/string_utils'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c)
|
1
|
+
# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require 'contrast/api/dtm.pb'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c)
|
1
|
+
# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require 'contrast/utils/string_utils'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c)
|
1
|
+
# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require 'contrast/utils/string_utils'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c)
|
1
|
+
# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require 'contrast/utils/object_share'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c)
|
1
|
+
# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
module Contrast
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c)
|
1
|
+
# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require 'contrast/utils/string_utils'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c)
|
1
|
+
# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require 'contrast/utils/string_utils'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c)
|
1
|
+
# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require 'contrast/utils/string_utils'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c)
|
1
|
+
# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require 'contrast/utils/string_utils'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c)
|
1
|
+
# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require 'contrast/utils/string_utils'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c)
|
1
|
+
# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require 'contrast/utils/object_share'
|