contrast-agent 6.6.4 → 6.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -2
- data/.gitmodules +0 -3
- data/.simplecov +0 -1
- data/Rakefile +0 -1
- data/ext/cs__assess_array/cs__assess_array.c +41 -10
- data/ext/cs__assess_array/cs__assess_array.h +4 -1
- data/ext/cs__scope/cs__scope.c +1 -1
- data/lib/contrast/agent/assess/contrast_event.rb +2 -24
- data/lib/contrast/agent/assess/events/source_event.rb +7 -61
- data/lib/contrast/agent/assess/finalizers/hash.rb +11 -0
- data/lib/contrast/agent/assess/policy/dynamic_source_factory.rb +0 -55
- data/lib/contrast/agent/assess/policy/policy_node.rb +3 -3
- data/lib/contrast/agent/assess/policy/policy_node_utils.rb +0 -1
- data/lib/contrast/agent/assess/policy/propagation_node.rb +4 -4
- data/lib/contrast/agent/assess/policy/source_method.rb +24 -1
- data/lib/contrast/agent/assess/policy/trigger/reflected_xss.rb +7 -5
- data/lib/contrast/agent/assess/policy/trigger/xpath.rb +6 -1
- data/lib/contrast/agent/assess/policy/trigger_method.rb +40 -121
- data/lib/contrast/agent/assess/policy/trigger_node.rb +3 -3
- 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/xss_validator.rb +1 -1
- data/lib/contrast/agent/assess/property/evented.rb +2 -12
- data/lib/contrast/agent/assess/rule/provider/hardcoded_value_rule.rb +42 -82
- data/lib/contrast/agent/assess/rule/response/base_rule.rb +11 -27
- data/lib/contrast/agent/assess/rule/response/body_rule.rb +1 -3
- data/lib/contrast/agent/assess/rule/response/cache_control_header_rule.rb +77 -62
- data/lib/contrast/agent/assess/rule/response/csp_header_insecure_rule.rb +1 -1
- data/lib/contrast/agent/assess/rule/response/framework/rails_support.rb +6 -1
- data/lib/contrast/agent/assess/rule/response/header_rule.rb +5 -5
- data/lib/contrast/agent/assess/rule/response/hsts_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/tracker.rb +1 -7
- data/lib/contrast/agent/at_exit_hook.rb +1 -7
- data/lib/contrast/agent/excluder.rb +224 -0
- data/lib/contrast/agent/exclusion_matcher.rb +25 -7
- data/lib/contrast/agent/inventory/database_config.rb +18 -23
- data/lib/contrast/agent/middleware.rb +4 -5
- data/lib/contrast/agent/patching/policy/after_load_patcher.rb +6 -0
- data/lib/contrast/agent/protect/input_analyzer/input_analyzer.rb +146 -127
- data/lib/contrast/agent/protect/policy/applies_command_injection_rule.rb +4 -0
- data/lib/contrast/agent/protect/policy/applies_path_traversal_rule.rb +20 -0
- data/lib/contrast/agent/protect/policy/applies_sqli_rule.rb +1 -0
- data/lib/contrast/agent/protect/policy/rule_applicator.rb +1 -1
- data/lib/contrast/agent/protect/rule/base.rb +98 -66
- data/lib/contrast/agent/protect/rule/base_service.rb +49 -24
- data/lib/contrast/agent/protect/rule/bot_blocker/bot_blocker_input_classification.rb +98 -0
- data/lib/contrast/agent/protect/rule/bot_blocker.rb +81 -0
- data/lib/contrast/agent/protect/rule/cmd_injection.rb +30 -99
- data/lib/contrast/agent/protect/rule/cmdi/cmdi_backdoors.rb +132 -0
- data/lib/contrast/agent/protect/rule/cmdi/cmdi_base_rule.rb +169 -0
- data/lib/contrast/agent/protect/rule/cmdi/cmdi_chained_command.rb +69 -0
- data/lib/contrast/agent/protect/rule/cmdi/cmdi_dangerous_path.rb +68 -0
- data/lib/contrast/agent/protect/rule/cmdi/cmdi_input_classification.rb +2 -58
- data/lib/contrast/agent/protect/rule/default_scanner.rb +1 -1
- data/lib/contrast/agent/protect/rule/deserialization.rb +10 -19
- data/lib/contrast/agent/protect/rule/http_method_tampering/http_method_tampering_input_classification.rb +2 -2
- data/lib/contrast/agent/protect/rule/http_method_tampering.rb +0 -11
- data/lib/contrast/agent/protect/rule/no_sqli/no_sqli_input_classification.rb +29 -34
- data/lib/contrast/agent/protect/rule/no_sqli.rb +25 -18
- data/lib/contrast/agent/protect/rule/path_traversal/path_traversal_input_classification.rb +61 -0
- data/lib/contrast/agent/protect/rule/path_traversal/path_traversal_semantic_security_bypass.rb +114 -0
- data/lib/contrast/agent/protect/rule/path_traversal.rb +46 -18
- data/lib/contrast/agent/protect/rule/sql_sample_builder.rb +49 -29
- data/lib/contrast/agent/protect/rule/sqli/sqli_base_rule.rb +37 -0
- data/lib/contrast/agent/protect/rule/sqli/sqli_input_classification.rb +2 -62
- data/lib/contrast/agent/protect/rule/sqli/sqli_semantic/sqli_dangerous_functions.rb +67 -0
- data/lib/contrast/agent/protect/rule/sqli.rb +67 -22
- data/lib/contrast/agent/protect/rule/unsafe_file_upload/unsafe_file_upload_input_classification.rb +39 -63
- data/lib/contrast/agent/protect/rule/unsafe_file_upload.rb +6 -33
- data/lib/contrast/agent/protect/rule/xss/reflected_xss_input_classification.rb +58 -0
- data/lib/contrast/agent/protect/rule/xss.rb +14 -20
- data/lib/contrast/agent/protect/rule/xxe.rb +15 -30
- data/lib/contrast/agent/protect/rule.rb +3 -1
- data/lib/contrast/agent/reporting/attack_result/attack_result.rb +8 -0
- data/lib/contrast/agent/reporting/attack_result/rasp_rule_sample.rb +70 -36
- data/lib/contrast/agent/reporting/attack_result/response_type.rb +9 -9
- data/lib/contrast/agent/reporting/attack_result/user_input.rb +11 -0
- data/lib/contrast/agent/reporting/details/bot_blocker_details.rb +29 -0
- data/lib/contrast/agent/reporting/details/cmd_injection_details.rb +30 -0
- data/lib/contrast/agent/reporting/details/details.rb +18 -0
- data/lib/contrast/agent/reporting/details/http_method_tempering_details.rb +27 -0
- data/lib/contrast/agent/reporting/details/ip_denylist_details.rb +35 -0
- data/lib/contrast/agent/reporting/details/no_sqli_details.rb +36 -0
- data/lib/contrast/agent/reporting/details/path_traversal_details.rb +24 -0
- data/lib/contrast/agent/reporting/details/path_traversal_semantic_analysis_details.rb +32 -0
- data/lib/contrast/agent/reporting/details/protect_rule_details.rb +17 -0
- data/lib/contrast/agent/reporting/details/sqli_dangerous_functions.rb +22 -0
- data/lib/contrast/agent/reporting/details/sqli_details.rb +36 -0
- data/lib/contrast/agent/reporting/details/untrusted_deserialization_details.rb +27 -0
- data/lib/contrast/agent/reporting/details/virtual_patch_details.rb +30 -0
- data/lib/contrast/agent/reporting/details/xss_details.rb +33 -0
- data/lib/contrast/agent/reporting/details/xss_match.rb +30 -0
- data/lib/contrast/agent/reporting/details/xxe_details.rb +36 -0
- data/lib/contrast/agent/reporting/details/xxe_match.rb +25 -0
- data/lib/contrast/agent/reporting/details/xxe_wrapper.rb +25 -0
- data/lib/contrast/agent/reporting/input_analysis/details/bot_blocker_details.rb +27 -0
- data/lib/contrast/agent/reporting/input_analysis/details/protect_rule_details.rb +15 -0
- data/lib/contrast/agent/reporting/input_analysis/input_analysis.rb +1 -2
- data/lib/contrast/agent/reporting/input_analysis/input_analysis_result.rb +17 -3
- data/lib/contrast/agent/reporting/masker/masker.rb +80 -65
- data/lib/contrast/agent/reporting/masker/masker_utils.rb +1 -30
- data/lib/contrast/agent/reporting/reporter.rb +1 -15
- data/lib/contrast/agent/reporting/reporting_events/agent_startup.rb +2 -2
- data/lib/contrast/agent/reporting/reporting_events/application_activity.rb +84 -15
- data/lib/contrast/agent/reporting/reporting_events/application_defend_activity.rb +13 -25
- data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_activity.rb +19 -24
- data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample.rb +46 -126
- data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample_activity.rb +5 -16
- data/lib/contrast/agent/reporting/reporting_events/application_defend_attacker_activity.rb +10 -18
- data/lib/contrast/agent/reporting/reporting_events/application_inventory_activity.rb +6 -14
- data/lib/contrast/agent/reporting/reporting_events/application_startup.rb +1 -1
- data/lib/contrast/agent/reporting/reporting_events/application_update.rb +0 -2
- data/lib/contrast/agent/reporting/reporting_events/architecture_component.rb +7 -22
- data/lib/contrast/agent/reporting/reporting_events/finding.rb +23 -53
- data/lib/contrast/agent/reporting/reporting_events/finding_event.rb +12 -9
- data/lib/contrast/agent/reporting/reporting_events/finding_event_signature.rb +1 -1
- data/lib/contrast/agent/reporting/reporting_events/finding_event_source.rb +23 -21
- data/lib/contrast/agent/reporting/reporting_events/finding_event_stack.rb +5 -18
- data/lib/contrast/agent/reporting/reporting_events/finding_event_taint_range.rb +1 -0
- data/lib/contrast/{api/decorators/trace_taint_range_tags.rb → agent/reporting/reporting_events/finding_event_taint_range_tags.rb} +7 -6
- data/lib/contrast/agent/reporting/reporting_events/finding_request.rb +40 -10
- data/lib/contrast/agent/reporting/reporting_events/library_discovery.rb +0 -1
- data/lib/contrast/agent/reporting/reporting_events/library_usage_observation.rb +1 -1
- data/lib/contrast/agent/reporting/reporting_events/observed_route.rb +2 -2
- data/lib/contrast/agent/reporting/reporting_events/poll.rb +1 -11
- data/lib/contrast/agent/reporting/reporting_events/preflight_message.rb +10 -14
- data/lib/contrast/agent/reporting/reporting_events/reporting_event.rb +11 -0
- data/lib/contrast/agent/reporting/reporting_events/route_coverage.rb +3 -1
- data/lib/contrast/agent/reporting/reporting_events/route_discovery.rb +12 -25
- data/lib/contrast/agent/reporting/reporting_events/route_discovery_observation.rb +8 -27
- data/lib/contrast/agent/reporting/reporting_utilities/audit.rb +3 -3
- data/lib/contrast/agent/reporting/reporting_utilities/build_preflight.rb +4 -7
- data/lib/contrast/agent/reporting/reporting_utilities/headers.rb +1 -1
- data/lib/contrast/agent/reporting/reporting_utilities/reporter_client.rb +2 -1
- data/lib/contrast/agent/reporting/reporting_utilities/reporter_client_utils.rb +3 -3
- data/lib/contrast/agent/reporting/reporting_utilities/response.rb +1 -1
- data/lib/contrast/agent/reporting/reporting_utilities/response_handler.rb +0 -3
- data/lib/contrast/agent/reporting/reporting_utilities/response_handler_utils.rb +1 -0
- data/lib/contrast/agent/reporting/settings/code_exclusion.rb +6 -1
- data/lib/contrast/agent/reporting/settings/exclusion_base.rb +18 -0
- data/lib/contrast/agent/reporting/settings/exclusions.rb +2 -1
- data/lib/contrast/agent/reporting/settings/input_exclusion.rb +9 -3
- data/lib/contrast/agent/reporting/settings/protect.rb +15 -15
- data/lib/contrast/agent/request.rb +4 -14
- data/lib/contrast/agent/request_context.rb +18 -24
- data/lib/contrast/agent/request_context_extend.rb +23 -164
- data/lib/contrast/agent/request_handler.rb +1 -11
- data/lib/contrast/agent/response.rb +0 -18
- data/lib/contrast/agent/telemetry/events/event.rb +1 -1
- data/lib/contrast/agent/telemetry/events/metric_event.rb +1 -1
- data/lib/contrast/agent/telemetry/events/startup_metrics_event.rb +3 -3
- data/lib/contrast/agent/thread_watcher.rb +3 -18
- data/lib/contrast/agent/version.rb +1 -1
- data/lib/contrast/agent.rb +0 -11
- data/lib/contrast/agent_lib/api/command_injection.rb +46 -0
- data/lib/contrast/agent_lib/api/init.rb +101 -0
- data/lib/contrast/agent_lib/api/input_tracing.rb +267 -0
- data/lib/contrast/agent_lib/api/method_tempering.rb +29 -0
- data/lib/contrast/agent_lib/api/panic.rb +87 -0
- data/lib/contrast/agent_lib/api/path_semantic_file_security_bypass.rb +40 -0
- data/lib/contrast/agent_lib/interface.rb +260 -0
- data/lib/contrast/agent_lib/interface_base.rb +118 -0
- data/lib/contrast/agent_lib/return_types/eval_result.rb +44 -0
- data/lib/contrast/agent_lib/test.rb +29 -0
- data/lib/contrast/api/communication/connection_status.rb +5 -5
- data/lib/contrast/components/agent.rb +13 -23
- data/lib/contrast/components/api.rb +10 -10
- data/lib/contrast/components/app_context.rb +9 -11
- data/lib/contrast/components/app_context_extend.rb +1 -26
- data/lib/contrast/components/assess.rb +92 -38
- data/lib/contrast/components/assess_rules.rb +36 -0
- data/lib/contrast/components/config.rb +49 -24
- data/lib/contrast/components/heap_dump.rb +1 -1
- data/lib/contrast/components/protect.rb +9 -6
- data/lib/contrast/components/ruby_component.rb +81 -0
- data/lib/contrast/components/sampling.rb +1 -1
- data/lib/contrast/components/security_logger.rb +23 -0
- data/lib/contrast/components/settings.rb +41 -85
- data/lib/contrast/config/base_configuration.rb +1 -1
- data/lib/contrast/config/protect_rule_configuration.rb +7 -7
- data/lib/contrast/config/protect_rules_configuration.rb +24 -48
- data/lib/contrast/config/server_configuration.rb +1 -1
- data/lib/contrast/config.rb +0 -6
- data/lib/contrast/configuration.rb +73 -18
- data/lib/contrast/extension/assess/array.rb +9 -0
- data/lib/contrast/extension/assess/exec_trigger.rb +3 -1
- data/lib/contrast/extension/assess/marshal.rb +3 -2
- data/lib/contrast/extension/assess/string.rb +0 -1
- data/lib/contrast/extension/delegator.rb +2 -0
- data/lib/contrast/extension/extension.rb +1 -1
- data/lib/contrast/framework/base_support.rb +0 -5
- data/lib/contrast/framework/grape/support.rb +1 -23
- data/lib/contrast/framework/manager.rb +3 -11
- data/lib/contrast/framework/rails/patch/action_controller_live_buffer.rb +1 -6
- data/lib/contrast/framework/rails/railtie.rb +0 -1
- data/lib/contrast/framework/rails/support.rb +5 -59
- data/lib/contrast/framework/sinatra/support.rb +2 -21
- data/lib/contrast/logger/cef_log.rb +21 -3
- data/lib/contrast/logger/log.rb +1 -11
- data/lib/contrast/tasks/config.rb +5 -10
- data/lib/contrast/utils/assess/event_limit_utils.rb +28 -12
- data/lib/contrast/utils/assess/trigger_method_utils.rb +10 -18
- data/lib/contrast/utils/duck_utils.rb +1 -0
- data/lib/contrast/utils/findings.rb +6 -5
- data/lib/contrast/utils/hash_digest.rb +9 -24
- data/lib/contrast/utils/hash_digest_extend.rb +6 -6
- data/lib/contrast/utils/input_classification_base.rb +156 -0
- data/lib/contrast/utils/invalid_configuration_util.rb +21 -58
- data/lib/contrast/utils/log_utils.rb +47 -17
- data/lib/contrast/utils/net_http_base.rb +2 -2
- data/lib/contrast/utils/os.rb +0 -20
- data/lib/contrast/utils/patching/policy/patch_utils.rb +3 -2
- data/lib/contrast/utils/response_utils.rb +0 -16
- data/lib/contrast/utils/stack_trace_utils.rb +3 -40
- data/lib/contrast/utils/string_utils.rb +19 -7
- data/lib/contrast/utils/telemetry_client.rb +13 -7
- data/lib/contrast.rb +7 -13
- data/resources/protect/policy.json +1 -2
- data/ruby-agent.gemspec +2 -5
- metadata +78 -137
- data/exe/contrast_service +0 -23
- data/lib/contrast/agent/protect/rule/cmdi/cmdi_worth_watching.rb +0 -64
- data/lib/contrast/agent/protect/rule/sqli/sqli_worth_watching.rb +0 -118
- data/lib/contrast/agent/protect/rule/unsafe_file_upload/unsafe_file_upload_matcher.rb +0 -45
- data/lib/contrast/agent/reaction_processor.rb +0 -47
- data/lib/contrast/agent/reporting/reporting_events/trace_event_source.rb +0 -30
- data/lib/contrast/agent/reporting/reporting_utilities/dtm_message.rb +0 -43
- data/lib/contrast/agent/service_heartbeat.rb +0 -35
- data/lib/contrast/api/communication/messaging_queue.rb +0 -129
- data/lib/contrast/api/communication/response_processor.rb +0 -90
- data/lib/contrast/api/communication/service_lifecycle.rb +0 -77
- data/lib/contrast/api/communication/socket.rb +0 -44
- data/lib/contrast/api/communication/socket_client.rb +0 -130
- data/lib/contrast/api/communication/speedracer.rb +0 -142
- data/lib/contrast/api/communication/tcp_socket.rb +0 -32
- data/lib/contrast/api/communication/unix_socket.rb +0 -28
- data/lib/contrast/api/communication.rb +0 -20
- data/lib/contrast/api/decorators/activity.rb +0 -33
- data/lib/contrast/api/decorators/address.rb +0 -59
- data/lib/contrast/api/decorators/agent_startup.rb +0 -57
- data/lib/contrast/api/decorators/application_settings.rb +0 -42
- data/lib/contrast/api/decorators/application_startup.rb +0 -56
- data/lib/contrast/api/decorators/architecture_component.rb +0 -36
- data/lib/contrast/api/decorators/bot_blocker.rb +0 -37
- data/lib/contrast/api/decorators/finding.rb +0 -29
- data/lib/contrast/api/decorators/http_request.rb +0 -137
- data/lib/contrast/api/decorators/input_analysis.rb +0 -18
- data/lib/contrast/api/decorators/instrumentation_mode.rb +0 -35
- data/lib/contrast/api/decorators/ip_denylist.rb +0 -37
- data/lib/contrast/api/decorators/message.rb +0 -71
- data/lib/contrast/api/decorators/rasp_rule_sample.rb +0 -58
- data/lib/contrast/api/decorators/response_type.rb +0 -17
- data/lib/contrast/api/decorators/route_coverage.rb +0 -91
- data/lib/contrast/api/decorators/server_features.rb +0 -25
- data/lib/contrast/api/decorators/trace_event.rb +0 -120
- data/lib/contrast/api/decorators/trace_event_object.rb +0 -63
- data/lib/contrast/api/decorators/trace_event_signature.rb +0 -69
- data/lib/contrast/api/decorators/trace_taint_range.rb +0 -52
- data/lib/contrast/api/decorators/user_input.rb +0 -51
- data/lib/contrast/api/decorators/virtual_patch.rb +0 -34
- data/lib/contrast/api/decorators.rb +0 -28
- data/lib/contrast/api/dtm.pb.rb +0 -852
- data/lib/contrast/api/settings.pb.rb +0 -500
- data/lib/contrast/api.rb +0 -16
- data/lib/contrast/components/contrast_service.rb +0 -88
- data/lib/contrast/config/assess_configuration.rb +0 -93
- data/lib/contrast/config/assess_rules_configuration.rb +0 -32
- data/lib/contrast/config/root_configuration.rb +0 -90
- data/lib/contrast/config/ruby_configuration.rb +0 -81
- data/lib/contrast/config/service_configuration.rb +0 -49
- data/lib/contrast/tasks/service.rb +0 -84
- data/lib/contrast/utils/input_classification.rb +0 -73
- data/lib/contrast/utils/preflight_util.rb +0 -13
- data/lib/protobuf/code_generator.rb +0 -129
- data/lib/protobuf/decoder.rb +0 -28
- data/lib/protobuf/deprecation.rb +0 -117
- data/lib/protobuf/descriptors/google/protobuf/compiler/plugin.pb.rb +0 -79
- data/lib/protobuf/descriptors/google/protobuf/descriptor.pb.rb +0 -360
- data/lib/protobuf/descriptors.rb +0 -3
- data/lib/protobuf/encoder.rb +0 -11
- data/lib/protobuf/enum.rb +0 -365
- data/lib/protobuf/exceptions.rb +0 -9
- data/lib/protobuf/field/base_field.rb +0 -380
- data/lib/protobuf/field/base_field_object_definitions.rb +0 -504
- data/lib/protobuf/field/bool_field.rb +0 -64
- data/lib/protobuf/field/bytes_field.rb +0 -67
- data/lib/protobuf/field/double_field.rb +0 -25
- data/lib/protobuf/field/enum_field.rb +0 -56
- data/lib/protobuf/field/field_array.rb +0 -102
- data/lib/protobuf/field/field_hash.rb +0 -122
- data/lib/protobuf/field/fixed32_field.rb +0 -25
- data/lib/protobuf/field/fixed64_field.rb +0 -28
- data/lib/protobuf/field/float_field.rb +0 -43
- data/lib/protobuf/field/int32_field.rb +0 -21
- data/lib/protobuf/field/int64_field.rb +0 -34
- data/lib/protobuf/field/integer_field.rb +0 -23
- data/lib/protobuf/field/message_field.rb +0 -51
- data/lib/protobuf/field/sfixed32_field.rb +0 -27
- data/lib/protobuf/field/sfixed64_field.rb +0 -28
- data/lib/protobuf/field/signed_integer_field.rb +0 -29
- data/lib/protobuf/field/sint32_field.rb +0 -21
- data/lib/protobuf/field/sint64_field.rb +0 -21
- data/lib/protobuf/field/string_field.rb +0 -51
- data/lib/protobuf/field/uint32_field.rb +0 -21
- data/lib/protobuf/field/uint64_field.rb +0 -21
- data/lib/protobuf/field/varint_field.rb +0 -77
- data/lib/protobuf/field.rb +0 -74
- data/lib/protobuf/generators/base.rb +0 -85
- data/lib/protobuf/generators/enum_generator.rb +0 -39
- data/lib/protobuf/generators/extension_generator.rb +0 -27
- data/lib/protobuf/generators/field_generator.rb +0 -193
- data/lib/protobuf/generators/file_generator.rb +0 -262
- data/lib/protobuf/generators/group_generator.rb +0 -122
- data/lib/protobuf/generators/message_generator.rb +0 -104
- data/lib/protobuf/generators/option_generator.rb +0 -17
- data/lib/protobuf/generators/printable.rb +0 -160
- data/lib/protobuf/generators/service_generator.rb +0 -50
- data/lib/protobuf/lifecycle.rb +0 -33
- data/lib/protobuf/logging.rb +0 -39
- data/lib/protobuf/message/fields.rb +0 -233
- data/lib/protobuf/message/serialization.rb +0 -85
- data/lib/protobuf/message.rb +0 -241
- data/lib/protobuf/optionable.rb +0 -72
- data/lib/protobuf/tasks/compile.rake +0 -80
- data/lib/protobuf/tasks.rb +0 -1
- data/lib/protobuf/varint.rb +0 -20
- data/lib/protobuf/varint_pure.rb +0 -31
- data/lib/protobuf/version.rb +0 -3
- data/lib/protobuf/wire_type.rb +0 -10
- data/lib/protobuf.rb +0 -91
- data/proto/dynamic_discovery.proto +0 -46
- data/proto/google/protobuf/compiler/plugin.proto +0 -183
- data/proto/google/protobuf/descriptor.proto +0 -911
- data/proto/rpc.proto +0 -71
- data/service_executables/.gitkeep +0 -0
- data/service_executables/VERSION +0 -1
- data/service_executables/linux/contrast-service +0 -0
- data/service_executables/mac/contrast-service +0 -0
@@ -1,142 +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
|
-
|
6
|
-
module Contrast
|
7
|
-
module Api
|
8
|
-
module Communication
|
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.
|
13
|
-
class Speedracer
|
14
|
-
include Contrast::Api::Communication::ServiceLifecycle
|
15
|
-
include Contrast::Components::Logger::InstanceMethods
|
16
|
-
|
17
|
-
attr_reader :status, :response_processor, :socket_client, :ensure_running
|
18
|
-
|
19
|
-
def initialize
|
20
|
-
@status = Contrast::Api::Communication::ConnectionStatus.new
|
21
|
-
@socket_client = Contrast::Api::Communication::SocketClient.new
|
22
|
-
@response_processor = Contrast::Api::Communication::ResponseProcessor.new
|
23
|
-
@ensure_running = Mutex.new
|
24
|
-
end
|
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.
|
34
|
-
def ensure_startup!
|
35
|
-
return if status.connected?
|
36
|
-
|
37
|
-
ensure_running.synchronize do
|
38
|
-
if ::Contrast::CONTRAST_SERVICE.use_bundled_service?
|
39
|
-
logger.info('Attempting to start local service')
|
40
|
-
unless attempt_local_service_startup
|
41
|
-
logger.error('Failed to start local service')
|
42
|
-
return
|
43
|
-
end
|
44
|
-
end
|
45
|
-
unless status.startup_messages_sent? || Contrast::CONTRAST_SERVICE.unnecessary?
|
46
|
-
startup_responses = send_initialization_messages
|
47
|
-
return false unless startup_responses
|
48
|
-
|
49
|
-
startup_responses.each { |response| response_processor.process(response) }
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
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]
|
61
|
-
def return_response event
|
62
|
-
send_to_speedracer(event) do |response|
|
63
|
-
return response
|
64
|
-
end
|
65
|
-
end
|
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
|
72
|
-
def process_internally event
|
73
|
-
send_to_speedracer(event) do |response|
|
74
|
-
response_processor.process(response)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
private
|
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]
|
86
|
-
def send_to_speedracer event
|
87
|
-
ensure_startup!
|
88
|
-
|
89
|
-
logger.debug_with_time(event.cs__class.cs__name) do
|
90
|
-
response = socket_client.send_one(event)
|
91
|
-
status.success!
|
92
|
-
yield(response)
|
93
|
-
end
|
94
|
-
rescue StandardError => e
|
95
|
-
status.failure!
|
96
|
-
logger.error('Unable to send message.', e, event_id: event.__id__, event_type: event.cs__class.cs__name)
|
97
|
-
nil
|
98
|
-
end
|
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.
|
103
|
-
def send_initialization_messages
|
104
|
-
agent_startup_msg = ::Contrast::APP_CONTEXT.build_agent_startup_message
|
105
|
-
|
106
|
-
logger.debug('Preparing to send startup messages')
|
107
|
-
# 1 initial attempt, + 3 potential retries.
|
108
|
-
# The agent-service-api REQUIREMENTS.md spec mandates this #.
|
109
|
-
4.times do
|
110
|
-
log_send_event(agent_startup_msg)
|
111
|
-
next unless (agent_response = socket_client.send_one(agent_startup_msg))
|
112
|
-
|
113
|
-
# Connection was successful; send app create with the resolved features.
|
114
|
-
app_startup_msg = ::Contrast::APP_CONTEXT.build_app_startup_message
|
115
|
-
log_send_event(app_startup_msg)
|
116
|
-
app_response = socket_client.send_one(app_startup_msg)
|
117
|
-
|
118
|
-
status.success!
|
119
|
-
logger.debug('Successfully sent startup messages to service.')
|
120
|
-
return [agent_response, app_response]
|
121
|
-
end
|
122
|
-
|
123
|
-
status.failure!
|
124
|
-
logger.error('Could not send agent startup message context')
|
125
|
-
nil
|
126
|
-
rescue StandardError => e
|
127
|
-
logger.error('Could not build service context', e)
|
128
|
-
status.failure!
|
129
|
-
nil
|
130
|
-
end
|
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
|
136
|
-
def log_send_event event
|
137
|
-
logger.debug('Immediately sending event.', event_id: event.__id__, event_type: event.cs__class.cs__name)
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end
|
142
|
-
end
|
@@ -1,32 +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/api/communication/socket'
|
5
|
-
|
6
|
-
module Contrast
|
7
|
-
module Api
|
8
|
-
module 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.
|
11
|
-
class TcpSocket
|
12
|
-
include Contrast::Api::Communication::Socket
|
13
|
-
|
14
|
-
attr_reader :host, :port
|
15
|
-
|
16
|
-
# Create the socket
|
17
|
-
#
|
18
|
-
# @param host [String] socket target hostname or IP address
|
19
|
-
# @param port [String,Integer] socket target port
|
20
|
-
def initialize host, port
|
21
|
-
@host = host.to_s
|
22
|
-
@port = port.to_i
|
23
|
-
end
|
24
|
-
|
25
|
-
# @return [::TCPSocket]
|
26
|
-
def new_socket
|
27
|
-
::TCPSocket.new(host, port)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,28 +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/api/communication/socket'
|
5
|
-
|
6
|
-
module Contrast
|
7
|
-
module Api
|
8
|
-
module Communication
|
9
|
-
# Implements a UNIX domain socket to connect to the Contrast Service.
|
10
|
-
class UnixSocket
|
11
|
-
include Contrast::Api::Communication::Socket
|
12
|
-
|
13
|
-
attr_reader :path
|
14
|
-
|
15
|
-
# Create the socket
|
16
|
-
# @param path [String] file path to a UNIX domain socket
|
17
|
-
def initialize path
|
18
|
-
@path = path
|
19
|
-
end
|
20
|
-
|
21
|
-
# @return [::UNIXSocket]
|
22
|
-
def new_socket
|
23
|
-
::UNIXSocket.new(path)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,20 +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 Api
|
6
|
-
# Used to contain all modules that handle communication with speedracer
|
7
|
-
module Communication
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
require 'contrast/api/communication/service_lifecycle'
|
13
|
-
require 'contrast/api/communication/connection_status'
|
14
|
-
require 'contrast/api/communication/socket'
|
15
|
-
require 'contrast/api/communication/tcp_socket'
|
16
|
-
require 'contrast/api/communication/unix_socket'
|
17
|
-
require 'contrast/api/communication/socket_client'
|
18
|
-
require 'contrast/api/communication/messaging_queue'
|
19
|
-
require 'contrast/api/communication/response_processor'
|
20
|
-
require 'contrast/api/communication/speedracer'
|
@@ -1,33 +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/utils/string_utils'
|
5
|
-
|
6
|
-
module Contrast
|
7
|
-
module Api
|
8
|
-
module Decorators
|
9
|
-
# Used to decorate the {Contrast::Api::Dtm::Activity} protobuf model
|
10
|
-
# to handle conversion between framework route classes and the dtm.
|
11
|
-
module Activity
|
12
|
-
def self.included klass
|
13
|
-
klass.extend(ClassMethods)
|
14
|
-
end
|
15
|
-
|
16
|
-
# Class methods for Activity
|
17
|
-
module ClassMethods
|
18
|
-
def source_or_string obj
|
19
|
-
if obj.cs__is_a?(Regexp)
|
20
|
-
obj.source
|
21
|
-
elsif obj.cs__respond_to?(:safe_string)
|
22
|
-
obj.safe_string
|
23
|
-
else
|
24
|
-
obj.to_s
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
Contrast::Api::Dtm::Activity.include(Contrast::Api::Decorators::Activity)
|
@@ -1,59 +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/api/dtm.pb'
|
5
|
-
require 'contrast/components/logger'
|
6
|
-
require 'contrast/utils/string_utils'
|
7
|
-
require 'contrast/utils/timer'
|
8
|
-
|
9
|
-
module Contrast
|
10
|
-
module Api
|
11
|
-
module Decorators
|
12
|
-
# Used to decorate the {Contrast::Api::Dtm::Address} protobuf model so it
|
13
|
-
# can own some of the data massaging required for Request dtm. Only works
|
14
|
-
# as an extension of that class.
|
15
|
-
module Address
|
16
|
-
def self.included klass
|
17
|
-
klass.extend(ClassMethods)
|
18
|
-
end
|
19
|
-
|
20
|
-
# Used to add class methods to the ApplicationUpdate class on inclusion of the decorator
|
21
|
-
module ClassMethods
|
22
|
-
include Contrast::Components::Logger::InstanceMethods
|
23
|
-
# receiver is memoized because it is the address/host/port of the server, once we
|
24
|
-
# resolve this for the first time, it shouldn't change
|
25
|
-
#
|
26
|
-
# @return [Contrast::Api::Dtm::Address] the address of this server
|
27
|
-
def build_receiver
|
28
|
-
@_build_receiver ||= begin
|
29
|
-
address = new
|
30
|
-
address.host = 'localhost'
|
31
|
-
address.ip = '127.0.0.1' # rubocop:disable Style/IpAddresses
|
32
|
-
begin
|
33
|
-
Timeout.timeout(1) do
|
34
|
-
address.host = Contrast::Utils::StringUtils.force_utf8(Socket.gethostname)
|
35
|
-
address.ip = Contrast::Utils::StringUtils.force_utf8(Resolv.getaddress(address.host))
|
36
|
-
end
|
37
|
-
rescue StandardError => e
|
38
|
-
logger.warn('Unable to resolve host or ip', e, address: address)
|
39
|
-
end
|
40
|
-
address
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
# Parse out the sender of the Request and return it as an Address
|
45
|
-
#
|
46
|
-
# @return [Contrast::Api::Dtm::Address] the address from which the
|
47
|
-
# request originated
|
48
|
-
def build_sender request
|
49
|
-
sender = new
|
50
|
-
sender.ip = Contrast::Utils::StringUtils.force_utf8(request.ip)
|
51
|
-
sender
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
Contrast::Api::Dtm::Address.include(Contrast::Api::Decorators::Address)
|
@@ -1,57 +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/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 AgentStartup protobuf model to handle reporting Agent process start
|
12
|
-
module AgentStartup
|
13
|
-
include Contrast::Components::ComponentBase
|
14
|
-
|
15
|
-
def self.included klass
|
16
|
-
klass.extend(ClassMethods)
|
17
|
-
end
|
18
|
-
|
19
|
-
# Used to add class methods to the AgentStartup class on inclusion of the decorator
|
20
|
-
module ClassMethods
|
21
|
-
# Return a new DTM with the values from the configuration and Agent discovery
|
22
|
-
#
|
23
|
-
# @parma name [String] the Hostname of this Server, or overridden value, used to identify this process
|
24
|
-
# @parma name [String] the Hostname of this Server, or overridden value, used to identify this process
|
25
|
-
# @parma name [String] the Hostname of this Server, or overridden value, used to identify this process
|
26
|
-
# @return [Contrast::Api::Dtm::AgentStartup]
|
27
|
-
def build name, path, type
|
28
|
-
msg = new
|
29
|
-
msg.server_version = Contrast::Agent::VERSION
|
30
|
-
msg.server_name = Contrast::Utils::StringUtils.protobuf_format(name)
|
31
|
-
msg.server_path = Contrast::Utils::StringUtils.protobuf_format(path)
|
32
|
-
msg.server_type = Contrast::Utils::StringUtils.protobuf_format(type)
|
33
|
-
config!(msg)
|
34
|
-
msg.finding_tags = Contrast::Utils::StringUtils.protobuf_format(::Contrast::ASSESS.tags)
|
35
|
-
msg
|
36
|
-
end
|
37
|
-
|
38
|
-
private
|
39
|
-
|
40
|
-
# set the configuration driven values for this AgentStartup msg
|
41
|
-
#
|
42
|
-
# @param msg [Contrast::Api::Dtm::AgentStartup]
|
43
|
-
def config! msg
|
44
|
-
msg.version = Contrast::Utils::StringUtils.protobuf_format(::Contrast::CONFIG.root.server.version)
|
45
|
-
msg.server_tags = Contrast::Utils::StringUtils.protobuf_format(::Contrast::CONFIG.root.server.tags)
|
46
|
-
msg.library_tags = Contrast::Utils::StringUtils.protobuf_format(::Contrast::CONFIG.root.inventory.tags)
|
47
|
-
msg.environment = Contrast::Utils::StringUtils.protobuf_format(::Contrast::CONFIG.root.server.environment)
|
48
|
-
msg.application_tags =
|
49
|
-
Contrast::Utils::StringUtils.protobuf_format(::Contrast::CONFIG.root.application.tags)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
Contrast::Api::Dtm::AgentStartup.include(Contrast::Api::Decorators::AgentStartup)
|
@@ -1,42 +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/utils/string_utils'
|
5
|
-
|
6
|
-
module Contrast
|
7
|
-
module Api
|
8
|
-
module Decorators
|
9
|
-
# Used to decorate the {Contrast::Api::Settings::ApplicationSettings}
|
10
|
-
# protobuf model to handle setting translation.
|
11
|
-
module ApplicationSettings
|
12
|
-
MODE_ALLOWLIST = [
|
13
|
-
Contrast::Api::Settings::ProtectionRule::Mode::NO_ACTION,
|
14
|
-
Contrast::Api::Settings::ProtectionRule::Mode::BLOCK,
|
15
|
-
Contrast::Api::Settings::ProtectionRule::Mode::MONITOR,
|
16
|
-
Contrast::Api::Settings::ProtectionRule::Mode::BLOCK_AT_PERIMETER
|
17
|
-
].cs__freeze
|
18
|
-
# Convert protobuf exlcusions into Agent exclusions
|
19
|
-
def translated_exclusions
|
20
|
-
exclusions.map { |exc| Contrast::Agent::ExclusionMatcher.new(exc) }
|
21
|
-
end
|
22
|
-
|
23
|
-
# Convert protobuf protect rule settings into a hash that settings state understands
|
24
|
-
def translated_protection_mode_by_id
|
25
|
-
protection_rules = self.protection_rules.map { |pr, _hash| [pr.id, pr.mode] } # [[RULE_ID, MODE]]
|
26
|
-
protection_rules.select! { |(_id, mode)| MODE_ALLOWLIST.include?(mode) } # [REMOVE IF MODE INVALID]
|
27
|
-
protection_rules.to_h # {RULE_ID => MODE}
|
28
|
-
end
|
29
|
-
|
30
|
-
def application_state_translation
|
31
|
-
{
|
32
|
-
modes_by_id: translated_protection_mode_by_id,
|
33
|
-
exclusion_matchers: translated_exclusions,
|
34
|
-
disabled_assess_rules: disabled_assess_rules
|
35
|
-
}
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
Contrast::Api::Settings::ApplicationSettings.include(Contrast::Api::Decorators::ApplicationSettings)
|
@@ -1,56 +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/api/dtm.pb'
|
5
|
-
require 'contrast/api/decorators/instrumentation_mode'
|
6
|
-
require 'contrast/components/base'
|
7
|
-
require 'contrast/utils/string_utils'
|
8
|
-
|
9
|
-
module Contrast
|
10
|
-
module Api
|
11
|
-
module Decorators
|
12
|
-
# Used to decorate the ApplicationCreate protobuf model to handle reporting Agent process start
|
13
|
-
module ApplicationStartup
|
14
|
-
include Contrast::Components::ComponentBase
|
15
|
-
|
16
|
-
def self.included klass
|
17
|
-
klass.extend(ClassMethods)
|
18
|
-
end
|
19
|
-
|
20
|
-
# Used to add class methods to the AgentStartup class on inclusion of the decorator
|
21
|
-
module ClassMethods
|
22
|
-
# Return a new DTM with the values from the configuration
|
23
|
-
#
|
24
|
-
# @return [Contrast::Api::Dtm::ApplicationCreate]
|
25
|
-
def build
|
26
|
-
msg = new
|
27
|
-
msg.code = Contrast::Utils::StringUtils.protobuf_format(::Contrast::CONFIG.root.application.code)
|
28
|
-
msg.group = Contrast::Utils::StringUtils.protobuf_format(::Contrast::CONFIG.root.application.group)
|
29
|
-
msg.metadata = Contrast::Utils::StringUtils.protobuf_format(::Contrast::CONFIG.root.application.metadata)
|
30
|
-
msg.mode = Contrast::Api::Dtm::InstrumentationMode.build
|
31
|
-
msg.app_version =
|
32
|
-
Contrast::Utils::StringUtils.protobuf_format(::Contrast::CONFIG.root.application.version.to_s) # rubocop:disable Layout/AssignmentIndentation Layout/FirstArgumentIndentation:
|
33
|
-
session!(msg)
|
34
|
-
msg
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
# Set the session metadata for this ApplicationCreate msg
|
40
|
-
#
|
41
|
-
# @param msg [Contrast::Api::Dtm::ApplicationCreate]
|
42
|
-
def session! msg
|
43
|
-
msg.session_id = Contrast::Utils::StringUtils.protobuf_format(
|
44
|
-
::Contrast::CONFIG.root.application.session_id,
|
45
|
-
truncate: false)
|
46
|
-
msg.session_metadata = Contrast::Utils::StringUtils.protobuf_format(
|
47
|
-
::Contrast::CONFIG.root.application.session_metadata,
|
48
|
-
truncate: false)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
Contrast::Api::Dtm::ApplicationCreate.include(Contrast::Api::Decorators::ApplicationStartup)
|
@@ -1,36 +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/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)
|
@@ -1,37 +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/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::BotBlockerDetails} protobuf
|
12
|
-
# model so it can own the request which its data is for.
|
13
|
-
module BotBlockerDetails
|
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
|
-
|
24
|
-
# @param result [Contrast::Api::Dtm::BotBlockerDetails]
|
25
|
-
def to_controlled_hash result
|
26
|
-
{
|
27
|
-
bot: result.bot,
|
28
|
-
user_agent: result.user_agent
|
29
|
-
}
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
Contrast::Api::Dtm::BotBlockerDetails.include(Contrast::Api::Decorators::BotBlockerDetails)
|
@@ -1,29 +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/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)
|