Sha256: f0643b49feae492308bfda22f5cb69b8ae4928de6e1fbad1f7f60611c365749a
Contents?: true
Size: 1.91 KB
Versions: 15
Compression:
Stored size: 1.91 KB
Contents
# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details. # frozen_string_literal: true require 'contrast/agent/patching/policy/policy_node' require 'contrast/api/decorators/trace_taint_range_tags' require 'contrast/utils/object_share' module Contrast module Agent module Assess module Policy # This module will extend the PolicyNode, which functions is to translate # our policy.json into an actionable Ruby object, allowing for dynamic # patching over hardcoded patching. module PolicyNodeUtils private # Given a policy string in the format A,B,C, populate the given array # 1) Split on ',' # 2) If 'O' or 'R', add the array, else it's P and needs to be # converted. P type will either be P# where # is the index # of the parameter. Drop the P and store the # as an int. # # @param markers [String] the String from the policy to parse # @return [Array] the array generated by converting the marker string def convert_policy_markers markers return Contrast::Utils::ObjectShare::EMPTY_ARRAY unless markers return Contrast::Utils::ObjectShare::EMPTY_ARRAY if markers.empty? converted = [] markers.split(Contrast::Utils::ObjectShare::COMMA).each do |maker| converted << case maker when Contrast::Utils::ObjectShare::OBJECT_KEY, Contrast::Utils::ObjectShare::RETURN_KEY maker else Integer(maker[1..]) end end converted end def all_type? marker marker.include?(Contrast::Utils::ObjectShare::COMMA) end end end end end end
Version data entries
15 entries across 15 versions & 1 rubygems