lib/contrast/components/config.rb in contrast-agent-3.12.2 vs lib/contrast/components/config.rb in contrast-agent-3.13.0
- old
+ new
@@ -1,10 +1,11 @@
# Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
# frozen_string_literal: true
cs__scoped_require 'contrast/utils/boolean_util'
cs__scoped_require 'contrast/utils/env_configuration_item'
+cs__scoped_require 'contrast/utils/object_share'
cs__scoped_require 'contrast/configuration'
module Contrast
module Components
# This component encapsulates reference to the configuration file.
@@ -67,21 +68,15 @@
@_assess = Contrast::Utils::BooleanUtil.true?(raw.assess.enable) if @_assess.nil?
@_assess
end
def session_id
- @_session_id ||= begin
- s = raw.application.session_id || ''
- s.empty? ? nil : s
- end
+ @_session_id ||= raw.application.session_id || Contrast::Utils::ObjectShare::EMPTY_STRING
end
def session_metadata
- @_session_metadata ||= begin
- s = raw.application.session_metadata || ''
- s.empty? ? nil : s
- end
+ @_session_metadata ||= raw.application.session_metadata || Contrast::Utils::ObjectShare::EMPTY_STRING
end
def valid?
@_valid = validate(log: false) if @_valid.nil?
end
@@ -96,10 +91,10 @@
def validate log: false
# The config has information about how to construct the logger.
# If the config is invalid, and you want to know about it, then
# you have a circular dependency if you try to log it,
# hence `log: false`.
- if session_id && session_metadata
+ if !session_id.empty? && !session_metadata.empty?
if log
cs__class.log_error(SESSION_VARIABLES)
else
puts SESSION_VARIABLES
end