mirror of
https://github.com/netbirdio/netbird.git
synced 2026-09-08 07:51:28 +02:00
[management] Classify a host that will not resolve as unreachable
The SSRF guard resolves the host before any request is built, so a name that does not resolve fails there rather than at the transport, and that error reached the caller unclassified — an operator with a typo in the hostname was told the provider could not be checked rather than that the url could not be reached. It is the commonest way for an upstream to be wrong. The live suite is what caught it: the unit tests construct the transport errors directly and so never went through the guard. The management fixture moves to a private upstream in the same change. It wants a provider row to hang a policy off, not a working vendor, and it was pointing a dummy key at the real api.openai.com — which the credential check now correctly refuses. A private address is left unchecked whether or not the run has vendor keys, and covers that path while it is there.
This commit is contained in:
@@ -16,14 +16,20 @@ import (
|
||||
|
||||
func ptr[T any](v T) *T { return &v }
|
||||
|
||||
// newProvider creates an OpenAI-catalog provider with a dummy key (these tests
|
||||
// never call the upstream) and registers cleanup.
|
||||
// newProvider creates an OpenAI-catalog provider these tests can hang a policy
|
||||
// off, and registers cleanup. Nothing here calls the upstream.
|
||||
func newProvider(t *testing.T, ctx context.Context, name string) api.AgentNetworkProvider {
|
||||
t.Helper()
|
||||
// A provider save is credential-checked against the vendor, and every
|
||||
// caller here wants a provider row to hang a policy off rather than a
|
||||
// working upstream. A private address is left unchecked — the proxy would
|
||||
// reach it through the tunnel, management cannot reach it at all — which
|
||||
// keeps this fixture independent of whether the run has vendor keys, and
|
||||
// covers the unchecked-provider-still-saves path while it is at it.
|
||||
prov, err := srv.CreateProvider(ctx, api.AgentNetworkProviderRequest{
|
||||
Name: name,
|
||||
ProviderId: "openai_api",
|
||||
UpstreamUrl: "https://api.openai.com",
|
||||
UpstreamUrl: "https://10.255.255.1",
|
||||
ApiKey: ptr("sk-dummy-e2e-key"),
|
||||
})
|
||||
require.NoError(t, err, "create provider %q", name)
|
||||
|
||||
Reference in New Issue
Block a user