Sha256: fe263a09ca349977ccb09022ccbc6cd0be903713327391c1ca715c18fe866794
Contents?: true
Size: 1.79 KB
Versions: 1
Compression:
Stored size: 1.79 KB
Contents
# Copyright (c) 2021 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details. # frozen_string_literal: true require 'contrast/agent/deadzone/policy/deadzone_node' require 'contrast/agent/patching/policy/policy' module Contrast module Agent module Deadzone module Policy # This is just a holder for our policy. Takes the policy JSON and converts it into hashes that we can access # nicely. class Policy < Contrast::Agent::Patching::Policy::Policy def self.policy_folder 'deadzone' end DEADZONES_KEY = 'deadzones' attr_reader :deadzones def initialize @deadzones = [] super end def node_type Contrast::Agent::Deadzone::Policy::DeadzoneNode end def from_hash_string string policy_data = JSON.parse(string) policy_data[DEADZONES_KEY].each do |deadzone_hash| add_node(node_type.new(deadzone_hash)) end end def validate return if class_name raise(ArgumentError, "#{ @node_class } #{ id } did not have a proper class name. Unable to create.") end def module_names @_module_names ||= Set.new(deadzones.map(&:class_name)) end def add_node node, _node_type = :deadzones unless node logger.error('Node was nil when adding node to policy') return end begin node.validate rescue ArgumentError => e logger.error('Node failed validation', e) return end @deadzones << node end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
contrast-agent-4.12.0 | lib/contrast/agent/deadzone/policy/policy.rb |