mirror of
https://github.com/netbirdio/netbird.git
synced 2026-09-12 17:59:06 +02:00
The debug-bundle paths that upload without a human picking a destination compiled the vendor endpoint in: the mobile clients and the desktop UI hold `https://upload.debug.netbird.io/upload-url` as a constant, the CLI defaults its flag to it, and the remote job falls back to it when nothing else is set. A self-hosted deployment therefore shipped peer logs, routes, DNS and firewall state to NetBird-run infrastructure without its operator ever configuring that, and had no way to point those paths anywhere else. #7147 and #7153 gave the remote job a per-job URL and an MDM override, but neither reaches the mobile, UI or CLI paths, and both fail open when unset. Publish the destination from the management server instead, on the channel that already carries stun/turn/signal/relay/flow/metrics: - `NetbirdConfig.debug.upload_url`, sourced from the new account setting `debug_bundle_upload_url` (REST + dashboard) and falling back to the new `DebugUpload.URL` in the management server config, which a self-hosted install can set once so a fresh account is not left on the vendor default. Both are validated as https-with-host where they are written; a change fans out to connected peers rather than waiting for the next login. - One resolver on the client, `debug.ResolveUploadURL`, used by every path: MDM override > explicitly named URL > destination published by management > the NetBird service, but only for a peer enrolled with NetBird's cloud. Anything else fails closed with ErrNoUploadDestination and the bundle stays local, which is the behaviour change: a self-hosted deployment that names no upload service no longer uploads at all. - The engine keeps the published value (`Engine.DebugUploadURL`) so the bundle paths, which run off the engine loop, do not have to read it back out of the opt-in sync-response store. - The daemon request grows `upload`, so "upload to wherever this deployment says" is expressible; an empty `uploadURL` no longer has to mean "no upload". The privilege gate is unchanged and still applies only to a URL the local caller named — a destination published by management is the operator naming their own service. - The desktop UI stops carrying a vendor URL of its own and sends the intent. Reported privately as GHSA-hf99-43rj-h577.
42 lines
1.7 KiB
Go
42 lines
1.7 KiB
Go
package debug
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/netbirdio/netbird/client/internal/metrics"
|
|
"github.com/netbirdio/netbird/upload-server/types"
|
|
)
|
|
|
|
// ErrNoUploadDestination reports that a bundle has nowhere to go: the
|
|
// management server of this deployment publishes no upload service, and the
|
|
// peer is not enrolled with NetBird's cloud either. A debug bundle carries the
|
|
// peer's logs, routes, DNS and firewall state, so the default is to keep it
|
|
// inside the operator's control sphere rather than fall back to the service
|
|
// NetBird runs.
|
|
var ErrNoUploadDestination = errors.New("this deployment publishes no debug bundle upload service; set it on the account settings or in the management server config, or pass an explicit upload URL")
|
|
|
|
// ResolveUploadURL decides where a debug bundle may be uploaded.
|
|
//
|
|
// requested is a destination a caller named explicitly (a CLI flag, the daemon
|
|
// request); it always wins, and the callers that accept one gate it separately.
|
|
// published is what the management server of this deployment advertises, which
|
|
// the engine holds (Engine.DebugUploadURL). With neither, only a peer enrolled
|
|
// with NetBird's cloud falls back to the service NetBird runs — for anyone else
|
|
// that would carry the bundle out of the deployment the operator controls, so it
|
|
// fails closed with ErrNoUploadDestination.
|
|
func ResolveUploadURL(requested, published, managementURL string) (string, error) {
|
|
if requested != "" {
|
|
return requested, nil
|
|
}
|
|
|
|
if published != "" {
|
|
return published, nil
|
|
}
|
|
|
|
if metrics.DetermineDeploymentType(managementURL) == metrics.DeploymentTypeCloud {
|
|
return types.DefaultBundleURL, nil
|
|
}
|
|
|
|
return "", ErrNoUploadDestination
|
|
}
|