Skip to content

Commit 49a5c68

Browse files
authored
Merge pull request #4944 from DataDog/revert-endpoint-collection
Revert "Merge pull request #4919 from DataDog/appsec-endpoint-collection"
2 parents eae7fc6 + 1876f61 commit 49a5c68

File tree

10 files changed

+0
-463
lines changed

10 files changed

+0
-463
lines changed

lib/datadog/appsec/api_security/endpoint_collection/rails_routes_serializer.rb

Lines changed: 0 additions & 43 deletions
This file was deleted.

lib/datadog/appsec/configuration/settings.rb

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -352,15 +352,6 @@ def self.add_settings!(base)
352352
o.default true
353353
end
354354

355-
settings :endpoint_collection do
356-
# Enables reporting of application routes at application start via telemetry
357-
option :enabled do |o|
358-
o.type :bool, nilable: true
359-
o.env 'DD_API_SECURITY_ENDPOINT_COLLECTION_ENABLED'
360-
o.default false
361-
end
362-
end
363-
364355
# NOTE: Unfortunately, we have to go with Float due to other libs
365356
# setup, even tho we don't plan to support sub-second delays.
366357
#

lib/datadog/appsec/contrib/rails/patcher.rb

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
require_relative 'gateway/request'
1111
require_relative 'patches/render_to_body_patch'
1212
require_relative 'patches/process_action_patch'
13-
require_relative '../../api_security/endpoint_collection/rails_routes_serializer'
1413

1514
require_relative '../../../tracing/contrib/rack/middlewares'
1615

@@ -21,7 +20,6 @@ module Rails
2120
# Patcher for AppSec on Rails
2221
module Patcher
2322
GUARD_ACTION_CONTROLLER_ONCE_PER_APP = Hash.new { |h, key| h[key] = Datadog::Core::Utils::OnlyOnce.new }
24-
GUARD_ROUTES_REPORTING_ONCE_PER_APP = Hash.new { |h, key| h[key] = Datadog::Core::Utils::OnlyOnce.new }
2523
BEFORE_INITIALIZE_ONLY_ONCE_PER_APP = Hash.new { |h, key| h[key] = Datadog::Core::Utils::OnlyOnce.new }
2624
AFTER_INITIALIZE_ONLY_ONCE_PER_APP = Hash.new { |h, key| h[key] = Datadog::Core::Utils::OnlyOnce.new }
2725

@@ -40,7 +38,6 @@ def patch
4038
patch_before_initialize
4139
patch_after_initialize
4240
patch_action_controller
43-
subscribe_to_routes_loaded
4441

4542
Patcher.instance_variable_set(:@patched, true)
4643
end
@@ -131,31 +128,6 @@ def patch_action_controller
131128
GUARD_ACTION_CONTROLLER_ONCE_PER_APP[self].run do
132129
::ActionController::Base.prepend(Patches::RenderToBodyPatch)
133130
end
134-
135-
# Rails 7.1 adds `after_routes_loaded` hook
136-
if Datadog::AppSec::Contrib::Rails::Patcher.target_version < Gem::Version.new('7.1')
137-
Datadog::AppSec::Contrib::Rails::Patcher.report_routes_via_telemetry(::Rails.application.routes.routes)
138-
end
139-
end
140-
end
141-
142-
def subscribe_to_routes_loaded
143-
::ActiveSupport.on_load(:after_routes_loaded) do |app|
144-
Datadog::AppSec::Contrib::Rails::Patcher.report_routes_via_telemetry(app.routes.routes)
145-
end
146-
end
147-
148-
def report_routes_via_telemetry(routes)
149-
# We do not support Rails 4.x for Endpoint Collection,
150-
# mainly because the Route#verb was a Regexp before Rails 5.0
151-
return if target_version < Gem::Version.new('5.0')
152-
153-
return unless Datadog.configuration.appsec.api_security.endpoint_collection.enabled
154-
155-
GUARD_ROUTES_REPORTING_ONCE_PER_APP[self].run do
156-
AppSec.telemetry.app_endpoints_loaded(
157-
APISecurity::EndpointCollection::RailsRoutesSerializer.new(routes).to_enum
158-
)
159131
end
160132
end
161133

lib/datadog/core/configuration/supported_configurations.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ module Configuration
1010
{"DD_AGENT_HOST" => {version: ["A"]},
1111
"DD_API_KEY" => {version: ["A"]},
1212
"DD_API_SECURITY_ENABLED" => {version: ["A"]},
13-
"DD_API_SECURITY_ENDPOINT_COLLECTION_ENABLED" => {version: ["A"]},
1413
"DD_API_SECURITY_REQUEST_SAMPLE_RATE" => {version: ["A"]},
1514
"DD_API_SECURITY_SAMPLE_DELAY" => {version: ["A"]},
1615
"DD_APM_TRACING_ENABLED" => {version: ["A"]},

sig/datadog/appsec/api_security/endpoint_collection/rails_routes_serializer.rbs

Lines changed: 0 additions & 33 deletions
This file was deleted.

sig/datadog/appsec/contrib/rails/patcher.rbs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ module Datadog
2727

2828
def self?.after_initialize: (untyped app) -> untyped
2929

30-
def self.subscribe_to_routes_loaded: () -> void
31-
32-
def self.report_routes_via_telemetry: () -> void
33-
3430
def self?.setup_security: () -> untyped
3531
end
3632
end

spec/datadog/appsec/api_security/endpoint_collection/rails_routes_serializer_spec.rb

Lines changed: 0 additions & 70 deletions
This file was deleted.

spec/datadog/appsec/configuration/settings_spec.rb

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,44 +1015,6 @@ def patcher
10151015
end
10161016
end
10171017
end
1018-
1019-
describe 'endpoint_collection' do
1020-
describe '#enabled' do
1021-
context 'when DD_API_SECURITY_ENDPOINT_COLLECTION_ENABLED is undefined' do
1022-
around do |example|
1023-
ClimateControl.modify('DD_API_SECURITY_ENDPOINT_COLLECTION_ENABLED' => nil) { example.run }
1024-
end
1025-
1026-
it { expect(settings.appsec.api_security.endpoint_collection.enabled).to eq(false) }
1027-
end
1028-
1029-
context 'when DD_API_SECURITY_ENDPOINT_COLLECTION_ENABLED is set to true' do
1030-
around do |example|
1031-
ClimateControl.modify('DD_API_SECURITY_ENDPOINT_COLLECTION_ENABLED' => 'true') { example.run }
1032-
end
1033-
1034-
it { expect(settings.appsec.api_security.endpoint_collection.enabled).to eq(true) }
1035-
end
1036-
1037-
context 'when DD_API_SECURITY_ENDPOINT_COLLECTION_ENABLED is set to false' do
1038-
around do |example|
1039-
ClimateControl.modify('DD_API_SECURITY_ENDPOINT_COLLECTION_ENABLED' => 'false') { example.run }
1040-
end
1041-
1042-
it { expect(settings.appsec.api_security.endpoint_collection.enabled).to eq(false) }
1043-
end
1044-
end
1045-
1046-
describe '#enabled=' do
1047-
[true, false].each do |value|
1048-
context "when given #{value}" do
1049-
before { settings.appsec.api_security.endpoint_collection.enabled = value }
1050-
1051-
it { expect(settings.appsec.api_security.endpoint_collection.enabled).to eq(value) }
1052-
end
1053-
end
1054-
end
1055-
end
10561018
end
10571019

10581020
describe 'sca' do

0 commit comments

Comments
 (0)