Sha256: c0f7748041117313c5424800cf7c91ff7bb547177f3a9cfd53c89b262ea401e9
Contents?: true
Size: 1.76 KB
Versions: 2
Compression:
Stored size: 1.76 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/config/effective_config' module Contrast module Agent module DiagnosticsConfig # This class is responsible for logging to file the effective Agent configurations after startup. class Config attr_reader :effective_config MESSAGE_FAIL = 'Unable to connect to Contrast, configuration details from the Contrast UI will not be included.' MESSAGE_SUCCESSFUL = 'Connected to Contrast.' CONN_STATUS_MSG_FAILURE = 'Unable to connect to Contrast, insufficient connection properties provided.' def initialize @effective_config = Contrast::Agent::DiagnosticsConfig::EffectiveConfig.new @config_status = Contrast::Utils::ObjectShare::EMPTY_STRING end # This method will set the status from the request/response cycles # # @param response [Contrast::Agent::Reporting::Response] def determine_config_status response return unless response # If we encounter for some of the startup events failure - always return failure return if [MESSAGE_FAIL, CONN_STATUS_MSG_FAILURE].include?(@config_status) response_code = response.code.to_s @config_status = response_code.start_with?('2') ? MESSAGE_SUCCESSFUL : MESSAGE_FAIL nil end # This method will set the status message from the config validation def populate_fail_connection @config_status = CONN_STATUS_MSG_FAILURE end def to_controlled_hash @effective_config.to_controlled_hash.merge({ Status: @config_status }) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
contrast-agent-6.11.0 | lib/contrast/config/config.rb |
contrast-agent-6.10.0 | lib/contrast/config/config.rb |