lib/contrast/agent/protect/rule/cmdi/cmdi_dangerous_path.rb in contrast-agent-6.11.0 vs lib/contrast/agent/protect/rule/cmdi/cmdi_dangerous_path.rb in contrast-agent-6.12.0

- old
+ new

@@ -1,6 +1,6 @@ -# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details. +# Copyright (c) 2023 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details. # frozen_string_literal: true require 'contrast/agent/protect/rule/base_service' require 'contrast/agent/request_context' require 'contrast/utils/object_share' @@ -21,29 +21,28 @@ def sub_rules Contrast::Utils::ObjectShare::EMPTY_ARRAY end - protected + # @param path [String] potential dangerous path executed. + def infilter? path + return unless enabled? + return unless dangerous_path?(path) + true + end + + private + # Used to customize the raised error message. # # @param classname [String] Name of the class # @param method [String] name of the method triggering the rule # @raise [Contrast::SecurityException] def raise_error classname, method raise(Contrast::SecurityException.new(self, 'Command Injection Dangerous Path rule triggered. ' \ "Call to #{ classname }.#{ method } blocked.")) - end - - private - - def find_probable_attacker context, potential_attack_string, _ia_results, **kwargs - dangerous_path = dangerous_path?(potential_attack_string) - return unless dangerous_path - - build_attack_with_match(context, nil, nil, potential_attack_string, **kwargs) end # Checks if a given shell command is trying to access a dangerous path. # This is used for the cmd-injection-semantic-dangerous-paths rule. #