contrast-agent 6.3.0 → 6.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -3
  3. data/.simplecov +1 -0
  4. data/Rakefile +0 -27
  5. data/ext/cs__contrast_patch/cs__contrast_patch.c +14 -1
  6. data/lib/contrast/agent/assess/finalizers/hash.rb +1 -0
  7. data/lib/contrast/agent/assess/policy/propagation_method.rb +5 -3
  8. data/lib/contrast/agent/assess/policy/propagator/custom.rb +4 -0
  9. data/lib/contrast/agent/assess/policy/propagator/database_write.rb +5 -0
  10. data/lib/contrast/agent/assess/policy/propagator/split.rb +3 -0
  11. data/lib/contrast/agent/assess/policy/source_method.rb +5 -0
  12. data/lib/contrast/agent/assess/policy/trigger_method.rb +9 -3
  13. data/lib/contrast/agent/assess/tracker.rb +12 -0
  14. data/lib/contrast/agent/inventory/dependency_analysis.rb +2 -2
  15. data/lib/contrast/agent/inventory/dependency_usage_analysis.rb +1 -1
  16. data/lib/contrast/agent/inventory/policy/datastores.rb +1 -1
  17. data/lib/contrast/agent/inventory/policy/policy.rb +1 -1
  18. data/lib/contrast/agent/patching/policy/method_policy.rb +3 -3
  19. data/lib/contrast/agent/protect/rule/base.rb +1 -1
  20. data/lib/contrast/agent/reporting/reporter_heartbeat.rb +1 -3
  21. data/lib/contrast/agent/reporting/reporting_events/application_defend_activity.rb +17 -21
  22. data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample.rb +1 -1
  23. data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample_activity.rb +26 -3
  24. data/lib/contrast/agent/reporting/reporting_utilities/audit.rb +5 -5
  25. data/lib/contrast/agent/reporting/reporting_utilities/headers.rb +1 -1
  26. data/lib/contrast/agent/reporting/reporting_utilities/reporter_client.rb +1 -1
  27. data/lib/contrast/agent/reporting/reporting_utilities/response_handler_utils.rb +1 -1
  28. data/lib/contrast/agent/request_context.rb +8 -0
  29. data/lib/contrast/agent/service_heartbeat.rb +2 -3
  30. data/lib/contrast/agent/static_analysis.rb +1 -1
  31. data/lib/contrast/agent/version.rb +1 -1
  32. data/lib/contrast/agent/worker_thread.rb +10 -0
  33. data/lib/contrast/api/communication/response_processor.rb +1 -1
  34. data/lib/contrast/api/dtm.pb.rb +1 -1
  35. data/lib/contrast/api/settings.pb.rb +1 -1
  36. data/lib/contrast/components/agent.rb +52 -14
  37. data/lib/contrast/components/api.rb +60 -23
  38. data/lib/contrast/components/assess.rb +16 -0
  39. data/lib/contrast/components/contrast_service.rb +1 -1
  40. data/lib/contrast/components/heap_dump.rb +51 -1
  41. data/lib/contrast/components/inventory.rb +19 -13
  42. data/lib/contrast/components/logger.rb +18 -0
  43. data/lib/contrast/components/protect.rb +41 -1
  44. data/lib/contrast/components/sampling.rb +29 -0
  45. data/lib/contrast/config/assess_configuration.rb +33 -3
  46. data/lib/contrast/config/base_configuration.rb +8 -2
  47. data/lib/contrast/config/root_configuration.rb +19 -16
  48. data/lib/contrast/config/service_configuration.rb +4 -4
  49. data/lib/contrast/config.rb +0 -9
  50. data/lib/contrast/extension/object.rb +19 -0
  51. data/lib/contrast/framework/rails/support.rb +4 -1
  52. data/lib/contrast/logger/log.rb +2 -1
  53. data/lib/contrast/utils/assess/event_limit_utils.rb +96 -0
  54. data/lib/contrast/utils/assess/propagation_method_utils.rb +27 -7
  55. data/lib/contrast/utils/log_utils.rb +2 -2
  56. data/lib/contrast/utils/net_http_base.rb +2 -2
  57. data/lib/contrast/utils/patching/policy/patch_utils.rb +6 -23
  58. data/lib/contrast.rb +39 -20
  59. data/lib/protobuf/code_generator.rb +129 -0
  60. data/lib/protobuf/decoder.rb +28 -0
  61. data/lib/protobuf/deprecation.rb +117 -0
  62. data/lib/protobuf/descriptors/google/protobuf/compiler/plugin.pb.rb +79 -0
  63. data/lib/protobuf/descriptors/google/protobuf/descriptor.pb.rb +360 -0
  64. data/lib/protobuf/descriptors.rb +3 -0
  65. data/lib/protobuf/encoder.rb +11 -0
  66. data/lib/protobuf/enum.rb +365 -0
  67. data/lib/protobuf/exceptions.rb +9 -0
  68. data/lib/protobuf/field/base_field.rb +380 -0
  69. data/lib/protobuf/field/base_field_object_definitions.rb +504 -0
  70. data/lib/protobuf/field/bool_field.rb +64 -0
  71. data/lib/protobuf/field/bytes_field.rb +67 -0
  72. data/lib/protobuf/field/double_field.rb +25 -0
  73. data/lib/protobuf/field/enum_field.rb +56 -0
  74. data/lib/protobuf/field/field_array.rb +102 -0
  75. data/lib/protobuf/field/field_hash.rb +122 -0
  76. data/lib/protobuf/field/fixed32_field.rb +25 -0
  77. data/lib/protobuf/field/fixed64_field.rb +28 -0
  78. data/lib/protobuf/field/float_field.rb +43 -0
  79. data/lib/protobuf/field/int32_field.rb +21 -0
  80. data/lib/protobuf/field/int64_field.rb +34 -0
  81. data/lib/protobuf/field/integer_field.rb +23 -0
  82. data/lib/protobuf/field/message_field.rb +51 -0
  83. data/lib/protobuf/field/sfixed32_field.rb +27 -0
  84. data/lib/protobuf/field/sfixed64_field.rb +28 -0
  85. data/lib/protobuf/field/signed_integer_field.rb +29 -0
  86. data/lib/protobuf/field/sint32_field.rb +21 -0
  87. data/lib/protobuf/field/sint64_field.rb +21 -0
  88. data/lib/protobuf/field/string_field.rb +51 -0
  89. data/lib/protobuf/field/uint32_field.rb +21 -0
  90. data/lib/protobuf/field/uint64_field.rb +21 -0
  91. data/lib/protobuf/field/varint_field.rb +77 -0
  92. data/lib/protobuf/field.rb +74 -0
  93. data/lib/protobuf/generators/base.rb +85 -0
  94. data/lib/protobuf/generators/enum_generator.rb +39 -0
  95. data/lib/protobuf/generators/extension_generator.rb +27 -0
  96. data/lib/protobuf/generators/field_generator.rb +193 -0
  97. data/lib/protobuf/generators/file_generator.rb +262 -0
  98. data/lib/protobuf/generators/group_generator.rb +122 -0
  99. data/lib/protobuf/generators/message_generator.rb +104 -0
  100. data/lib/protobuf/generators/option_generator.rb +17 -0
  101. data/lib/protobuf/generators/printable.rb +160 -0
  102. data/lib/protobuf/generators/service_generator.rb +50 -0
  103. data/lib/protobuf/lifecycle.rb +33 -0
  104. data/lib/protobuf/logging.rb +39 -0
  105. data/lib/protobuf/message/fields.rb +233 -0
  106. data/lib/protobuf/message/serialization.rb +85 -0
  107. data/lib/protobuf/message.rb +241 -0
  108. data/lib/protobuf/optionable.rb +72 -0
  109. data/lib/protobuf/tasks/compile.rake +80 -0
  110. data/lib/protobuf/tasks.rb +1 -0
  111. data/lib/protobuf/varint.rb +20 -0
  112. data/lib/protobuf/varint_pure.rb +31 -0
  113. data/lib/protobuf/version.rb +3 -0
  114. data/lib/protobuf/wire_type.rb +10 -0
  115. data/lib/protobuf.rb +91 -0
  116. data/proto/dynamic_discovery.proto +46 -0
  117. data/proto/google/protobuf/compiler/plugin.proto +183 -0
  118. data/proto/google/protobuf/descriptor.proto +911 -0
  119. data/proto/rpc.proto +71 -0
  120. data/resources/assess/policy.json +15 -12
  121. data/resources/deadzone/policy.json +132 -19
  122. data/ruby-agent.gemspec +3 -1
  123. metadata +112 -28
  124. data/lib/contrast/config/agent_configuration.rb +0 -63
  125. data/lib/contrast/config/api_configuration.rb +0 -56
  126. data/lib/contrast/config/heap_dump_configuration.rb +0 -59
  127. data/lib/contrast/config/inventory_configuration.rb +0 -33
  128. data/lib/contrast/config/logger_configuration.rb +0 -26
  129. data/lib/contrast/config/protect_configuration.rb +0 -33
  130. data/lib/contrast/config/sampling_configuration.rb +0 -35
