feat: implement TLS certificate verification and add new flags#40
Merged
wu-sheng merged 7 commits intoapache:mainfrom Mar 31, 2026
Merged
feat: implement TLS certificate verification and add new flags#40wu-sheng merged 7 commits intoapache:mainfrom
wu-sheng merged 7 commits intoapache:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR tightens security and input validation around SkyWalking OAP connectivity and HTTP transports, while adding operator-facing flags for controlled exceptions and origin enforcement.
Changes:
- Enforce (and optionally bypass via
--sw-insecure) TLS certificate verification for OAP connections used by MQE’s direct HTTP GraphQL client; reject non-http/https OAP URL schemes. - Add CORS/Origin enforcement (
--allowed-origins) to SSE + Streamable transports via a shared middleware wrapper. - Redact sensitive JSON fields in
--log-commandoutput; add warnings for unresolved${ENV_VAR}credentials; add/adjust unit tests and docs.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents new global and transport-specific flags and usage examples. |
| cmd/skywalking-mcp/main.go | Adds --sw-insecure flag and binds it into viper config. |
| internal/swmcp/server.go | Propagates insecure flag into request context; warns on missing env vars for credentials. |
| internal/tools/mqe.go | Adds URL scheme validation, TLS config behavior, and regex/layer validation for MQE tools. |
| internal/tools/common.go | Adds validateURLScheme helper for OAP URL scheme enforcement. |
| internal/tools/io.go | Adds sensitive-field redaction for --log-command stdin/stdout logging. |
| internal/swmcp/cors.go | Introduces CORS/origin enforcement middleware and allowlist parsing. |
| internal/swmcp/sse.go | Adds --allowed-origins and wraps SSE HTTP server with CORS middleware. |
| internal/swmcp/streamable.go | Adds --allowed-origins and wraps Streamable HTTP server with CORS middleware. |
| internal/swmcp/server_registry_test.go | Refactors registry tests to prefer public tool inventory APIs where available. |
| internal/tools/common_test.go | Adds unit tests for URL finalization, duration parsing, pagination, etc. |
| internal/tools/alarm_test.go | Adds tests around alarm query condition building/duration defaults. |
| CLAUDE.md | Updates developer documentation for TLS, origin enforcement, and MQE validation rules. |
| CHANGES.md | Adds 0.2.0 release notes entries for the new security/validation features. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
wu-sheng
approved these changes
Mar 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TLS certificate verification is now enforced for OAP connections. Added
--sw-insecureflag to opt out (development/self-signed certs only).authorization,password,token,secret) are redacted in--log-commandoutput.${VAR}) in--sw-username/--sw-passwordnow log a warning when the variable is not set, preventing silent unauthenticated requests.list_mqe_metricsare validated for complexity before compilation.--allowed-originsflag tosseandstreamabletransports for CORS/CSRF origin enforcement. Requests carrying anOriginheader not in the allowlist receive403 Forbidden. When unset, all origins are permitted (backward compatible).Signed-off-by: Qiuxia Fan qiuxiafan@apache.org