Module: Contrast::Agent::Reporting::MaskerUtils

Includes:
Utils::ObjectShare
Included in:
Masker
Defined in:
lib/contrast/agent/reporting/masker/masker_utils.rb

Overview

helper methods used for masking

Constant Summary

Constants included from Utils::ObjectShare

Utils::ObjectShare::AMPERSAND, Utils::ObjectShare::ASTERISK, Utils::ObjectShare::AT, Utils::ObjectShare::BACK_SLASH, Utils::ObjectShare::BANG, Utils::ObjectShare::CACHE, Utils::ObjectShare::CARROT, Utils::ObjectShare::COLON, Utils::ObjectShare::COLON_SLASH_SLASH, Utils::ObjectShare::COMMA, Utils::ObjectShare::CONTRAST_DOT, Utils::ObjectShare::CONTRAST_PATCHED_METHOD_START, Utils::ObjectShare::DASH, Utils::ObjectShare::DIGIT_REGEXP, Utils::ObjectShare::DOLLAR_SIGN, Utils::ObjectShare::DOUBLE_QUOTE, Utils::ObjectShare::DOUBLE_UNDERSCORE, Utils::ObjectShare::EMPTY_ARRAY, Utils::ObjectShare::EMPTY_HASH, Utils::ObjectShare::EMPTY_STRING, Utils::ObjectShare::EQUALS, Utils::ObjectShare::EXCLAMATION, Utils::ObjectShare::FALSE, Utils::ObjectShare::HTTPS_START, Utils::ObjectShare::HTTP_SCORE, Utils::ObjectShare::HTTP_START, Utils::ObjectShare::INDEX, Utils::ObjectShare::LEFT_ANGLE, Utils::ObjectShare::NEW_LINE, Utils::ObjectShare::NIL_64_STRING, Utils::ObjectShare::NIL_STRING, Utils::ObjectShare::NOT_WHITE_SPACE_REGEXP, Utils::ObjectShare::OBJECT_KEY, Utils::ObjectShare::OVERRIDE_MESSAGE, Utils::ObjectShare::PARENT_PATH, Utils::ObjectShare::PERIOD, Utils::ObjectShare::POUND_SIGN, Utils::ObjectShare::QUESTION_MARK, Utils::ObjectShare::RETURN, Utils::ObjectShare::RETURN_KEY, Utils::ObjectShare::RUBY, Utils::ObjectShare::SEMICOLON, Utils::ObjectShare::SINGLE_QUOTE, Utils::ObjectShare::SLASH, Utils::ObjectShare::SPACE, Utils::ObjectShare::TRUE, Utils::ObjectShare::UNDERSCORE, Utils::ObjectShare::UNKNOWN, Utils::ObjectShare::WHITE_SPACE_REGEXP, Utils::ObjectShare::WRITE_FLAG

Instance Method Summary collapse

Instance Method Details

#mask_raw_query(query, results) ⇒ Object

Mask raw query as it comes from the env. exp: ‘ssn=1234567&id=%272%20or%202%20=%202%27’ => ‘ssn=contrast-redacted-ssn&id=contrast-redacted-id’

results to match against.

Parameters:

  • query (String)
  • results (Array<Contrast::Agent::Reporting::ApplicationDefendAttackActivitys>)


21
22
23
24
25
26
27
28
29
# File 'lib/contrast/agent/reporting/masker/masker_utils.rb', line 21

def mask_raw_query query, results
  masked = EMPTY_STRING
  hash = URI.decode_www_form(query).to_h
  mask_with_dictionary(results, hash)
  # Restore to string form.
  hash.each { |k, v| masked += "#{ k }#{ EQUALS }#{ v }#{ AMPERSAND }" }
  query = masked
  query.chomp!(masked[-1])
end