Agent Mesh
Go a2aa2a-protocolagent-meshagentic-aiinferencemcpmeshmesh-networknetwork-securitynetworking-aip2p-network
node: gate a2a egress case-insensitively to match ingress
Tomas Tormo830d0bad74ea
diff --git a/internal/node/a2a_service.go b/internal/node/a2a_service.goindex f5429b5a..3045739d 100644--- a/internal/node/a2a_service.go+++ b/internal/node/a2a_service.go@@ -58,7 +58,7 @@ type a2aCardBaseURL struct{}// On refusal it writes the HTTP error itself and returns ok=false.func a2aEgressHook(node *SamNode, w http.ResponseWriter, r *http.Request) (*http.Request, bool) {parts := strings.SplitN(r.URL.Path, "/", 6)- if len(parts) < 5 || parts[3] != api.ServiceTypeStringA2A {+ if len(parts) < 5 || !strings.EqualFold(parts[3], api.ServiceTypeStringA2A) {return r, true}if labelsHeader := r.Header.Get(api.HeaderSamRequiredLabels); labelsHeader != "" {diff --git a/internal/node/a2a_service_test.go b/internal/node/a2a_service_test.goindex 5a580117..e5917cad 100644--- a/internal/node/a2a_service_test.go+++ b/internal/node/a2a_service_test.go@@ -225,3 +225,19 @@ func TestRewriteA2AAgentCardSkipsContentEncoded(t *testing.T) {t.Fatalf("content-encoded response was modified: %s", body)}}++func TestA2AEgressHookUppercaseTypeIsGated(t *testing.T) {+ rec := httptest.NewRecorder()+ req := httptest.NewRequest("POST", "/sam/not-a-peer/A2A/agent/", nil)+ req.Header.Set(api.HeaderSamRequiredLabels, "region=eu")+ _, ok := a2aEgressHook(nil, rec, req)+ if ok {+ t.Fatal("uppercase A2A path must not bypass the labels gate")+ }+ if rec.Code != http.StatusBadRequest {+ t.Fatalf("status = %d, want 400 (invalid peer reached after gate engaged)", rec.Code)+ }+ if req.Header.Get(api.HeaderSamRequiredLabels) != "" {+ t.Fatal("labels header must be stripped on a2a paths regardless of case")+ }+}