lib/contrast/utils/invalid_configuration_util.rb in contrast-agent-3.8.5 vs lib/contrast/utils/invalid_configuration_util.rb in contrast-agent-3.9.0
- old
+ new
@@ -1,7 +1,7 @@
# Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
-# frozen_string_literal: false
+# frozen_string_literal: true
cs__scoped_require 'contrast/components/interface'
module Contrast
module Utils
@@ -9,13 +9,13 @@
# customer applications, as determined by Configuration Rules at runtime.
module InvalidConfigurationUtil
include Contrast::Components::Interface
access_component :agent, :analysis, :contrast_service, :logging
- CS__PATH = 'path'.cs__freeze
- CS__SESSION_ID = 'sessionId'.cs__freeze
- CS__SNIPPET = 'snippet'.cs__freeze
+ CS__PATH = 'path'
+ CS__SESSION_ID = 'sessionId'
+ CS__SNIPPET = 'snippet'
# Build and report a finding for the given rule
#
# @param rule_id [String] the rule that was violated by the configuration
# @param user_provided_options [Hash] the configuration value(s) which
@@ -69,10 +69,10 @@
def file_snippet file_path, call_location
idx = call_location&.lineno
if file_path && idx && File.exist?(file_path)
idx = idx > 5 ? idx - 5 : 0
- snippet = ''
+ snippet = +''
File.foreach(file_path).with_index do |line, line_num|
next unless line_num >= idx
break if line_num > idx + 10
snippet << line