Sha256: 92dd82a413af0665fae03778a9935e76fca165c00e850138884df8790928ac42
Contents?: true
Size: 1.36 KB
Versions: 13
Compression:
Stored size: 1.36 KB
Contents
# Copyright (c) 2023 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details. # frozen_string_literal: true require 'contrast/components/logger' module Contrast module Agent module Reporting # A class supporting all to_controlled_hash reporting methods. All errors raised during # validation will be handled here. class ReportableHash include Contrast::Components::Logger::InstanceMethods # Convert the instance variables on the class, and other information, into the identifiers required for # TeamServer to process the JSON form of this message. # # @return [Hash, nil] # @raise [ArgumentError] def to_controlled_hash validate {} end # @raise [ArgumentError] def validate; end # Helper method to get json representation of event objects and handle errors. # # @return [String, nil] - JSON def event_json hsh = to_controlled_hash hsh.to_json rescue ArgumentError => e # Log the error and raise it for the client to handle: logger.error(validation_error_message, e) raise(e) end private def validation_error_message "#{ cs__class } failed validation with: " end end end end end
Version data entries
13 entries across 13 versions & 1 rubygems