Repository navigation
NH-155200: santize the endpoint uri and include bearer token only for… - #321
Conversation
… solarwinds endpoint
There was a problem hiding this comment.
🟡 Changes recommended
The endpoint tests do not assert the new INFO message, leaving its signal-specific header guidance and credential-free endpoint logging unverified.
1 open issue
What changed in this PR
This PR limits automatic service-key authorization to validated SolarWinds OTLP endpoints, preventing the Ruby agent from attaching the token to custom collectors.
Changes:
- Set authorization per signal after resolving endpoints, with stricter URI and hostname validation.
- Add sanitized INFO messages, custom-collector guidance, and regression tests.
- Remove the outdated changelog.
| File | Description |
|---|---|
test/support/otlp_endpoint_test.rb |
Tests token isolation, endpoint validation, and sanitization. |
lib/solarwinds_apm/support/otlp_endpoint.rb |
Restricts token injection and logs sanitized custom-endpoint guidance. |
CONFIGURATION.md |
Documents authorization behavior and custom-collector configuration. |
CHANGELOG.md |
Removes the outdated release history. |
Review effort: Balanced
|
Looks good overall and appreciate the test for If it's been agreed somewhere to completely remove the Changelog because records are being kept somewhere else, then could that please be in a separate PR? |
Sure, added it back for now |
| end | ||
|
|
||
| # Only scheme, host and port are logged, never userinfo or query that may carry credentials. | ||
| def sanitize_endpoint(endpoint) |
There was a problem hiding this comment.
From PR title the intention is to also apply sanitization to the collector endpoint, but i'm not seeing this method used anywhere other than tests.
There was a problem hiding this comment.
Added to sanitize collector endpoint
| def swo_otlp_endpoint?(endpoint) | ||
| return false if endpoint.to_s.empty? | ||
|
|
||
| uri = URI.parse(endpoint.to_s.strip) |
There was a problem hiding this comment.
From an ad-hoc AI review, and related to my comment about sanitizing actual exporter input: this validates a different value from the one passed to the exporter. An endpoint with leading whitespace or a trailing newline passes the SolarWinds check and receives a bearer header, but the unchanged environment value is rejected by the exporter’s URI parser. Prefer validating the raw value, or consistently normalizing it before both uses.
There was a problem hiding this comment.
Removed the strip
Co-authored-by: Lin Lin <lin.lin@solarwinds.com>
| # rubocop:disable-next Naming/MethodName | ||
| module SolarWindsAPM | ||
| module Span | ||
| def self.createSpan(trans_name, domain, span_time, has_error); end | ||
| end | ||
| end |
There was a problem hiding this comment.
new rubocop will use rubocop:disable-next to disable entire module block so # rubocop:disable Naming/MethodName is not needed
cheempz
left a comment
There was a problem hiding this comment.
LGTM, @xuan-cao-swi pls take a look at the latest copilot review finding, seems minor but happy to reapprove if you address it.

Description
OTEL_EXPORTER_OTLP_HEADERS=authorization=Bearer <token>regardless of endpoint. Now it only add the bearer token for solarwinds endpoint (per signal)otel.collector.*.*.solarwinds.comonly.