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
@@ -3,12 +3,14 @@
|
|
3
3
|
|
4
4
|
require 'contrast/agent/assess/events/event_factory'
|
5
5
|
require 'contrast/agent/assess/policy/trigger_validation/trigger_validation'
|
6
|
+
require 'contrast/agent/excluder'
|
6
7
|
require 'contrast/components/logger'
|
7
8
|
require 'contrast/utils/object_share'
|
8
9
|
require 'contrast/utils/sha256_builder'
|
9
10
|
require 'contrast/utils/assess/trigger_method_utils'
|
10
11
|
require 'contrast/agent/assess/events/event_data'
|
11
12
|
require 'contrast/agent/reporting/reporting_events/preflight'
|
13
|
+
require 'contrast/agent/reporting/reporting_events/application_activity'
|
12
14
|
require 'contrast/agent/reporting/reporting_events/preflight_message'
|
13
15
|
require 'contrast/agent/reporting/reporting_events/route_discovery'
|
14
16
|
require 'contrast/agent/reporting/reporting_utilities/reporting_storage'
|
@@ -21,18 +23,14 @@ module Contrast
|
|
21
23
|
# A trigger method is one which can perform a dangerous action, as described by the
|
22
24
|
# Contrast::Agent::Assess::Policy::TriggerNode class. Each such method will call to this module just after
|
23
25
|
# invocation in order to determine if the call was done safely. In those cases where it was not, a Finding
|
24
|
-
# report is issued to
|
25
|
-
module TriggerMethod
|
26
|
+
# report is issued to TeamServer.
|
27
|
+
module TriggerMethod
|
26
28
|
extend Contrast::Components::Logger::InstanceMethods
|
27
29
|
extend Contrast::Utils::Assess::TriggerMethodUtils
|
28
30
|
extend Contrast::Utils::Assess::EventLimitUtils
|
29
31
|
|
30
|
-
# The level of TeamServer compliance our traces meet when in the abnormal condition of being dataflow rules
|
31
|
-
# without routes.
|
32
|
-
MINIMUM_FINDING_VERSION = 3
|
33
|
-
# The level of TeamServer compliance our traces meet.
|
34
|
-
CURRENT_FINDING_VERSION = 4
|
35
32
|
# Rules that always exists outside of Request Context
|
33
|
+
# @return [Array<String>]
|
36
34
|
NON_REQUEST_RULES = [
|
37
35
|
'hardcoded-password', # Contrast::Agent::Assess::Rule::Provider::HardcodedPassword.NAME,
|
38
36
|
'hardcoded-key' # Contrast::Agent::Assess::Rule::Provider::HardcodedKey.NAME
|
@@ -57,7 +55,9 @@ module Contrast
|
|
57
55
|
# else proceed, if the flag is true we don't need to check for context we
|
58
56
|
# go as currently.
|
59
57
|
# When outside of a request, only track when the feature is enabled
|
60
|
-
return unless
|
58
|
+
return unless context ||
|
59
|
+
Contrast::ASSESS.non_request_tracking? ||
|
60
|
+
NON_REQUEST_RULES.include?(trigger_node.rule_id)
|
61
61
|
|
62
62
|
if trigger_node.sources&.any?
|
63
63
|
trigger_node.sources.each do |marker|
|
@@ -73,95 +73,57 @@ module Contrast
|
|
73
73
|
apply_trigger(trigger_node, source, object, ret, *args)
|
74
74
|
end
|
75
75
|
|
76
|
-
def append_to_finding finding, event_data, request
|
77
|
-
finding.rule_id = Contrast::Utils::StringUtils.protobuf_safe_string(event_data.policy_node.rule_id)
|
78
|
-
finding.version = determine_compliance_version(finding)
|
79
|
-
append_events(finding, event_data)
|
80
|
-
append_route(finding, request)
|
81
|
-
append_hash(finding, event_data.tagged, request)
|
82
|
-
end
|
83
|
-
|
84
76
|
# This converts the source of the finding, and the events leading up to it into a Finding
|
85
77
|
#
|
86
78
|
# @param trigger_node [Contrast::Agent::Assess::Policy::TriggerNode] the node to direct applying this
|
87
79
|
# trigger event
|
88
80
|
# @param source [Object] the source of the Trigger Event
|
89
81
|
# @param object [Object] the Object on which the method was invoked
|
90
|
-
# @param ret [Object] the Return of the invoked method
|
82
|
+
# @param ret [Object, nil] the Return of the invoked method, or nil if void method
|
91
83
|
# @param args [Array<Object>] the Arguments with which the method was invoked
|
92
|
-
# @return [Contrast::
|
93
|
-
# nil if conditions were not met
|
84
|
+
# @return [Contrast::Agent::Reporting::Finding, nil] the finding to send to TeamServer if found
|
94
85
|
def build_finding trigger_node, source, object, ret, *args
|
95
86
|
content_type = Contrast::Agent::REQUEST_TRACKER.current&.response&.content_type
|
96
|
-
|
97
87
|
if content_type.nil? && trigger_node.collectable?
|
98
88
|
Contrast::Agent::FINDINGS.collect_finding(trigger_node, source, object, ret, *args)
|
99
89
|
return
|
100
90
|
end
|
101
|
-
|
102
91
|
return unless Contrast::Agent::Assess::Policy::TriggerValidation.valid?(trigger_node, object, ret, args)
|
103
92
|
|
104
93
|
request = find_request(source)
|
105
94
|
return unless reportable?(request&.env)
|
95
|
+
return if excluded_by_url_and_rule?(request, trigger_node.rule_id)
|
106
96
|
|
107
|
-
|
97
|
+
finding = Contrast::Agent::Reporting::Finding.new(trigger_node.rule_id)
|
98
|
+
finding.attach_data(trigger_node, source, object, ret, request, *args)
|
99
|
+
return if excluded_by_input_and_rule?(request, finding, trigger_node.rule_id)
|
100
|
+
|
101
|
+
finding.hash_code = Contrast::Utils::HashDigest.generate_event_hash(finding, source, request)
|
102
|
+
finding
|
108
103
|
rescue StandardError => e
|
109
104
|
logger.error('Unable to build a finding', e, rule: trigger_node.rule_id, node_id: trigger_node.id)
|
105
|
+
nil
|
110
106
|
end
|
111
107
|
|
112
|
-
|
113
|
-
if Contrast::Agent::Reporter.enabled?
|
114
|
-
handle_new_finding(trigger_node, source, object, ret, request, *args)
|
115
|
-
else # TODO: RUBY-1438 -- remove
|
116
|
-
finding = Contrast::Api::Dtm::Finding.new
|
117
|
-
event_data = Contrast::Agent::Assess::Events::EventData.new(trigger_node, source, object, ret, args)
|
118
|
-
append_to_finding(finding, event_data, request)
|
119
|
-
logger.trace('Finding created', node_id: trigger_node.id, source_id: source.__id__,
|
120
|
-
rule: trigger_node.rule_id)
|
121
|
-
report_finding(finding, request)
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
# Given a finding, append it to an activity message and send it to the Service for processing. If an
|
108
|
+
# Given a finding, append it to an activity message and send it to the TeamServer for processing. If an
|
126
109
|
# activity message does not exist, b/c we're invoked outside of a request context, build an activity and
|
127
110
|
# immediately report it with the finding.
|
128
111
|
#
|
129
|
-
#
|
130
|
-
|
131
|
-
|
132
|
-
# @param request [Contrast::Agent::Request] our wrapper around the Rack::Request.
|
133
|
-
def report_finding finding, request = nil
|
134
|
-
context = Contrast::Agent::REQUEST_TRACKER.current
|
135
|
-
if context
|
136
|
-
context.activity.findings << finding
|
137
|
-
return
|
138
|
-
end
|
139
|
-
|
140
|
-
return unless ::Contrast::ASSESS.non_request_tracking? || NON_REQUEST_RULES.include?(finding.rule_id)
|
112
|
+
# @param finding [Contrast::Agent::Reporting::Finding] the Finding to report.
|
113
|
+
def report_finding finding
|
114
|
+
return unless finding
|
141
115
|
|
142
|
-
|
143
|
-
|
144
|
-
if request
|
145
|
-
activity.http_request = request.dtm
|
146
|
-
else
|
147
|
-
logger.debug('Attempted to report finding without request', finding: finding)
|
148
|
-
end
|
149
|
-
|
150
|
-
# If we're out of request context, then we need to report this finding ourselves,
|
151
|
-
# so we'll send it in the one-off activity we created.
|
152
|
-
Contrast::Agent.messaging_queue&.send_event_eventually(activity)
|
153
|
-
end
|
116
|
+
preflight = Contrast::Agent::Reporting::BuildPreflight.generate(finding)
|
117
|
+
return unless preflight
|
154
118
|
|
155
|
-
|
156
|
-
|
157
|
-
# here we will generate new type of finding
|
158
|
-
ruby_finding = Contrast::Agent::Reporting::Finding.new(trigger_node.rule_id)
|
159
|
-
ruby_finding.attach_data(trigger_node, source, object, ret, request, *args)
|
160
|
-
hash_code = Contrast::Utils::HashDigest.generate_event_hash(ruby_finding, source, request)
|
161
|
-
ruby_finding.hash_code = hash_code
|
119
|
+
preflight_data = preflight.messages[0].data
|
120
|
+
return if Contrast::Agent::REQUEST_TRACKER.current&.reported_findings&.include?(preflight_data)
|
162
121
|
|
163
|
-
|
164
|
-
Contrast::Agent.
|
122
|
+
Contrast::Agent::Reporting::ReportingStorage[preflight.messages[0].data] = finding
|
123
|
+
if Contrast::Agent::REQUEST_TRACKER.current
|
124
|
+
Contrast::Agent::REQUEST_TRACKER.current.reported_findings << preflight_data
|
125
|
+
end
|
126
|
+
Contrast::Agent.reporter&.send_event(preflight)
|
165
127
|
end
|
166
128
|
|
167
129
|
private
|
@@ -203,30 +165,6 @@ module Contrast
|
|
203
165
|
end
|
204
166
|
end
|
205
167
|
|
206
|
-
def append_events finding, event_data
|
207
|
-
append_from_source(finding, event_data.tagged)
|
208
|
-
finding.events << Contrast::Agent::Assess::Events::EventFactory.build(event_data).to_dtm_event
|
209
|
-
end
|
210
|
-
|
211
|
-
def append_from_source finding, source
|
212
|
-
return unless source
|
213
|
-
return unless Contrast::Agent::Assess::Tracker.trackable?(source)
|
214
|
-
|
215
|
-
properties = Contrast::Agent::Assess::Tracker.properties(source)
|
216
|
-
return unless properties
|
217
|
-
|
218
|
-
build_events(finding, properties.event) if properties.event
|
219
|
-
|
220
|
-
# CSGoogle::Protobuf::Map doesn't support merge!, so we have to do this long form
|
221
|
-
source_props = properties.properties
|
222
|
-
return unless source_props
|
223
|
-
|
224
|
-
source_props.each_pair do |key, value|
|
225
|
-
key = Contrast::Utils::StringUtils.force_utf8(key)
|
226
|
-
finding.properties[key] = Contrast::Utils::StringUtils.force_utf8(value)
|
227
|
-
end
|
228
|
-
end
|
229
|
-
|
230
168
|
def build_events finding, event
|
231
169
|
return unless event
|
232
170
|
|
@@ -238,36 +176,17 @@ module Contrast
|
|
238
176
|
finding.events << event.to_dtm_event
|
239
177
|
end
|
240
178
|
|
241
|
-
|
242
|
-
context = Contrast::Agent::REQUEST_TRACKER.current
|
243
|
-
if context
|
244
|
-
finding.routes << context.route if context.route
|
245
|
-
elsif request&.route
|
246
|
-
finding.routes << request.route
|
247
|
-
end
|
248
|
-
end
|
249
|
-
|
250
|
-
def append_hash finding, source, request
|
251
|
-
hash_code = Contrast::Utils::HashDigest.generate_event_hash(finding, source, request)
|
252
|
-
finding.hash_code = Contrast::Utils::StringUtils.force_utf8(hash_code)
|
253
|
-
finding.preflight = Contrast::Utils::PreflightUtil.create_preflight(finding)
|
254
|
-
end
|
255
|
-
|
256
|
-
# Because our APIs are not versioned, TeamServer relies on a field, version, to tell it what, if any,
|
257
|
-
# validation it can preform on the findings we send it. Examine the finding and determine the level to
|
258
|
-
# which it conforms.
|
179
|
+
# Check if the finding should be excluded due to the assess exclusion rules.
|
259
180
|
#
|
260
|
-
# @param
|
261
|
-
# @
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
return CURRENT_FINDING_VERSION if finding.routes.any?
|
267
|
-
# any finding without events is not of a dataflow type and therefore at maximum compliance
|
268
|
-
return CURRENT_FINDING_VERSION unless finding.events.any?
|
181
|
+
# @param request [Contrast::Agent::Request] a wrapper around the Rack::Request for the current request
|
182
|
+
# @param rule_id [String]
|
183
|
+
# return [Boolean]
|
184
|
+
def excluded_by_url_and_rule? request, rule_id
|
185
|
+
Contrast::SETTINGS.excluder.assess_excluded_by_url_and_rule?(request, rule_id)
|
186
|
+
end
|
269
187
|
|
270
|
-
|
188
|
+
def excluded_by_input_and_rule? request, finding, rule_id
|
189
|
+
Contrast::SETTINGS.excluder.assess_excluded_by_input_and_rule?(request, finding, rule_id)
|
271
190
|
end
|
272
191
|
end
|
273
192
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
require 'contrast/agent/assess/policy/trigger/reflected_xss'
|
5
5
|
require 'contrast/agent/assess/policy/trigger/xpath'
|
6
|
-
require 'contrast/
|
6
|
+
require 'contrast/agent/reporting/reporting_events/finding_event_taint_range_tags'
|
7
7
|
require 'contrast/components/logger'
|
8
8
|
|
9
9
|
module Contrast
|
@@ -185,8 +185,8 @@ module Contrast
|
|
185
185
|
|
186
186
|
tags.each do |tag|
|
187
187
|
raise(ArgumentError, "Rule #{ rule_id } had an invalid tag. #{ tag } is not a known value.") unless
|
188
|
-
Contrast::
|
189
|
-
Contrast::
|
188
|
+
Contrast::Agent::Reporting::FindingEventTaintRangeTags::VALID_TAGS.include?(tag) ||
|
189
|
+
Contrast::Agent::Reporting::FindingEventTaintRangeTags::VALID_SOURCE_TAGS.include?(tag)
|
190
190
|
end
|
191
191
|
end
|
192
192
|
|
@@ -7,7 +7,7 @@ module Contrast
|
|
7
7
|
module Policy
|
8
8
|
module TriggerValidation
|
9
9
|
# Validator used to assert a REDOS finding is actually vulnerable
|
10
|
-
# before serializing that finding as a DTM to report to the
|
10
|
+
# before serializing that finding as a DTM to report to the TeamServer.
|
11
11
|
module REDOSValidator
|
12
12
|
RULE_NAME = 'redos'
|
13
13
|
|
@@ -7,7 +7,7 @@ module Contrast
|
|
7
7
|
module Policy
|
8
8
|
module TriggerValidation
|
9
9
|
# Validator used to assert a SSRF finding is actually vulnerable
|
10
|
-
# before serializing that finding as a DTM to report to the
|
10
|
+
# before serializing that finding as a DTM to report to the TeamServer.
|
11
11
|
module SSRFValidator
|
12
12
|
RULE_NAME = 'ssrf'
|
13
13
|
URL_PATTERN = %r{(?<protocol>http|https|ftp|sftp|telnet|gopher|rtsp|rtsps|ssh|svn)://(?<host>[^/?]+)(?<path>/?[^?]*)(?<query_string>\?.*)?}i.cs__freeze # rubocop:disable Layout/LineLength
|
@@ -8,7 +8,7 @@ module Contrast
|
|
8
8
|
module TriggerValidation
|
9
9
|
# Validator used to assert a Reflected XSS finding is actually
|
10
10
|
# vulnerable before serializing that finding as a DTM to report to
|
11
|
-
# the
|
11
|
+
# the TeamServer.
|
12
12
|
module XSSValidator
|
13
13
|
RULE_NAME = 'reflected-xss'
|
14
14
|
SAFE_CONTENT_TYPES = %w[/csv /javascript /json /pdf /x-javascript /x-json].cs__freeze
|
@@ -42,24 +42,14 @@ module Contrast
|
|
42
42
|
return unless event.source_type
|
43
43
|
return unless (current_request = Contrast::Agent::REQUEST_TRACKER.current)
|
44
44
|
|
45
|
-
append_to_ruby_object(current_request, event)
|
46
|
-
end
|
47
|
-
|
48
|
-
# @param current_request [Contrast::Agent::RequestContext]
|
49
|
-
# @param event [Contrast::Agent::Assess::Events::ContrastEvent]
|
50
|
-
def append_to_ruby_object current_request, event
|
51
45
|
if current_request.observed_route.sources.any? do |source|
|
52
|
-
source.type == event.
|
53
|
-
source.name == event.forced_source_name # rubocop:disable Security/Module/Name
|
46
|
+
source.type == event.source_type && source.name == event.source_name # rubocop:disable Security/Module/Name
|
54
47
|
end
|
55
48
|
|
56
49
|
return
|
57
50
|
end
|
58
51
|
|
59
|
-
event_source
|
60
|
-
return unless event_source
|
61
|
-
|
62
|
-
current_request.observed_route.sources << event_source
|
52
|
+
current_request.observed_route.sources << event.event_source if event.event_source
|
63
53
|
end
|
64
54
|
end
|
65
55
|
end
|
@@ -11,9 +11,8 @@ module Contrast
|
|
11
11
|
module Assess
|
12
12
|
module Rule
|
13
13
|
module Provider
|
14
|
-
# Hardcoded rules detect if any secret value has been written
|
15
|
-
#
|
16
|
-
# class, a provider must implement three methods:
|
14
|
+
# Hardcoded rules detect if any secret value has been written directly into the sourcecode of the
|
15
|
+
# application. To use this base class, a provider must implement three methods:
|
17
16
|
# 1) name_passes? : does the constant name match a given value set
|
18
17
|
# 2) value_node_passes? : does the value of the constant match a
|
19
18
|
# given value set
|
@@ -21,23 +20,21 @@ module Contrast
|
|
21
20
|
module HardcodedValueRule
|
22
21
|
include Contrast::Components::Logger::InstanceMethods
|
23
22
|
|
23
|
+
# @return [Boolean]
|
24
24
|
def disabled?
|
25
25
|
!::Contrast::ASSESS.enabled? || ::Contrast::ASSESS.rule_disabled?(rule_id)
|
26
26
|
end
|
27
27
|
|
28
|
-
# Parse the file pertaining to the given TracePoint to walk its AST
|
29
|
-
#
|
30
|
-
#
|
31
|
-
# String or through a method call.
|
28
|
+
# Parse the file pertaining to the given TracePoint to walk its AST to determine if a Constant is
|
29
|
+
# hardcoded. For our purposes, this hard coding means directly set rather than as an interpolated String or
|
30
|
+
# through a method call.
|
32
31
|
#
|
33
|
-
# Note: This is a top layer check, we make no assertions about what
|
34
|
-
#
|
35
|
-
# calling a hardcoded thing, causes this check to not report.
|
32
|
+
# Note: This is a top layer check, we make no assertions about what the methods or interpolations do.
|
33
|
+
# Their presence, even if only calling a hardcoded thing, causes this check to not report.
|
36
34
|
#
|
37
|
-
# @param trace_point [TracePoint] the TracePoint event created on
|
38
|
-
#
|
39
|
-
#
|
40
|
-
# tree of the Module defined in the TracePoint end event
|
35
|
+
# @param trace_point [TracePoint] the TracePoint event created on the :end of a Module being loaded
|
36
|
+
# @param ast [RubyVM::AbstractSyntaxTree::Node] the abstract syntax tree of the Module defined in the
|
37
|
+
# TracePoint end event
|
41
38
|
def parse trace_point, ast
|
42
39
|
return if disabled?
|
43
40
|
|
@@ -56,8 +53,8 @@ module Contrast
|
|
56
53
|
private
|
57
54
|
|
58
55
|
# @param mod [Module] the module to which this AST pertains
|
59
|
-
# @param ast [RubyVM::AbstractSyntaxTree::Node, Object] a node
|
60
|
-
#
|
56
|
+
# @param ast [RubyVM::AbstractSyntaxTree::Node, Object] a node within the AST, which may be a leaf, so any
|
57
|
+
# Object
|
61
58
|
def parse_ast mod, ast
|
62
59
|
return unless ast.cs__is_a?(RubyVM::AbstractSyntaxTree::Node)
|
63
60
|
return unless ast.cs__respond_to?(:children)
|
@@ -72,32 +69,27 @@ module Contrast
|
|
72
69
|
# https://www.rubydoc.info/gems/ruby-internal/Node/CDECL
|
73
70
|
return unless ast.type == :CDECL
|
74
71
|
|
75
|
-
# The CDECL Node has two children, the first being the Constant
|
76
|
-
#
|
77
|
-
# constant
|
72
|
+
# The CDECL Node has two children, the first being the Constant name as a symbol, the second as the value
|
73
|
+
# to assign to that constant
|
78
74
|
children = ast.children
|
79
75
|
name = children[0].to_s
|
80
76
|
# If that constant name doesn't pass our checks, move on.
|
81
77
|
return unless name_passes?(name)
|
82
78
|
|
83
79
|
value = children[1]
|
84
|
-
# The assignment node could be a direct value or a call of some
|
85
|
-
#
|
80
|
+
# The assignment node could be a direct value or a call of some sort. We leave it to each rule to
|
81
|
+
# properly handle these nodes.
|
86
82
|
return unless value_node_passes?(value)
|
87
83
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
build_finding(mod, name)
|
92
|
-
end
|
84
|
+
build_and_report(mod, name)
|
85
|
+
rescue StandardError => e
|
86
|
+
logger.error('Unable to parse AST for Hardcoded Rule analysis.', e)
|
93
87
|
end
|
94
88
|
|
95
|
-
# Constants can be set as frozen directly. We need to account for
|
96
|
-
#
|
97
|
-
# a :CALL, not a constant.
|
89
|
+
# Constants can be set as frozen directly. We need to account for this change as it means the Node given to
|
90
|
+
# the :CDECL call will be a :CALL, not a constant.
|
98
91
|
#
|
99
|
-
# @param value_node [RubyVM::AbstractSyntaxTree::Node] the node to
|
100
|
-
# evaluate
|
92
|
+
# @param value_node [RubyVM::AbstractSyntaxTree::Node] the node to evaluate
|
101
93
|
# @return [Boolean] is this a freeze call or not
|
102
94
|
def freeze_call? value_node
|
103
95
|
return false unless value_node.type == :CALL
|
@@ -109,61 +101,29 @@ module Contrast
|
|
109
101
|
children[1] == :freeze
|
110
102
|
end
|
111
103
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
finding =
|
116
|
-
|
117
|
-
activity.findings << finding
|
118
|
-
Contrast::Agent.messaging_queue.send_event_eventually(activity, force: true)
|
119
|
-
rescue StandardError => e
|
120
|
-
logger.error('Unable to build a finding for Hardcoded Rule', e)
|
121
|
-
nil
|
122
|
-
end
|
104
|
+
# @param mod [Module] the module to which this AST pertains
|
105
|
+
# @param name [String] the name of the hardcoded constant
|
106
|
+
def build_and_report mod, name
|
107
|
+
finding = build_finding(mod, name)
|
108
|
+
return unless finding
|
123
109
|
|
124
|
-
|
125
|
-
|
126
|
-
# @return [Contrast::Api::Dtm::Finding]
|
127
|
-
def assign_finding class_name, constant_string
|
128
|
-
finding = Contrast::Api::Dtm::Finding.new
|
129
|
-
finding.rule_id = Contrast::Utils::StringUtils.protobuf_safe_string(rule_id)
|
130
|
-
finding.version = Contrast::Agent::Assess::Policy::TriggerMethod::CURRENT_FINDING_VERSION
|
131
|
-
|
132
|
-
finding.properties[SOURCE_KEY] = Contrast::Utils::StringUtils.protobuf_safe_string(class_name)
|
133
|
-
finding.properties[CONSTANT_NAME_KEY] = Contrast::Utils::StringUtils.protobuf_safe_string(constant_string)
|
134
|
-
finding.properties[CODE_SOURCE_KEY] =
|
135
|
-
Contrast::Utils::StringUtils.protobuf_safe_string(constant_string + redacted_marker)
|
136
|
-
|
137
|
-
hash = Contrast::Utils::HashDigest.generate_class_scanning_hash(finding)
|
138
|
-
finding.hash_code = Contrast::Utils::StringUtils.protobuf_safe_string(hash)
|
139
|
-
finding.preflight = Contrast::Utils::PreflightUtil.create_preflight(finding)
|
140
|
-
finding
|
141
|
-
end
|
110
|
+
preflight = Contrast::Agent::Reporting::BuildPreflight.generate(finding)
|
111
|
+
return unless preflight
|
142
112
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
# sent to reporter
|
147
|
-
# and add logger message for the report of the preflight
|
148
|
-
new_preflight = Contrast::Agent::Reporting::Preflight.new
|
149
|
-
new_preflight_message = Contrast::Agent::Reporting::PreflightMessage.new
|
150
|
-
new_preflight_message.hash_code = hash
|
151
|
-
new_preflight_message.data = "#{ rule_id },#{ hash }"
|
152
|
-
new_preflight.messages << new_preflight_message
|
153
|
-
|
154
|
-
# extract to new method
|
155
|
-
# here we will generate new type of finding
|
156
|
-
ruby_finding = Contrast::Agent::Reporting::Finding.new(rule_id)
|
157
|
-
ruby_finding.hash_code = hash
|
158
|
-
ruby_finding.properties[SOURCE_KEY] = clazz.cs__name
|
159
|
-
ruby_finding.properties[CONSTANT_NAME_KEY] = constant_string
|
160
|
-
ruby_finding.properties[CODE_SOURCE_KEY] = constant_string + redacted_marker
|
161
|
-
save_and_report_finding(ruby_finding, new_preflight)
|
113
|
+
Contrast::Agent::Reporting::ReportingStorage[preflight.messages[0].data] = finding
|
114
|
+
Contrast::Agent.reporter&.send_event(preflight)
|
162
115
|
end
|
163
116
|
|
164
|
-
|
165
|
-
|
166
|
-
|
117
|
+
# @param clazz [Class] the Class or Module containing the constant
|
118
|
+
# @param constant_string [String]
|
119
|
+
# @return [Contrast::Agent::Reporting::Finding]
|
120
|
+
def build_finding clazz, constant_string
|
121
|
+
finding = Contrast::Agent::Reporting::Finding.new(rule_id)
|
122
|
+
finding.properties[SOURCE_KEY] = clazz.cs__name
|
123
|
+
finding.properties[CONSTANT_NAME_KEY] = constant_string
|
124
|
+
finding.properties[CODE_SOURCE_KEY] = constant_string + redacted_marker
|
125
|
+
finding.hash_code = Contrast::Utils::HashDigest.generate_class_scanning_hash(finding)
|
126
|
+
finding
|
167
127
|
end
|
168
128
|
end
|
169
129
|
end
|
@@ -3,10 +3,8 @@
|
|
3
3
|
|
4
4
|
require 'rack'
|
5
5
|
require 'json'
|
6
|
-
require 'contrast/agent/reporting/reporting_utilities/dtm_message'
|
7
6
|
require 'contrast/agent/reporting/reporting_utilities/build_preflight'
|
8
7
|
require 'contrast/utils/hash_digest'
|
9
|
-
require 'contrast/utils/preflight_util'
|
10
8
|
require 'contrast/utils/string_utils'
|
11
9
|
|
12
10
|
module Contrast
|
@@ -32,18 +30,11 @@ module Contrast
|
|
32
30
|
finding = build_finding(violation)
|
33
31
|
return unless finding
|
34
32
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
Contrast::Agent.reporter&.send_event(preflight)
|
41
|
-
else
|
42
|
-
Contrast::Agent.reporter&.send_event(report)
|
43
|
-
end
|
44
|
-
else
|
45
|
-
Contrast::Agent::REQUEST_TRACKER.current.activity.findings << finding
|
46
|
-
end
|
33
|
+
preflight = Contrast::Agent::Reporting::BuildPreflight.generate(finding)
|
34
|
+
return unless preflight
|
35
|
+
|
36
|
+
Contrast::Agent::Reporting::ReportingStorage[preflight.messages[0].data] = finding
|
37
|
+
Contrast::Agent.reporter&.send_event(preflight)
|
47
38
|
end
|
48
39
|
|
49
40
|
protected
|
@@ -75,16 +66,15 @@ module Contrast
|
|
75
66
|
# Convert the given evidence into a finding. The rule will populate this evidence with each of the
|
76
67
|
#
|
77
68
|
# @param evidence [Hash] the properties required to build this finding.
|
78
|
-
# @return [Contrast::
|
69
|
+
# @return [Contrast::Agent::Reporting::Finding]
|
79
70
|
def build_finding evidence
|
80
|
-
finding = Contrast::
|
81
|
-
finding.rule_id = rule_id
|
71
|
+
finding = Contrast::Agent::Reporting::Finding.new(rule_id)
|
82
72
|
context = Contrast::Agent::REQUEST_TRACKER.current
|
83
|
-
finding.routes << context.
|
73
|
+
finding.routes << context.discovered_route if context&.discovered_route
|
84
74
|
build_evidence(evidence, finding)
|
75
|
+
finding.request = Contrast::Agent::Reporting::FindingRequest.convert(context.request) if context&.request
|
85
76
|
hash = Contrast::Utils::HashDigest.generate_config_hash(finding)
|
86
77
|
finding.hash_code = Contrast::Utils::StringUtils.force_utf8(hash)
|
87
|
-
finding.preflight = Contrast::Utils::PreflightUtil.create_preflight(finding)
|
88
78
|
finding
|
89
79
|
end
|
90
80
|
|
@@ -92,16 +82,10 @@ module Contrast
|
|
92
82
|
# Change it accordingly the rule you work on
|
93
83
|
#
|
94
84
|
# @param evidence [Hash] the properties required to build this finding.
|
95
|
-
# @param finding [Contrast::
|
85
|
+
# @param finding [Contrast::Agent::Reporting::Finding] finding to attach the evidence to
|
96
86
|
def build_evidence evidence, finding
|
97
87
|
evidence.each_pair do |key, value|
|
98
|
-
finding.properties[key] =
|
99
|
-
Contrast::Utils::StringUtils.protobuf_format(value.to_json)
|
100
|
-
elsif value.cs__is_a?(Array)
|
101
|
-
value.map { Contrast::Utils::StringUtils.protobuf_format(_1) }.to_s
|
102
|
-
else
|
103
|
-
Contrast::Utils::StringUtils.protobuf_format(value)
|
104
|
-
end
|
88
|
+
finding.properties[key] = value
|
105
89
|
end
|
106
90
|
end
|
107
91
|
|
@@ -2,9 +2,7 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require 'rack'
|
5
|
-
require 'contrast/agent/reporting/reporting_utilities/dtm_message'
|
6
5
|
require 'contrast/utils/hash_digest'
|
7
|
-
require 'contrast/utils/preflight_util'
|
8
6
|
require 'contrast/utils/string_utils'
|
9
7
|
require 'contrast/agent/assess/rule/response/base_rule'
|
10
8
|
|
@@ -22,7 +20,7 @@ module Contrast
|
|
22
20
|
START_PROP = 'start'.cs__freeze
|
23
21
|
END_PROP = 'end'.cs__freeze
|
24
22
|
FORM_START_REGEXP = /<form/i.cs__freeze
|
25
|
-
META_TYPE = '
|
23
|
+
META_TYPE = 'META tag'
|
26
24
|
PRAGMA = 'pragma'
|
27
25
|
|
28
26
|
# Rules discern which responses they can/should analyze.
|