contrast-agent 4.8.0 → 4.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +6 -1
- data/.simplecov +1 -0
- data/lib/contrast.rb +24 -14
- data/lib/contrast/agent/assess/contrast_event.rb +1 -4
- data/lib/contrast/agent/assess/finalizers/hash.rb +2 -4
- data/lib/contrast/agent/assess/policy/patcher.rb +6 -4
- data/lib/contrast/agent/assess/policy/policy.rb +1 -1
- data/lib/contrast/agent/assess/policy/policy_scanner.rb +3 -5
- data/lib/contrast/agent/assess/policy/preshift.rb +4 -4
- data/lib/contrast/agent/assess/policy/propagation_method.rb +4 -4
- data/lib/contrast/agent/assess/policy/propagator/database_write.rb +3 -6
- data/lib/contrast/agent/assess/policy/propagator/split.rb +9 -6
- data/lib/contrast/agent/assess/policy/propagator/substitution.rb +2 -3
- data/lib/contrast/agent/assess/policy/rewriter_patch.rb +7 -7
- data/lib/contrast/agent/assess/policy/source_method.rb +6 -6
- data/lib/contrast/agent/assess/policy/trigger/xpath.rb +0 -3
- data/lib/contrast/agent/assess/policy/trigger_method.rb +2 -3
- data/lib/contrast/agent/assess/policy/trigger_node.rb +1 -1
- data/lib/contrast/agent/assess/rule/provider/hardcoded_value_rule.rb +4 -4
- data/lib/contrast/agent/at_exit_hook.rb +3 -3
- data/lib/contrast/agent/class_reopener.rb +6 -5
- data/lib/contrast/agent/disable_reaction.rb +3 -4
- data/lib/contrast/agent/exclusion_matcher.rb +2 -3
- data/lib/contrast/agent/inventory/dependency_analysis.rb +2 -6
- data/lib/contrast/agent/inventory/dependency_usage_analysis.rb +3 -5
- data/lib/contrast/agent/inventory/policy/datastores.rb +3 -4
- data/lib/contrast/agent/inventory/policy/policy.rb +1 -1
- data/lib/contrast/agent/middleware.rb +14 -13
- data/lib/contrast/agent/patching/policy/after_load_patch.rb +3 -3
- data/lib/contrast/agent/patching/policy/after_load_patcher.rb +3 -4
- data/lib/contrast/agent/patching/policy/patch.rb +8 -8
- data/lib/contrast/agent/patching/policy/patcher.rb +6 -6
- data/lib/contrast/agent/patching/policy/policy.rb +2 -4
- data/lib/contrast/agent/patching/policy/policy_node.rb +2 -3
- data/lib/contrast/agent/protect/policy/policy.rb +1 -1
- data/lib/contrast/agent/protect/policy/rule_applicator.rb +3 -5
- data/lib/contrast/agent/protect/rule/base.rb +10 -10
- data/lib/contrast/agent/protect/rule/cmd_injection.rb +4 -5
- data/lib/contrast/agent/protect/rule/path_traversal.rb +1 -5
- data/lib/contrast/agent/reaction_processor.rb +2 -3
- data/lib/contrast/agent/request.rb +4 -3
- data/lib/contrast/agent/request_context.rb +9 -9
- data/lib/contrast/agent/request_handler.rb +5 -3
- data/lib/contrast/agent/response.rb +2 -3
- data/lib/contrast/agent/rewriter.rb +4 -3
- data/lib/contrast/agent/rule_set.rb +5 -4
- data/lib/contrast/agent/service_heartbeat.rb +2 -3
- data/lib/contrast/agent/static_analysis.rb +6 -5
- data/lib/contrast/agent/thread.rb +2 -4
- data/lib/contrast/agent/thread_watcher.rb +3 -4
- data/lib/contrast/agent/tracepoint_hook.rb +4 -4
- data/lib/contrast/agent/version.rb +1 -1
- data/lib/contrast/api/communication/messaging_queue.rb +4 -5
- data/lib/contrast/api/communication/response_processor.rb +11 -11
- data/lib/contrast/api/communication/service_lifecycle.rb +5 -4
- data/lib/contrast/api/communication/socket_client.rb +18 -14
- data/lib/contrast/api/communication/speedracer.rb +5 -6
- data/lib/contrast/api/decorators/address.rb +2 -3
- data/lib/contrast/api/decorators/agent_startup.rb +7 -9
- data/lib/contrast/api/decorators/application_startup.rb +8 -10
- data/lib/contrast/api/decorators/application_update.rb +0 -4
- data/lib/contrast/api/decorators/http_request.rb +3 -7
- data/lib/contrast/api/decorators/instrumentation_mode.rb +3 -5
- data/lib/contrast/api/decorators/message.rb +7 -7
- data/lib/contrast/api/decorators/trace_event_object.rb +2 -3
- data/lib/contrast/components/agent.rb +10 -15
- data/lib/contrast/components/app_context.rb +7 -11
- data/lib/contrast/components/assess.rb +16 -16
- data/lib/contrast/components/base.rb +40 -0
- data/lib/contrast/components/config.rb +0 -2
- data/lib/contrast/components/contrast_service.rb +6 -11
- data/lib/contrast/components/heap_dump.rb +5 -4
- data/lib/contrast/components/inventory.rb +2 -7
- data/lib/contrast/components/logger.rb +1 -2
- data/lib/contrast/components/protect.rb +10 -13
- data/lib/contrast/components/sampling.rb +5 -5
- data/lib/contrast/components/scope.rb +0 -4
- data/lib/contrast/components/settings.rb +1 -5
- data/lib/contrast/configuration.rb +3 -4
- data/lib/contrast/extension/assess/array.rb +2 -4
- data/lib/contrast/extension/assess/eval_trigger.rb +2 -3
- data/lib/contrast/extension/assess/fiber.rb +6 -5
- data/lib/contrast/extension/assess/hash.rb +3 -3
- data/lib/contrast/extension/assess/kernel.rb +2 -4
- data/lib/contrast/extension/assess/marshal.rb +4 -4
- data/lib/contrast/extension/assess/regexp.rb +5 -4
- data/lib/contrast/extension/assess/string.rb +6 -6
- data/lib/contrast/extension/kernel.rb +2 -4
- data/lib/contrast/extension/protect/kernel.rb +0 -5
- data/lib/contrast/framework/manager.rb +2 -3
- data/lib/contrast/framework/rack/patch/session_cookie.rb +6 -6
- data/lib/contrast/framework/rails/patch/assess_configuration.rb +5 -7
- data/lib/contrast/framework/rails/patch/support.rb +40 -36
- data/lib/contrast/framework/rails/railtie.rb +8 -6
- data/lib/contrast/framework/rails/rewrite/active_record_named.rb +3 -4
- data/lib/contrast/funchook/funchook.rb +4 -3
- data/lib/contrast/logger/application.rb +1 -6
- data/lib/contrast/logger/log.rb +22 -6
- data/lib/contrast/logger/request.rb +0 -4
- data/lib/contrast/tasks/service.rb +1 -6
- data/lib/contrast/utils/assess/sampling_util.rb +2 -3
- data/lib/contrast/utils/assess/tracking_util.rb +2 -4
- data/lib/contrast/utils/heap_dump_util.rb +5 -3
- data/lib/contrast/utils/invalid_configuration_util.rb +4 -3
- data/lib/contrast/utils/inventory_util.rb +2 -3
- data/lib/contrast/utils/io_util.rb +2 -4
- data/lib/contrast/utils/job_servers_running.rb +4 -3
- data/lib/contrast/utils/os.rb +2 -3
- data/lib/contrast/utils/string_utils.rb +2 -3
- data/lib/contrast/utils/tag_util.rb +25 -19
- data/ruby-agent.gemspec +4 -2
- data/service_executables/VERSION +1 -1
- data/service_executables/linux/contrast-service +0 -0
- data/service_executables/mac/contrast-service +0 -0
- metadata +28 -15
- data/lib/contrast/components/interface.rb +0 -196
- data/lib/contrast/delegators/input_analysis.rb +0 -12
@@ -2,7 +2,7 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require 'contrast/agent/assess/tracker'
|
5
|
-
require 'contrast/components/
|
5
|
+
require 'contrast/components/logger'
|
6
6
|
require 'contrast/utils/duck_utils'
|
7
7
|
|
8
8
|
module Contrast
|
@@ -10,9 +10,7 @@ module Contrast
|
|
10
10
|
module Assess
|
11
11
|
# TrackingUtil has methods for determining if a object is being tracked
|
12
12
|
class TrackingUtil
|
13
|
-
|
14
|
-
|
15
|
-
access_component :logging
|
13
|
+
extend Contrast::Components::Logger::InstanceMethods
|
16
14
|
|
17
15
|
class << self
|
18
16
|
# Public interface to our tracking check, isolating the internals
|
@@ -3,14 +3,16 @@
|
|
3
3
|
|
4
4
|
require 'objspace'
|
5
5
|
require 'singleton'
|
6
|
-
require 'contrast/components/
|
6
|
+
require 'contrast/components/heap_dump'
|
7
|
+
require 'contrast/components/logger'
|
7
8
|
|
8
9
|
module Contrast
|
9
10
|
module Utils
|
10
11
|
# Implementation of a heap dump util to automate generation
|
11
12
|
class HeapDumpUtil < Contrast::Agent::WorkerThread
|
12
|
-
|
13
|
-
|
13
|
+
extend Contrast::Components::Logger::InstanceMethods
|
14
|
+
include Contrast::Components::Logger::InstanceMethods
|
15
|
+
extend Contrast::Components::HeapDump::InstanceMethods
|
14
16
|
|
15
17
|
LOG_ERROR_DUMPS = 'Unable to generate heap dumps'
|
16
18
|
FILE_WRITE_FLAGS = 'w'
|
@@ -2,15 +2,16 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require 'contrast/agent/assess/policy/trigger_method'
|
5
|
-
require 'contrast/components/
|
5
|
+
require 'contrast/components/logger'
|
6
|
+
require 'contrast/components/scope'
|
6
7
|
|
7
8
|
module Contrast
|
8
9
|
module Utils
|
9
10
|
# This utility allows us to report invalid configurations detected in
|
10
11
|
# customer applications, as determined by Configuration Rules at runtime.
|
11
12
|
module InvalidConfigurationUtil
|
12
|
-
include Contrast::Components::
|
13
|
-
|
13
|
+
include Contrast::Components::Logger::InstanceMethods
|
14
|
+
include Contrast::Components::Scope::InstanceMethods
|
14
15
|
|
15
16
|
CS__PATH = 'path'
|
16
17
|
CS__SESSION_ID = 'sessionId'
|
@@ -3,14 +3,13 @@
|
|
3
3
|
|
4
4
|
require 'contrast/utils/timer'
|
5
5
|
require 'contrast/utils/object_share'
|
6
|
-
require 'contrast/components/
|
6
|
+
require 'contrast/components/logger'
|
7
7
|
|
8
8
|
module Contrast
|
9
9
|
module Utils
|
10
10
|
# Utilities for getting inventory information from the application
|
11
11
|
class InventoryUtil
|
12
|
-
|
13
|
-
access_component :logging
|
12
|
+
extend Contrast::Components::Logger::InstanceMethods
|
14
13
|
|
15
14
|
# TeamServer only accepts certain values for ArchitectureComponents.
|
16
15
|
# DO NOT CHANGE THIS!
|
@@ -1,15 +1,13 @@
|
|
1
1
|
# Copyright (c) 2021 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/components/
|
4
|
+
require 'contrast/components/logger'
|
5
5
|
|
6
6
|
module Contrast
|
7
7
|
module Utils
|
8
8
|
# Util for information about an IO
|
9
9
|
class IOUtil
|
10
|
-
|
11
|
-
|
12
|
-
access_component :logging
|
10
|
+
extend Contrast::Components::Logger::InstanceMethods
|
13
11
|
|
14
12
|
# We're only going to call rewind on things that we believe are safe to
|
15
13
|
# call it on. This method white lists those cases and returns false in
|
@@ -1,13 +1,14 @@
|
|
1
1
|
# Copyright (c) 2021 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/components/logger'
|
5
|
+
|
4
6
|
module Contrast
|
5
7
|
module Utils
|
6
8
|
# A module that detects whether any job servers attached to
|
7
9
|
# the application are running
|
8
10
|
module JobServersRunning
|
9
|
-
|
10
|
-
access_component :app_context, :logging
|
11
|
+
extend Contrast::Components::Logger::InstanceMethods
|
11
12
|
|
12
13
|
class << self
|
13
14
|
def job_servers_running?
|
@@ -31,7 +32,7 @@ module Contrast
|
|
31
32
|
return
|
32
33
|
end
|
33
34
|
|
34
|
-
disabled_rake_tasks = APP_CONTEXT.disabled_agent_rake_tasks
|
35
|
+
disabled_rake_tasks = ::Contrast::APP_CONTEXT.disabled_agent_rake_tasks
|
35
36
|
has_disabled_task = Rake.application.top_level_tasks.any? do |top_level_task|
|
36
37
|
disabled_rake_tasks.include?(top_level_task)
|
37
38
|
end
|
data/lib/contrast/utils/os.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Copyright (c) 2021 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/components/
|
4
|
+
require 'contrast/components/scope'
|
5
5
|
|
6
6
|
module Contrast
|
7
7
|
module Utils
|
@@ -9,8 +9,7 @@ module Contrast
|
|
9
9
|
# which will not change at runtime, such as the operating system, the
|
10
10
|
# Utility memozies to avoid multiple lookups.
|
11
11
|
module OS
|
12
|
-
|
13
|
-
access_component :scope
|
12
|
+
extend Contrast::Components::Scope::InstanceMethods
|
14
13
|
|
15
14
|
class << self
|
16
15
|
def running?
|
@@ -1,14 +1,13 @@
|
|
1
1
|
# Copyright (c) 2021 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/components/
|
4
|
+
require 'contrast/components/logger'
|
5
5
|
|
6
6
|
module Contrast
|
7
7
|
module Utils
|
8
8
|
# Utilities for encoding and normalizing strings
|
9
9
|
class StringUtils
|
10
|
-
include Contrast::Components::
|
11
|
-
access_component :logging
|
10
|
+
include Contrast::Components::Logger::InstanceMethods
|
12
11
|
|
13
12
|
UTF8 = 'utf-8'
|
14
13
|
HTTP_PREFIX = 'HTTP_'
|
@@ -7,8 +7,9 @@ module Contrast
|
|
7
7
|
class TagUtil
|
8
8
|
class << self
|
9
9
|
# Determine if the given array of tags is covered by the other
|
10
|
-
#
|
11
|
-
#
|
10
|
+
#
|
11
|
+
# @param remaining_ranges [Array<Contrast::Agent::Assess::Tag>] the tags left that haven't been covered by those given
|
12
|
+
# @param ranges Array<Contrast::Agent::Assess::Tag> the tags that are covering the first
|
12
13
|
def covered? remaining_ranges, ranges
|
13
14
|
return true unless remaining_ranges&.any?
|
14
15
|
|
@@ -74,14 +75,14 @@ module Contrast
|
|
74
75
|
|
75
76
|
# Given a collection of tags, merge any tags that are continuous
|
76
77
|
#
|
77
|
-
# If tags is a hash, it should be in the format label => [tags]
|
78
|
-
#
|
78
|
+
# If tags is a hash, it should be in the format label => [tags]. The array of tags will each be merged
|
79
|
+
# If tags is an array in the format [tags], the array will be merged
|
79
80
|
#
|
80
|
-
#
|
81
|
-
#
|
81
|
+
# The original object is returned, although setters should not be necessary since tags is a collection in
|
82
|
+
# either case
|
82
83
|
#
|
83
|
-
#
|
84
|
-
#
|
84
|
+
# @param tags [Hash{String => Array<Contrast::Agent::Assess::Tag>}, Array<Contrast::Agent::Assess::Tag>]
|
85
|
+
# @return [Hash{String => Array<Contrast::Agent::Assess::Tag>}, Array<Contrast::Agent::Assess::Tag>]
|
85
86
|
def merge_tags tags
|
86
87
|
if tags.is_a?(Hash)
|
87
88
|
tags.each_value { |value| smallerize(value) }
|
@@ -90,6 +91,12 @@ module Contrast
|
|
90
91
|
end
|
91
92
|
end
|
92
93
|
|
94
|
+
# Merge the given set of tags such that any overlap combines. For any tag which extends beyond the size of the
|
95
|
+
# target_object, the end will be updated to the target_object's length.
|
96
|
+
#
|
97
|
+
# @param target_object [Object] the thing to which the tags apply
|
98
|
+
# @param tags [Hash{String => Array<Contrast::Agent::Assess::Tag>}, Array<Contrast::Agent::Assess::Tag>]
|
99
|
+
# @return [Hash{String => Array<Contrast::Agent::Assess::Tag>}, Array<Contrast::Agent::Assess::Tag>]
|
93
100
|
def size_aware_merge target_object, tags
|
94
101
|
max_size = target_object.to_s.length
|
95
102
|
tags = merge_tags(tags)
|
@@ -100,14 +107,12 @@ module Contrast
|
|
100
107
|
|
101
108
|
private
|
102
109
|
|
103
|
-
# Add one new element to the given array
|
110
|
+
# Add one new element to the given array. The addition is done such that the new entry is inserted so that the
|
111
|
+
# range they cover is in order. Any overlapping ranges are merged before returning.
|
104
112
|
#
|
105
|
-
#
|
106
|
-
#
|
107
|
-
#
|
108
|
-
#
|
109
|
-
# arr: the array to which the element is added
|
110
|
-
# new_element: the element to be added to the array
|
113
|
+
# @param arr [Array<Contrast::Agent::Assess::Tag>]
|
114
|
+
# @param new_element []Contrast::Agent::Assess::Tag]
|
115
|
+
# @return [Array<Contrast::Agent::Assess::Tag>]
|
111
116
|
def single_ordered_merge arr, new_element
|
112
117
|
idx = 0
|
113
118
|
arr.each do |existing|
|
@@ -122,10 +127,11 @@ module Contrast
|
|
122
127
|
arr.insert(idx, new_element)
|
123
128
|
end
|
124
129
|
|
125
|
-
# Given an arry of tags, merge any that overlap
|
126
|
-
#
|
127
|
-
#
|
128
|
-
#
|
130
|
+
# Given an arry of tags, merge any that overlap. The tag that was higher up is removed from the list of tags.
|
131
|
+
# ranges like [0-3][3-6]-6-9] become [0-9]
|
132
|
+
#
|
133
|
+
# @param tags [Array<Contrast::Agent::Assess::Tag>]
|
134
|
+
# @return [Array<Contrast::Agent::Assess::Tag>]
|
129
135
|
def smallerize tags
|
130
136
|
smallered = []
|
131
137
|
curr = nil
|
data/ruby-agent.gemspec
CHANGED
@@ -51,6 +51,7 @@ def self.add_linters spec
|
|
51
51
|
spec.add_development_dependency 'debride', '1.8.2'
|
52
52
|
spec.add_development_dependency 'fasterer', '0.9.0'
|
53
53
|
spec.add_development_dependency 'flay', '2.12.1'
|
54
|
+
# spec.add_development_dependency 'steep', '0.44.1' # TODO: RUBY-714 uncomment w/ EOL of 2.5
|
54
55
|
add_rubocop(spec)
|
55
56
|
end
|
56
57
|
|
@@ -69,6 +70,7 @@ def self.add_specs spec
|
|
69
70
|
spec.add_development_dependency 'rspec-benchmark'
|
70
71
|
spec.add_development_dependency 'rspec_junit_formatter', '0.3.0'
|
71
72
|
spec.add_development_dependency 'rspec-rails', '5.0'
|
73
|
+
spec.add_development_dependency 'warning'
|
72
74
|
spec.add_development_dependency 'tzinfo-data' # Alpine rspec-rails requirement.
|
73
75
|
end
|
74
76
|
|
@@ -90,8 +92,8 @@ end
|
|
90
92
|
def self.add_tested_gems spec
|
91
93
|
spec.add_development_dependency 'async'
|
92
94
|
spec.add_development_dependency 'execjs'
|
93
|
-
spec.add_development_dependency 'sqlite3'
|
94
95
|
spec.add_development_dependency 'rhino'
|
96
|
+
spec.add_development_dependency 'sqlite3'
|
95
97
|
spec.add_development_dependency 'tilt'
|
96
98
|
spec.add_development_dependency 'xpath'
|
97
99
|
end
|
@@ -114,7 +116,7 @@ def self.add_files spec
|
|
114
116
|
# Directories used for testing:
|
115
117
|
f.match(%r{^(spec|test)/}) ||
|
116
118
|
# Directories used in pipelines
|
117
|
-
f.match(%r{^(\.github|bin|internal_resources|vendor)/}) ||
|
119
|
+
f.match(%r{^(\.github|bin|internal_resources|sig|vendor)/}) ||
|
118
120
|
# Configuration and other files that don't belong to one directory
|
119
121
|
f.match(/(Dockerfile)/) ||
|
120
122
|
f.match(/(.*\.csv)/) ||
|
data/service_executables/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.21.2
|
Binary file
|
Binary file
|
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: 4.
|
4
|
+
version: 4.9.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: 2021-
|
16
|
+
date: 2021-06-24 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: bundler
|
@@ -296,7 +296,7 @@ dependencies:
|
|
296
296
|
- !ruby/object:Gem::Version
|
297
297
|
version: '0'
|
298
298
|
- !ruby/object:Gem::Dependency
|
299
|
-
name:
|
299
|
+
name: rhino
|
300
300
|
requirement: !ruby/object:Gem::Requirement
|
301
301
|
requirements:
|
302
302
|
- - ">="
|
@@ -310,7 +310,7 @@ dependencies:
|
|
310
310
|
- !ruby/object:Gem::Version
|
311
311
|
version: '0'
|
312
312
|
- !ruby/object:Gem::Dependency
|
313
|
-
name:
|
313
|
+
name: sqlite3
|
314
314
|
requirement: !ruby/object:Gem::Requirement
|
315
315
|
requirements:
|
316
316
|
- - ">="
|
@@ -477,6 +477,20 @@ dependencies:
|
|
477
477
|
- - '='
|
478
478
|
- !ruby/object:Gem::Version
|
479
479
|
version: '5.0'
|
480
|
+
- !ruby/object:Gem::Dependency
|
481
|
+
name: warning
|
482
|
+
requirement: !ruby/object:Gem::Requirement
|
483
|
+
requirements:
|
484
|
+
- - ">="
|
485
|
+
- !ruby/object:Gem::Version
|
486
|
+
version: '0'
|
487
|
+
type: :development
|
488
|
+
prerelease: false
|
489
|
+
version_requirements: !ruby/object:Gem::Requirement
|
490
|
+
requirements:
|
491
|
+
- - ">="
|
492
|
+
- !ruby/object:Gem::Version
|
493
|
+
version: '0'
|
480
494
|
- !ruby/object:Gem::Dependency
|
481
495
|
name: tzinfo-data
|
482
496
|
requirement: !ruby/object:Gem::Requirement
|
@@ -555,20 +569,20 @@ executables:
|
|
555
569
|
- contrast_service
|
556
570
|
extensions:
|
557
571
|
- ext/cs__common/extconf.rb
|
558
|
-
- ext/
|
559
|
-
- ext/
|
560
|
-
- ext/cs__protect_kernel/extconf.rb
|
572
|
+
- ext/cs__assess_string_interpolation26/extconf.rb
|
573
|
+
- ext/cs__contrast_patch/extconf.rb
|
561
574
|
- ext/cs__assess_module/extconf.rb
|
562
|
-
- ext/
|
563
|
-
- ext/
|
575
|
+
- ext/cs__assess_kernel/extconf.rb
|
576
|
+
- ext/cs__assess_yield_track/extconf.rb
|
577
|
+
- ext/cs__assess_string/extconf.rb
|
564
578
|
- ext/cs__assess_array/extconf.rb
|
565
|
-
- ext/
|
566
|
-
- ext/
|
579
|
+
- ext/cs__assess_active_record_named/extconf.rb
|
580
|
+
- ext/cs__assess_hash/extconf.rb
|
567
581
|
- ext/cs__assess_regexp/extconf.rb
|
582
|
+
- ext/cs__assess_fiber_track/extconf.rb
|
568
583
|
- ext/cs__assess_marshal_module/extconf.rb
|
584
|
+
- ext/cs__protect_kernel/extconf.rb
|
569
585
|
- ext/cs__assess_basic_object/extconf.rb
|
570
|
-
- ext/cs__assess_hash/extconf.rb
|
571
|
-
- ext/cs__assess_yield_track/extconf.rb
|
572
586
|
extra_rdoc_files: []
|
573
587
|
files:
|
574
588
|
- ".clang-format"
|
@@ -927,10 +941,10 @@ files:
|
|
927
941
|
- lib/contrast/components/agent.rb
|
928
942
|
- lib/contrast/components/app_context.rb
|
929
943
|
- lib/contrast/components/assess.rb
|
944
|
+
- lib/contrast/components/base.rb
|
930
945
|
- lib/contrast/components/config.rb
|
931
946
|
- lib/contrast/components/contrast_service.rb
|
932
947
|
- lib/contrast/components/heap_dump.rb
|
933
|
-
- lib/contrast/components/interface.rb
|
934
948
|
- lib/contrast/components/inventory.rb
|
935
949
|
- lib/contrast/components/logger.rb
|
936
950
|
- lib/contrast/components/protect.rb
|
@@ -957,7 +971,6 @@ files:
|
|
957
971
|
- lib/contrast/config/server_configuration.rb
|
958
972
|
- lib/contrast/config/service_configuration.rb
|
959
973
|
- lib/contrast/configuration.rb
|
960
|
-
- lib/contrast/delegators/input_analysis.rb
|
961
974
|
- lib/contrast/extension/assess.rb
|
962
975
|
- lib/contrast/extension/assess/array.rb
|
963
976
|
- lib/contrast/extension/assess/erb.rb
|
@@ -1,196 +0,0 @@
|
|
1
|
-
# Copyright (c) 2021 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require 'delegate'
|
5
|
-
require 'contrast/extension/module'
|
6
|
-
require 'contrast/utils/object_share'
|
7
|
-
|
8
|
-
module Contrast
|
9
|
-
# This is the base module for our components classes. It is intended to
|
10
|
-
# facilitate the translation of the Common Configuration settings to usable
|
11
|
-
# Ruby methods. Any class under this namespace should be required here,
|
12
|
-
# providing a single point of require for this functionality.
|
13
|
-
module Components
|
14
|
-
# Include this into your classes and modules,
|
15
|
-
# and use 'access_component' to define constants that will allow
|
16
|
-
# interaction with other components.
|
17
|
-
module Interface
|
18
|
-
def self.included klass
|
19
|
-
# Upon inclusion, ComponentInterfaces extends the including with
|
20
|
-
# these two interfaces.
|
21
|
-
# Interface provides a class-level method 'access_component'
|
22
|
-
# that regulates per-class access to agent state.
|
23
|
-
# (It's a glorified `include MyComponent`).
|
24
|
-
klass.extend Contrast::Components::ComponentReceiverClassInterface
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
# All component access is gated through delegators.
|
29
|
-
#
|
30
|
-
# One delegator is used by the calling class,
|
31
|
-
# so we can tweak outgoing calls.
|
32
|
-
#
|
33
|
-
# The second delegator is used by the receiving component,
|
34
|
-
# so we can tweak incoming calls.
|
35
|
-
#
|
36
|
-
# We use __setobj__ to decide which component implementation to use.
|
37
|
-
# This is intended to provide flexibility in design and
|
38
|
-
# simplicity in testing.
|
39
|
-
class ComponentDelegator < SimpleDelegator
|
40
|
-
# intentionally left blank
|
41
|
-
end
|
42
|
-
|
43
|
-
# All components should inherit from this,
|
44
|
-
# whether Interfaces, InstanceMethods or ClassMethods.
|
45
|
-
module ComponentBase
|
46
|
-
def self.included klass
|
47
|
-
klass.extend Methods
|
48
|
-
klass.include Methods
|
49
|
-
end
|
50
|
-
|
51
|
-
module Methods # :nodoc:
|
52
|
-
# use this to determine if the configuration value is literally boolean
|
53
|
-
# false or some form of the word `false`, regardless of case. It should
|
54
|
-
# be used for those values which default to `true` as they should only
|
55
|
-
# treat a value explicitly set to `false` as such.
|
56
|
-
#
|
57
|
-
# @param config_param [Boolean,String] the value to check
|
58
|
-
# @return [Boolean] should the value be treated as `false`
|
59
|
-
def false? config_param
|
60
|
-
return false if config_param == true
|
61
|
-
return true if config_param == false
|
62
|
-
return false unless config_param.cs__is_a?(String)
|
63
|
-
|
64
|
-
Contrast::Utils::ObjectShare::FALSE.casecmp?(config_param)
|
65
|
-
end
|
66
|
-
|
67
|
-
# use this to determine if the configuration value is literally boolean
|
68
|
-
# true or some form of the word `true`, regardless of case. It should
|
69
|
-
# be used for those values which default to `false` as they should only
|
70
|
-
# treat a value explicitly set to `true` as such.
|
71
|
-
#
|
72
|
-
# @param config_param [Boolean,String] the value to check
|
73
|
-
# @return [Boolean] should the value be treated as `true`
|
74
|
-
def true? config_param
|
75
|
-
return false if config_param == false
|
76
|
-
return true if config_param == true
|
77
|
-
return false unless config_param.cs__is_a?(String)
|
78
|
-
|
79
|
-
Contrast::Utils::ObjectShare::TRUE.casecmp?(config_param)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def self.component_const_name mod_name
|
85
|
-
mod_name = mod_name.split('::').last
|
86
|
-
@cache ||= {}
|
87
|
-
@cache[mod_name] ||= mod_name. # CamelCaseName
|
88
|
-
split(/(?=[A-Z])/)&. # ['Camel', 'Case', 'Name']
|
89
|
-
map(&:upcase)&. # ['CAMEL', 'CASE', 'NAME']
|
90
|
-
join('_') # 'CAMEL_CASE_NAME'
|
91
|
-
end
|
92
|
-
|
93
|
-
# Interface to allow for iteration over each of the configuration
|
94
|
-
# components
|
95
|
-
module ComponentReceiverClassInterface
|
96
|
-
# Components are manually required at the end of
|
97
|
-
# this file, and this constant is then frozen.
|
98
|
-
# RUBY-535 to handle this better.
|
99
|
-
COMPONENT_MAP = {} # rubocop:disable Style/MutableConstant
|
100
|
-
|
101
|
-
# TODO: RUBY-535
|
102
|
-
# This module is used via `extend`, so it can't access
|
103
|
-
# constants we define here.
|
104
|
-
def component_map
|
105
|
-
COMPONENT_MAP
|
106
|
-
end
|
107
|
-
|
108
|
-
# .access_component
|
109
|
-
#
|
110
|
-
# to be used as:
|
111
|
-
#
|
112
|
-
# class Abc
|
113
|
-
# include Contrast::Components::Interface
|
114
|
-
# access_component :logging, :agent
|
115
|
-
#
|
116
|
-
# def function
|
117
|
-
# if AGENT.disabled?
|
118
|
-
# 0 / 3
|
119
|
-
# end
|
120
|
-
# rescue
|
121
|
-
# logger.error "this function did error"
|
122
|
-
# end
|
123
|
-
# end
|
124
|
-
#
|
125
|
-
# `:logger` creates a #logger and .logger method
|
126
|
-
# `:agent` provides an AGENT constant, analogous to a local singleton.
|
127
|
-
#
|
128
|
-
def access_component *component_set_syms
|
129
|
-
@_access_component ||= {}
|
130
|
-
|
131
|
-
component_set_syms.each do |sym|
|
132
|
-
next if @_access_component[sym]
|
133
|
-
|
134
|
-
if (mods = component_map[sym]) # rubocop:disable Style/GuardClause
|
135
|
-
# We may support multiple components via one access request.
|
136
|
-
mods.each do |m|
|
137
|
-
name = Contrast::Components.component_const_name(m.cs__name)
|
138
|
-
cs__const_set(name, m::COMPONENT_INTERFACE) if m.cs__const_defined?(:COMPONENT_INTERFACE)
|
139
|
-
include m::InstanceMethods if m.cs__const_defined?(:InstanceMethods, false)
|
140
|
-
extend m::ClassMethods if m.cs__const_defined?(:ClassMethods, false)
|
141
|
-
end
|
142
|
-
|
143
|
-
@_access_component[sym] = true
|
144
|
-
else
|
145
|
-
raise NoMethodError, "#{ self } asked to access undefined component '#{ sym }'."
|
146
|
-
end
|
147
|
-
end
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
# Components can depend on other components, but it should be a
|
154
|
-
# directed acyclic graph.
|
155
|
-
|
156
|
-
# Scope shouldn't depend on anything.
|
157
|
-
require 'contrast/components/scope'
|
158
|
-
Contrast::Components::ComponentReceiverClassInterface::COMPONENT_MAP[:scope] = [Contrast::Components::Scope]
|
159
|
-
|
160
|
-
# Config depends on Scope.
|
161
|
-
require 'contrast/components/config'
|
162
|
-
Contrast::Components::ComponentReceiverClassInterface::COMPONENT_MAP[:config] = [Contrast::Components::Config]
|
163
|
-
|
164
|
-
# Settings should not depend on anything but Config.
|
165
|
-
require 'contrast/components/settings'
|
166
|
-
Contrast::Components::ComponentReceiverClassInterface::COMPONENT_MAP[:settings] = [Contrast::Components::Settings]
|
167
|
-
|
168
|
-
require 'contrast/components/assess'
|
169
|
-
require 'contrast/components/protect'
|
170
|
-
require 'contrast/components/inventory'
|
171
|
-
Contrast::Components::ComponentReceiverClassInterface::COMPONENT_MAP[:analysis] = [
|
172
|
-
Contrast::Components::Protect,
|
173
|
-
Contrast::Components::Assess,
|
174
|
-
Contrast::Components::Inventory
|
175
|
-
]
|
176
|
-
|
177
|
-
require 'contrast/components/logger'
|
178
|
-
Contrast::Components::ComponentReceiverClassInterface::COMPONENT_MAP[:logging] = [Contrast::Components::Logger]
|
179
|
-
|
180
|
-
require 'contrast/components/agent'
|
181
|
-
Contrast::Components::ComponentReceiverClassInterface::COMPONENT_MAP[:agent] = [Contrast::Components::Agent]
|
182
|
-
|
183
|
-
require 'contrast/components/contrast_service'
|
184
|
-
Contrast::Components::ComponentReceiverClassInterface::COMPONENT_MAP[:contrast_service] =
|
185
|
-
[Contrast::Components::ContrastService]
|
186
|
-
|
187
|
-
require 'contrast/components/app_context'
|
188
|
-
Contrast::Components::ComponentReceiverClassInterface::COMPONENT_MAP[:app_context] = [Contrast::Components::AppContext]
|
189
|
-
|
190
|
-
require 'contrast/components/heap_dump'
|
191
|
-
Contrast::Components::ComponentReceiverClassInterface::COMPONENT_MAP[:heap_dump] = [Contrast::Components::HeapDump]
|
192
|
-
|
193
|
-
require 'contrast/components/sampling'
|
194
|
-
Contrast::Components::ComponentReceiverClassInterface::COMPONENT_MAP[:sampling] = [Contrast::Components::Sampling]
|
195
|
-
|
196
|
-
Contrast::Components::ComponentReceiverClassInterface::COMPONENT_MAP.cs__freeze
|