lib/contrast/agent/reporting/masker/masker_utils.rb in contrast-agent-6.6.4 vs lib/contrast/agent/reporting/masker/masker_utils.rb in contrast-agent-6.6.5
- old
+ new
@@ -7,46 +7,17 @@
module Agent
module Reporting
# helper methods used for masking
module MaskerUtils
include Contrast::Utils::ObjectShare
- # Helper to deal with Protobuf FieldHash.
- #
- # @param field_hash [Protobuf::Field::FieldHash] hash to be masked
- # @param results [Array<Contrast::Api::Dtm::AttackResults>]
- # results to match against.
- # @return [Hash]
- def mask_field_hash field_hash, results
- return {} unless field_hash&.any?
- hash = {}
- # Because this is the start of a built string, we have to be sure that it is not frozen.
- masked = +''
- field_hash.each do |entry|
- # Protobuf::Field::FieldHash produces array, with the key as first param and value as second.
- new_value = entry[1].delete(SEMICOLON).split(SPACE)
- new_value.each do |value|
- arr = value.split(EQUALS)
- # Add to new hash.
- hash[arr[0]] = arr[1]
- end
- # Mask the newly created hash.
- mask_with_dictionary(results, hash)
-
- # Restore to original form.
- hash.each { |k, v| masked += "#{ k }=#{ v }; " }
- masked.rstrip!
- field_hash[entry[0]] = masked
- end
- end
-
# 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'
#
# @param query [String]
- # @param results [Array<Contrast::Api::Dtm::AttackResults>]
+ # @param results [Array<Contrast::Agent::Reporting::ApplicationDefendAttackActivitys>]
# results to match against.
def mask_raw_query query, results
masked = EMPTY_STRING
hash = URI.decode_www_form(query).to_h
mask_with_dictionary(results, hash)