@@ -1,63 +0,0 @@
1
- # Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
- # frozen_string_literal: true
3
-
4
- require 'contrast/config/service_configuration'
5
- require 'contrast/config/logger_configuration'
6
- require 'contrast/config/ruby_configuration'
7
- require 'contrast/config/heap_dump_configuration'
8
- require 'contrast/config/api_configuration'
9
-
10
- module Contrast
11
- module Config
12
- # Common Configuration settings. Those in this section pertain to the core functionality of the Agent.
13
- class AgentConfiguration
14
- include Contrast::Config::BaseConfiguration
15
-
16
- # @return [Boolean, nil]
17
- attr_accessor :enable
18
- # @return [Boolean, nil]
19
- attr_accessor :omit_body
20
- # @return [Contrast::Config::RubyConfiguration]
21
- attr_writer :ruby
22
- # @return [Contrast::Config::ServiceConfiguration]
23
- attr_writer :service
24
- # @return [ Contrast::Config::LoggerConfiguration]
25
- attr_writer :logger
26
- # @return [Contrast::Config::HeapDumpConfiguration]
27
- attr_writer :heap_dump
28
-
29
- def initialize hsh = {}
30
- return unless hsh
31
-
32
- @enable = hsh[:enable]
33
- @start_bundled_service = hsh[:start_bundled_service]
34
- @omit_body = hsh[:omit_body]
35
- @service = Contrast::Config::ServiceConfiguration.new(hsh[:service])
36
- @logger = Contrast::Config::LoggerConfiguration.new(hsh[:logger])
37
- @ruby = Contrast::Config::RubyConfiguration.new(hsh[:ruby])
38
- @heap_dump = Contrast::Config::HeapDumpConfiguration.new(hsh[:heap_dump])
39
- end
40
-
41
- # @return [Boolean, true]
42
- def start_bundled_service
43
- @start_bundled_service.nil? ? true : @start_bundled_service
44
- end
45
-
46
- def service
47
- @service ||= Contrast::Config::ServiceConfiguration.new
48
- end
49
-
50
- def logger
51
- @logger ||= Contrast::Config::LoggerConfiguration.new
52
- end
53
-
54
- def ruby
55
- @ruby ||= Contrast::Config::RubyConfiguration.new
56
- end
57
-
58
- def heap_dump
59
- @heap_dump ||= Contrast::Config::HeapDumpConfiguration.new
60
- end
61
- end
62
- end
63
- end
@@ -1,56 +0,0 @@
1
- # Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
- # frozen_string_literal: true
3
-
4
- require 'contrast/config/api_proxy_configuration'
5
- require 'contrast/config/certification_configuration'
6
- require 'contrast/config/request_audit_configuration'
7
-
8
- module Contrast
9
- module Config
10
- # Api keys configuration
11
- class ApiConfiguration
12
- include Contrast::Config::BaseConfiguration
13
-
14
- # @return [String]
15
- attr_accessor :api_key
16
- # @return [String]
17
- attr_accessor :user_name
18
- # @return [String]
19
- attr_accessor :service_key
20
- attr_writer :url, :proxy, :request_audit, :certificate
21
-
22
- DEFAULT_URL = 'https://app.contrastsecurity.com/Contrast'
23
-
24
- def initialize hsh = {}
25
- return unless hsh
26
-
27
- @api_key = hsh[:api_key]
28
- @url = hsh[:url]
29
- @user_name = hsh[:user_name]
30
- @service_key = hsh[:service_key]
31
- @proxy = Contrast::Config::ApiProxyConfiguration.new(hsh[:proxy])
32
- @request_audit = Contrast::Config::RequestAuditConfiguration.new(hsh[:request_audit])
33
- @certificate = Contrast::Config::CertificationConfiguration.new(hsh[:certificate])
34
- end
35
-
36
- def url
37
- @url.nil? ? DEFAULT_URL : @url
38
- end
39
-
40
- # @return [Contrast::Config::ApiProxyConfiguration]
41
- def proxy
42
- @proxy ||= Contrast::Config::ApiProxyConfiguration.new
43
- end
44
-
45
- # @return [Contrast::Config::RequestAuditConfiguration]
46
- def request_audit
47
- @request_audit ||= Contrast::Config::RequestAuditConfiguration.new
48
- end
49
-
50
- # @return [Contrast::Config::CertificationConfiguration]
51
- def certificate
52
- @certificate ||= Contrast::Config::CertificationConfiguration.new
53
- end
54
- end
55
- end
56
- end
@@ -1,59 +0,0 @@
1
- # Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
- # frozen_string_literal: true
3
-
4
- module Contrast
5
- module Config
6
- # Common Configuration settings. Those in this section pertain to the Heap Dump collection functionality of the
7
- # Agent.
8
- class HeapDumpConfiguration
9
- include Contrast::Config::BaseConfiguration
10
-
11
- DEFAULT_PATH = 'contrast_heap_dumps' # saved
12
- DEFAULT_MS = 10_000
13
- DEFAULT_COUNT = 5
14
-
15
- attr_writer :enable, :path, :delay_ms, :window_ms, :count, :clean
16
-
17
- def initialize hsh = {}
18
- return unless hsh
19
-
20
- @enable = hsh[:enable]
21
- @path = hsh[:path]
22
- @delay_ms = hsh[:delay_ms]
23
- @window_ms = hsh[:window_ms]
24
- @count = hsh[:count]
25
- @clean = hsh[:clean]
26
- end
27
-
28
- # @return [Boolean, Contrast::Utils::ObjectShare::FALSE] should dumps be taken
29
- def enable
30
- @enable.nil? ? Contrast::Utils::ObjectShare::FALSE : @enable
31
- end
32
-
33
- # @return [String, DEFAULT_PATH] dir to which dumps should be
34
- def path
35
- @path ||= DEFAULT_PATH
36
- end
37
-
38
- # @return [Integer, DEFAULT_MS] time, in ms, after initialization
39
- def delay_ms
40
- @delay_ms ||= DEFAULT_MS
41
- end
42
-
43
- # @return [Integer, DEFAULT_MS] ms between each dump
44
- def window_ms
45
- @window_ms ||= DEFAULT_MS
46
- end
47
-
48
- # @return [Integer, DEFAULT_MS] number of dumps to take
49
- def count
50
- @count ||= DEFAULT_COUNT
51
- end
52
-
53
- # @return [Boolean, Contrast::Utils::ObjectShare::FALSE] remove temporary objects or not
54
- def clean
55
- @clean.nil? ? Contrast::Utils::ObjectShare::FALSE : @clean
56
- end
57
- end
58
- end
59
- end
@@ -1,33 +0,0 @@
1
- # Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
- # frozen_string_literal: true
3
-
4
- module Contrast
5
- module Config
6
- # Common Configuration settings. Those in this section pertain to the inventory functionality of the Agent.
7
- class InventoryConfiguration
8
- include Contrast::Config::BaseConfiguration
9
-
10
- # @return [Array, nil] tags
11
- attr_accessor :tags
12
- attr_writer :enable, :analyze_libraries
13
-
14
- def initialize hsh = {}
15
- return unless hsh
16
-
17
- @enable = hsh[:enable]
18
- @analyze_libraries = hsh[:analyze_libraries]
19
- @tags = hsh[:tags]
20
- end
21
-
22
- # @return [Boolean, true]
23
- def enable
24
- @enable.nil? ? true : @enable
25
- end
26
-
27
- # @return [Boolean, true]
28
- def analyze_libraries
29
- @analyze_libraries.nil? ? true : @analyze_libraries
30
- end
31
- end
32
- end
33
- end
@@ -1,26 +0,0 @@
1
- # Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
- # frozen_string_literal: true
3
-
4
- module Contrast
5
- module Config
6
- # Common Configuration settings. Those in this section pertain to the logging in the Agent.
7
- class LoggerConfiguration
8
- include Contrast::Config::BaseConfiguration
9
-
10
- # @return [String, nil]
11
- attr_accessor :path
12
- # @return [String, nil]
13
- attr_accessor :level
14
- # @return [String, nil]
15
- attr_accessor :progname
16
-
17
- def initialize hsh = {}
18
- return unless hsh
19
-
20
- @path = hsh[:path]
21
- @level = hsh[:level]
22
- @progname = hsh[:progname]
23
- end
24
- end
25
- end
26
- end
@@ -1,33 +0,0 @@
1
- # Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
- # frozen_string_literal: true
3
-
4
- module Contrast
5
- module Config
6
- # Common Configuration settings. Those in this section pertain to the protect functionality of the Agent.
7
- class ProtectConfiguration
8
- include Contrast::Config::BaseConfiguration
9
-
10
- # @return [Boolean, nil]
11
- attr_accessor :enable
12
- attr_writer :exceptions, :rules
13
-
14
- def initialize hsh = {}
15
- return unless hsh
16
-
17
- @exceptions = Contrast::Config::ExceptionConfiguration.new(hsh[:exceptions])
18
- @rules = Contrast::Config::ProtectRulesConfiguration.new(hsh[:rules])
19
- @enable = hsh[:enable]
20
- end
21
-
22
- # @return [Contrast::Config::ExceptionConfiguration]
23
- def exceptions
24
- @exceptions ||= Contrast::Config::ExceptionConfiguration.new
25
- end
26
-
27
- # @return [Contrast::Config::ProtectRulesConfiguration]
28
- def rules
29
- @rules ||= Contrast::Config::ProtectRulesConfiguration.new
30
- end
31
- end
32
- end
33
- end
@@ -1,35 +0,0 @@
1
- # Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
- # frozen_string_literal: true
3
-
4
- module Contrast
5
- module Config
6
- # Common Configuration settings. Those in this section pertain to the sampling functionality of the Agent.
7
- class SamplingConfiguration
8
- include Contrast::Config::BaseConfiguration
9
-
10
- # @return [Integer, nil]
11
- attr_reader :baseline
12
- # @return [Integer, nil]
13
- attr_reader :request_frequency
14
- # @return [Integer, nil]
15
- attr_reader :response_frequency
16
- # @return [Integer, nil]
17
- attr_reader :window_ms
18
-
19
- def initialize hsh = {}
20
- return unless hsh
21
-
22
- @enable = hsh[:enable]
23
- @baseline = hsh[:baseline]
24
- @request_frequency = hsh[:request_frequency]
25
- @response_frequency = hsh[:response_frequency]
26
- @window_ms = hsh[:window_ms]
27
- end
28
-
29
- # @return [Boolean, false]
30
- def enable
31
- !!@enable
32
- end
33
- end
34
- end
35
- end