contrast-agent 5.2.0 → 5.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fa7aa416c6a15843424449814734c462a46e2951cbe41f010bd2570c03717cc5
4
- data.tar.gz: ade4eac9f0f32d9aa339d6429a30728f0b7950a68db8b8b1aad2e0e5cfe52d71
3
+ metadata.gz: bfca6df4def9f2366f7a92651aa9cd2fc40f3ced6784228844d8025cee5a4850
4
+ data.tar.gz: b66b10e1d892adee985f070963e08945fd9dd4faf641f4f06a8372683129facd
5
5
  SHA512:
6
- metadata.gz: fd24331e49a9d2826628613ccc3f1bcf5c3ba337ba866ea321fd5a795d9b585507d935b92e64bffca5d70f83d4dbac7a978b484b372ae9c590c2d82ca3a57e91
7
- data.tar.gz: cc3b03f3b101658f74006af2b4ef4c81256c2890372727fcd6f5d300926ca6454a6da64be5500cd0d5cc103e36d92a5c8f24495677558e33856fe5e8f99e71f9
6
+ metadata.gz: '08a6989482a82249d3fb906b2f79788e03d5c5ffa03973beabe591292fa780cd2bd3a6f459e8b7eedf58181a729720da0e95b1afa069e8869511b6ff4338625d'
7
+ data.tar.gz: b460cad0b10b3355bfafa3be8c49ba41d0174e5a5d0524bbab273cf51c3d9fed6348027b9658dd3dadddcace9012f0ce119566f46899ee71f8712aebf56a98bf
@@ -1,8 +1,6 @@
1
1
  # Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
- require 'rails'
5
-
6
4
  module Contrast
7
5
  module Agent
8
6
  module Assess
@@ -10,11 +8,13 @@ module Contrast
10
8
  module Response
11
9
  module Framework
12
10
  # Rails 7 supports managing potential unsafe Headers
13
- # this module contains methods for checking if Rails 7 supercedes our rules
11
+ # this module contains methods for checking if Rails 7 supersedes our rules
14
12
  module RailsSupport
15
13
  RAILS_VERSION = Gem::Version.new('7.0.0')
16
14
 
17
15
  def framework_supported?
16
+ return false unless defined?(::Rails)
17
+
18
18
  rails_version = ::Rails.version
19
19
  return false unless !!rails_version
20
20
 
@@ -1,10 +1,9 @@
1
1
  # Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
+ require 'contrast/agent/assess/rule/response/framework/rails_support'
4
5
  require 'contrast/agent/assess/rule/response/header_rule'
5
6
  require 'contrast/utils/string_utils'
6
- require 'contrast/agent/assess/rule/response/framework/rails_support'
7
- require 'rails'
8
7
 
9
8
  module Contrast
10
9
  module Agent
@@ -3,6 +3,6 @@
3
3
 
4
4
  module Contrast
5
5
  module Agent
6
- VERSION = '5.2.0'
6
+ VERSION = '5.3.0'
7
7
  end
8
8
  end
@@ -13,17 +13,72 @@ module Contrast
13
13
  DEFAULT_HOST = '127.0.0.1'
14
14
  DEFAULT_PORT = '30555'
15
15
 
16
- KEYS = {
17
- enable: EMPTY_VALUE,
18
- host: EMPTY_VALUE,
19
- port: EMPTY_VALUE,
20
- socket: EMPTY_VALUE,
21
- logger: Contrast::Config::LoggerConfiguration,
22
- bypass: false
23
- }.cs__freeze
24
-
25
- def initialize hsh
26
- super(hsh, KEYS)
16
+ attr_writer :enable, :logger, :bypass
17
+ # @return [String, nil]
18
+ attr_accessor :socket
19
+ # @return [String, nil]
20
+ attr_accessor :port
21
+ # @return [String, nil]
22
+ attr_accessor :host
23
+
24
+ def initialize hsh = {}
25
+ @enable = traverse_config(hsh, :enable)
26
+ @host = traverse_config(hsh, :host)
27
+ @port = traverse_config(hsh, :port)
28
+ @socket = traverse_config(hsh, :socket)
29
+ @logger = Contrast::Config::LoggerConfiguration.new(traverse_config(hsh, :logger))
30
+ @bypass = traverse_config(hsh, :bypass)
31
+ @configuration_map = {}
32
+ build_configuration_map
33
+ end
34
+
35
+ # @return [Boolean, false]
36
+ def enable
37
+ !!@enable
38
+ end
39
+
40
+ # @return [Contrast::Config::LoggerConfiguration]
41
+ def logger
42
+ @logger ||= Contrast::Config::LoggerConfiguration.new
43
+ end
44
+
45
+ # @return [Boolean, false]
46
+ def bypass
47
+ !!@bypass
48
+ end
49
+
50
+ # TODO: RUBY-1493 MOVE TO BASE CONFIG
51
+
52
+ def []= key, value
53
+ instance_variable_set("@#{ key }".to_sym, value)
54
+ @configuration_map[key] = value
55
+ end
56
+
57
+ def [] key
58
+ send(key.to_sym)
59
+ end
60
+
61
+ # Traverse the given entity to build out the configuration graph.
62
+ #
63
+ # The values will be either a hash, indicating internal nodes to
64
+ # traverse, or a value to set or the EMPTY_VALUE symbol, indicating a
65
+ # leaf node.
66
+ #
67
+ # The spec_key are the Contrast defined keys based on the instance variables of
68
+ # a given configuration.
69
+ def traverse_config values, spec_key
70
+ internal_nodes = values.cs__respond_to?(:has_key?)
71
+ val = internal_nodes ? value_from_key_config(spec_key, values) : nil
72
+ val == EMPTY_VALUE ? nil : val
73
+ end
74
+
75
+ def build_configuration_map
76
+ instance_variables.each do |key|
77
+ str_key = key.to_s.tr('@', '')
78
+ next if str_key == 'configuration_map'
79
+
80
+ @configuration_map[str_key] = send(str_key.to_sym)
81
+ end
27
82
  end
28
83
  end
29
84
  end
@@ -1 +1 @@
1
- 2.28.6
1
+ 2.28.14
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contrast-agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.0
4
+ version: 5.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - galen.palmer@contrastsecurity.com
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: exe
15
15
  cert_chain: []
16
- date: 2022-02-22 00:00:00.000000000 Z
16
+ date: 2022-03-03 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: bundler