Skip to content

NH-155200: santize the endpoint uri and include bearer token only for… - #321

Merged
xuan-cao-swi merged 8 commits into
mainfrom
NH-155200
Nov 19, 2026
Merged

xuan-cao-swi merged 8 commits into
mainfrom
NH-155200

Conversation

@xuan-cao-swi

@xuan-cao-swi xuan-cao-swi commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Description

  • Remove that OTEL_EXPORTER_OTLP_HEADERS=authorization=Bearer <token> regardless of endpoint. Now it only add the bearer token for solarwinds endpoint (per signal)
  • Check and parses the endpoint uri. Solarwinds uri now requires https, no userinfo, and a host matching otel.collector.*.*.solarwinds.com only.

@xuan-cao-swi
xuan-cao-swi marked this pull request as ready for review November 12, 2026 16:25
@xuan-cao-swi
xuan-cao-swi requested review from a team as code owners November 12, 2026 16:26
Copilot AI balanced review requested due to automatic review settings November 12, 2026 16:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

@tammy-baylis-swi

Copy link
Copy Markdown
Contributor

Looks good overall and appreciate the test for custom metrics endpoint does not leak bearer.

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?

@xuan-cao-swi

Copy link
Copy Markdown
Contributor Author

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)

@cheempz cheempz Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added to sanitize collector endpoint

def swo_otlp_endpoint?(endpoint)
return false if endpoint.to_s.empty?

uri = URI.parse(endpoint.to_s.strip)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the strip

Comment thread CONFIGURATION.md Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unsupported rubocop:disable-next directives leave naming and duplicate-method offenses unsuppressed in three test files.

1 open issue
1 resolved since last review

Review effort: Balanced

Comment on lines +15 to 20
# rubocop:disable-next Naming/MethodName
module SolarWindsAPM
module Span
def self.createSpan(trans_name, domain, span_time, has_error); end
end
end

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new rubocop will use rubocop:disable-next to disable entire module block so # rubocop:disable Naming/MethodName is not needed

@cheempz cheempz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, @xuan-cao-swi pls take a look at the latest copilot review finding, seems minor but happy to reapprove if you address it.

@xuan-cao-swi
xuan-cao-swi merged commit 23197fa into main Nov 19, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants