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
2 changes: 1 addition & 1 deletion .github/workflows/system-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
include:
- weblogs: "" # All of them
scenarios: DEFAULT,EVERYTHING_DISABLED,APPSEC_BLOCKING_FULL_DENYLIST,APPSEC_BLOCKING,GRAPHQL_APPSEC,PARAMETRIC
- weblogs: rack,rails70
- weblogs: rack,rails72
scenarios: |
APPSEC_API_SECURITY,
APPSEC_API_SECURITY_RC,
Expand Down
4 changes: 2 additions & 2 deletions lib/datadog/appsec/contrib/rails/patcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,16 @@ 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
return unless AppSec.telemetry

GUARD_ROUTES_REPORTING_ONCE_PER_APP[::Rails.application].run do
AppSec.telemetry.app_endpoints_loaded(
APISecurity::EndpointCollection::RailsRoutesSerializer.new(routes).to_enum
)
end
rescue => e
AppSec.telemetry.report(e, description: 'failed to report application endpoints')
AppSec.telemetry&.report(e, description: 'failed to report application endpoints')
end

def setup_security
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,14 @@ def initialize(files, dirs = {}, &block)
ActiveSupport.run_load_hooks(:after_routes_loaded, Rails.application)
end

it 'does not raise an error when AppSec.telemetry is nil' do
allow(Datadog::AppSec).to receive(:telemetry).and_return(nil)

expect do
ActiveSupport.run_load_hooks(:after_routes_loaded, Rails.application)
end.not_to raise_error
end

it 'reports routes via telemetry' do
ActiveSupport.run_load_hooks(:after_routes_loaded, Rails.application)

Expand Down