Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

9 changes: 0 additions & 9 deletions lib/datadog/appsec/configuration/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -352,15 +352,6 @@ def self.add_settings!(base)
o.default true
end

settings :endpoint_collection do
# Enables reporting of application routes at application start via telemetry
option :enabled do |o|
o.type :bool, nilable: true
o.env 'DD_API_SECURITY_ENDPOINT_COLLECTION_ENABLED'
o.default false
end
end

# NOTE: Unfortunately, we have to go with Float due to other libs
# setup, even tho we don't plan to support sub-second delays.
#
Expand Down
28 changes: 0 additions & 28 deletions lib/datadog/appsec/contrib/rails/patcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
require_relative 'gateway/request'
require_relative 'patches/render_to_body_patch'
require_relative 'patches/process_action_patch'
require_relative '../../api_security/endpoint_collection/rails_routes_serializer'

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

Expand All @@ -21,7 +20,6 @@ module Rails
# Patcher for AppSec on Rails
module Patcher
GUARD_ACTION_CONTROLLER_ONCE_PER_APP = Hash.new { |h, key| h[key] = Datadog::Core::Utils::OnlyOnce.new }
GUARD_ROUTES_REPORTING_ONCE_PER_APP = Hash.new { |h, key| h[key] = Datadog::Core::Utils::OnlyOnce.new }
BEFORE_INITIALIZE_ONLY_ONCE_PER_APP = Hash.new { |h, key| h[key] = Datadog::Core::Utils::OnlyOnce.new }
AFTER_INITIALIZE_ONLY_ONCE_PER_APP = Hash.new { |h, key| h[key] = Datadog::Core::Utils::OnlyOnce.new }

Expand All @@ -40,7 +38,6 @@ def patch
patch_before_initialize
patch_after_initialize
patch_action_controller
subscribe_to_routes_loaded

Patcher.instance_variable_set(:@patched, true)
end
Expand Down Expand Up @@ -131,31 +128,6 @@ def patch_action_controller
GUARD_ACTION_CONTROLLER_ONCE_PER_APP[self].run do
::ActionController::Base.prepend(Patches::RenderToBodyPatch)
end

# Rails 7.1 adds `after_routes_loaded` hook
if Datadog::AppSec::Contrib::Rails::Patcher.target_version < Gem::Version.new('7.1')
Datadog::AppSec::Contrib::Rails::Patcher.report_routes_via_telemetry(::Rails.application.routes.routes)
end
end
end

def subscribe_to_routes_loaded
::ActiveSupport.on_load(:after_routes_loaded) do |app|
Datadog::AppSec::Contrib::Rails::Patcher.report_routes_via_telemetry(app.routes.routes)
end
end

def report_routes_via_telemetry(routes)
# We do not support Rails 4.x for Endpoint Collection,
# mainly because the Route#verb was a Regexp before Rails 5.0
return if target_version < Gem::Version.new('5.0')

return unless Datadog.configuration.appsec.api_security.endpoint_collection.enabled

GUARD_ROUTES_REPORTING_ONCE_PER_APP[self].run do
AppSec.telemetry.app_endpoints_loaded(
APISecurity::EndpointCollection::RailsRoutesSerializer.new(routes).to_enum
)
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ module Configuration
{"DD_AGENT_HOST" => {version: ["A"]},
"DD_API_KEY" => {version: ["A"]},
"DD_API_SECURITY_ENABLED" => {version: ["A"]},
"DD_API_SECURITY_ENDPOINT_COLLECTION_ENABLED" => {version: ["A"]},
"DD_API_SECURITY_REQUEST_SAMPLE_RATE" => {version: ["A"]},
"DD_API_SECURITY_SAMPLE_DELAY" => {version: ["A"]},
"DD_APM_TRACING_ENABLED" => {version: ["A"]},
Expand Down

This file was deleted.

4 changes: 0 additions & 4 deletions sig/datadog/appsec/contrib/rails/patcher.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ module Datadog

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

def self.subscribe_to_routes_loaded: () -> void

def self.report_routes_via_telemetry: () -> void

def self?.setup_security: () -> untyped
end
end
Expand Down

This file was deleted.

38 changes: 0 additions & 38 deletions spec/datadog/appsec/configuration/settings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1015,44 +1015,6 @@ def patcher
end
end
end

describe 'endpoint_collection' do
describe '#enabled' do
context 'when DD_API_SECURITY_ENDPOINT_COLLECTION_ENABLED is undefined' do
around do |example|
ClimateControl.modify('DD_API_SECURITY_ENDPOINT_COLLECTION_ENABLED' => nil) { example.run }
end

it { expect(settings.appsec.api_security.endpoint_collection.enabled).to eq(false) }
end

context 'when DD_API_SECURITY_ENDPOINT_COLLECTION_ENABLED is set to true' do
around do |example|
ClimateControl.modify('DD_API_SECURITY_ENDPOINT_COLLECTION_ENABLED' => 'true') { example.run }
end

it { expect(settings.appsec.api_security.endpoint_collection.enabled).to eq(true) }
end

context 'when DD_API_SECURITY_ENDPOINT_COLLECTION_ENABLED is set to false' do
around do |example|
ClimateControl.modify('DD_API_SECURITY_ENDPOINT_COLLECTION_ENABLED' => 'false') { example.run }
end

it { expect(settings.appsec.api_security.endpoint_collection.enabled).to eq(false) }
end
end

describe '#enabled=' do
[true, false].each do |value|
context "when given #{value}" do
before { settings.appsec.api_security.endpoint_collection.enabled = value }

it { expect(settings.appsec.api_security.endpoint_collection.enabled).to eq(value) }
end
end
end
end
end

describe 'sca' do
Expand Down
Loading
Loading