# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details. # frozen_string_literal: true module Contrast module Api module Decorators # Used to decorate the {Contrast::Api::Dtm::RaspRuleSample} protobuf # model. module RaspRuleSample def self.included klass klass.extend(ClassMethods) end # Used to add class methods to RaspRuleSample module ClassMethods def build context, ia_result sample = new sample.timestamp_ms = context.timer.start_ms sample.user_input = Contrast::Api::Dtm::UserInput.build_from_ia_result(ia_result) sample.user_input.document_type = Contrast::Utils::StringUtils.force_utf8(context.request.document_type) sample end # @param result [Contrast::Api::Dtm::RaspRuleSample] def to_controlled_hash result { timestamp: Time.at(result.timestamp_ms).iso8601, user_input: result.user_input, brute_force: result.brute_force, bot_blocker: result.bot_blocker, cmdi: result.cmdi, csrf: result.csrf, cve: result.cve, untrusted_deserialization: result.untrusted_deserialization, el_injection: result.el_injection, mark_of_the_beast: result.mark_of_the_beast, padding_oracle: result.padding_oracle, path_traversal: result.path_traversal, re_dos: result.re_dos, sqli: result.sqli, ssrf: result.ssrf, virtual_patch: result.virtual_patch, xss: result.xss, xxe: result.xxe, no_sqli: result.no_sqli, method_tampering: result.method_tampering, path_traversal_semantic: result.path_traversal_semantic, ssjs: result.ssjs, ip_denylist: result.ip_denylist } end end end end end end Contrast::Api::Dtm::RaspRuleSample.include(Contrast::Api::Decorators::RaspRuleSample)