diff --git a/internal/adapter/docsui/openapi/ra.yaml b/internal/adapter/docsui/openapi/ra.yaml index b214a8d..5c6cdbc 100644 --- a/internal/adapter/docsui/openapi/ra.yaml +++ b/internal/adapter/docsui/openapi/ra.yaml @@ -277,13 +277,12 @@ paths: description: | Registers a new agent with the Agent Name Service. - The Registration Authority (RA) validates the agent's identity and - submitted information, then interacts with the CA to issue certificates - or validates provided (BYOC) server certificates. + The request MAY include a Certificate Signing Request (CSR) so that + an Identity certificate can be issued. Identity certificates are + issued by the RA. - The request MUST include an identity CSR. The request can optionally - include a server CSR (for RA-issued server cert) or a BYOC server - certificate with its chain. + The request must include a server CSR (for RA-issued server cert) + or a BYOC server certificate with its chain. operationId: registerAgent requestBody: description: Agent registration request @@ -1807,7 +1806,7 @@ components: Protocol: type: string - enum: [A2A, MCP, HTTP-API] + enum: [A2A, MCP, HTTP_API] DiscoveryProfile: type: string @@ -1890,6 +1889,14 @@ components: endpoints: type: array minItems: 1 + description: >- + One or more protocol endpoints. Each protocol may appear at + most once across the array — a second endpoint with an + already-used protocol is rejected with 422 DUPLICATE_PROTOCOL, + and an exact protocol+agentUrl repeat with 422 + DUPLICATE_ENDPOINT. (By-field uniqueness is not expressible in + OpenAPI/JSON Schema; enforced in + internal/domain/endpoint.go AgentEndpoints.Validate.) items: $ref: '#/components/schemas/AgentEndpoint' serverCsrPEM: @@ -1942,6 +1949,9 @@ components: - agentHost - endpoints - version + oneOf: + - required: [serverCsrPEM] + - required: [serverCertificatePEM] AgentRevocationRequest: type: object @@ -2417,6 +2427,10 @@ components: metaDataHash: type: string pattern: '^SHA256:[a-f0-9]{64}$' + description: >- + Optional integrity pin over the metadata descriptor. + Meaningless on its own: it MUST be accompanied by metaDataUrl. + A metaDataHash without a metaDataUrl is rejected with 422 INVALID_ENDPOINT. documentationUrl: type: string format: uri @@ -2430,10 +2444,14 @@ components: type: array items: type: string - enum: [STREAMABLE-HTTP, SSE, JSON-RPC, GRPC, REST, HTTP] + enum: [STREAMABLE_HTTP, SSE, JSON_RPC, GRPC, REST, HTTP] required: - protocol - agentUrl + anyOf: + - not: + required: [metaDataHash] + - required: [metaDataUrl] AgentFunction: type: object diff --git a/internal/adapter/docsui/openapi/tl.yaml b/internal/adapter/docsui/openapi/tl.yaml index 78cdcf7..d4ffa5b 100644 --- a/internal/adapter/docsui/openapi/tl.yaml +++ b/internal/adapter/docsui/openapi/tl.yaml @@ -997,7 +997,7 @@ components: ansName: { type: string, example: "ans://v1.0.0.agent.example.com" } eventType: type: string - enum: [AGENT_REGISTRATION, DOMAIN_VALIDATION, AGENT_ACTIVE, AGENT_REVOCATION] + enum: [AGENT_REGISTERED, AGENT_RENEWED, AGENT_DEPRECATED, AGENT_REVOKED] raId: { type: string, example: "ans-ra-local" } issuedAt: { type: string, format: date-time } timestamp: { type: string, format: date-time } diff --git a/internal/domain/agent.go b/internal/domain/agent.go index af61fcc..cd0c4be 100644 --- a/internal/domain/agent.go +++ b/internal/domain/agent.go @@ -118,6 +118,9 @@ func NewRegistration( if ownerID == "" { return nil, NewValidationError("MISSING_OWNER_ID", "ownerId is required") } + if displayName == "" { + return nil, NewValidationError("MISSING_DISPLAY_NAME", "displayName is required") + } if ansName.IsZero() { return nil, NewValidationError("MISSING_ANS_NAME", "ansName is required") } diff --git a/internal/domain/agent_test.go b/internal/domain/agent_test.go index 77df8f7..f6c4ba0 100644 --- a/internal/domain/agent_test.go +++ b/internal/domain/agent_test.go @@ -85,12 +85,13 @@ func TestNewRegistration_Validations(t *testing.T) { csr *AgentCSR code string }{ - {"missing agent id", "", "o", validName, "", "", validEndpoints, nil, &validCSR, "MISSING_AGENT_ID"}, - {"missing owner", "a", "", validName, "", "", validEndpoints, nil, &validCSR, "MISSING_OWNER_ID"}, - {"missing ans name", "a", "o", AnsName{}, "", "", validEndpoints, nil, &validCSR, "MISSING_ANS_NAME"}, + {"missing agent id", "", "o", validName, "displayName", "", validEndpoints, nil, &validCSR, "MISSING_AGENT_ID"}, + {"missing owner", "a", "", validName, "displayName", "", validEndpoints, nil, &validCSR, "MISSING_OWNER_ID"}, + {"missing ans name", "a", "o", AnsName{}, "displayName", "", validEndpoints, nil, &validCSR, "MISSING_ANS_NAME"}, + {"missing display name", "a", "o", validName, "", "", validEndpoints, nil, &validCSR, "MISSING_DISPLAY_NAME"}, {"display name too long", "a", "o", validName, strings.Repeat("x", 65), "", validEndpoints, nil, &validCSR, "DISPLAY_NAME_TOO_LONG"}, - {"description too long", "a", "o", validName, "", strings.Repeat("x", 151), validEndpoints, nil, &validCSR, "DESCRIPTION_TOO_LONG"}, - {"no endpoints", "a", "o", validName, "", "", nil, nil, &validCSR, "MISSING_ENDPOINTS"}, + {"description too long", "a", "o", validName, "displayName", strings.Repeat("x", 151), validEndpoints, nil, &validCSR, "DESCRIPTION_TOO_LONG"}, + {"no endpoints", "a", "o", validName, "displayName", "", nil, nil, &validCSR, "MISSING_ENDPOINTS"}, } for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { @@ -109,7 +110,7 @@ func TestNewRegistration_CertFQDNMismatch(t *testing.T) { ep := []AgentEndpoint{{Protocol: ProtocolMCP, AgentURL: "https://agent.example.com/mcp"}} cert := &ByocServerCertificate{SubjectCommonName: "other.example.com"} - _, err := NewRegistration("a", "o", ansName, "", "", ep, cert, &csr, time.Now()) + _, err := NewRegistration("a", "o", ansName, "displayName", "", ep, cert, &csr, time.Now()) assert.ErrorIs(t, err, ErrCertificate) } diff --git a/internal/domain/endpoint.go b/internal/domain/endpoint.go index 73da712..d077fb1 100644 --- a/internal/domain/endpoint.go +++ b/internal/domain/endpoint.go @@ -9,8 +9,10 @@ import ( ) const ( - maxFunctionTags = 20 - maxTagLength = 20 + maxFunctionTags = 5 + maxTagLength = 20 + maxFunctionIDLength = 64 + maxFunctionNameLength = 64 // maxMetadataURLLength bounds the operator-supplied metadataUrl. It // is emitted verbatim as the DNSAID `cap` SvcParam and embedded in the // signed TL attestation, so an unbounded value would bloat the @@ -29,12 +31,26 @@ type AgentFunction struct { // Validate checks that the function has valid fields. func (f AgentFunction) Validate() error { + if len(f.ID) > maxFunctionIDLength { + return NewValidationError( + "INVALID_FUNCTION", + fmt.Sprintf("function id length %d exceeds %d characters", len(f.ID), maxFunctionIDLength), + ) + } if strings.TrimSpace(f.ID) == "" { return NewValidationError("INVALID_FUNCTION", "function id cannot be blank") } + + if len(f.Name) > maxFunctionNameLength { + return NewValidationError( + "INVALID_FUNCTION", + fmt.Sprintf("function name length %d exceeds %d characters", len(f.Name), maxFunctionNameLength), + ) + } if strings.TrimSpace(f.Name) == "" { return NewValidationError("INVALID_FUNCTION", "function name cannot be blank") } + for _, tag := range f.Tags { if len(tag) > maxTagLength { return NewValidationError( diff --git a/internal/domain/endpoint_test.go b/internal/domain/endpoint_test.go index 26a31d8..e05d778 100644 --- a/internal/domain/endpoint_test.go +++ b/internal/domain/endpoint_test.go @@ -14,11 +14,21 @@ func TestAgentFunction_Validate(t *testing.T) { assert.NoError(t, f.Validate()) }) + t.Run("reject long id", func(t *testing.T) { + err := AgentFunction{ID: strings.Repeat("x", 65), Name: "n"}.Validate() + assert.ErrorIs(t, err, ErrValidation) + }) + t.Run("reject blank id", func(t *testing.T) { err := AgentFunction{ID: " ", Name: "ok"}.Validate() assert.ErrorIs(t, err, ErrValidation) }) + t.Run("reject long name", func(t *testing.T) { + err := AgentFunction{ID: "id", Name: strings.Repeat("x", 65)}.Validate() + assert.ErrorIs(t, err, ErrValidation) + }) + t.Run("reject blank name", func(t *testing.T) { err := AgentFunction{ID: "id", Name: ""}.Validate() assert.ErrorIs(t, err, ErrValidation) @@ -30,7 +40,7 @@ func TestAgentFunction_Validate(t *testing.T) { }) t.Run("reject too many tags", func(t *testing.T) { - tags := make([]string, 21) + tags := make([]string, 6) for i := range tags { tags[i] = "t" } diff --git a/internal/domain/protocol_test.go b/internal/domain/protocol_test.go index c1b6ca0..baec3b5 100644 --- a/internal/domain/protocol_test.go +++ b/internal/domain/protocol_test.go @@ -60,6 +60,7 @@ func TestParseTransport(t *testing.T) { {"STREAMABLE-HTTP", TransportStreamableHTTP, false}, {"sse", TransportSSE, false}, {"json-rpc", TransportJSONRPC, false}, + {"json_rpc", TransportJSONRPC, false}, {"JSONRPC", TransportJSONRPC, false}, {"GRPC", TransportGRPC, false}, {"REST", TransportREST, false}, diff --git a/internal/ra/handler/lifecycle.go b/internal/ra/handler/lifecycle.go index b556e00..cce0db6 100644 --- a/internal/ra/handler/lifecycle.go +++ b/internal/ra/handler/lifecycle.go @@ -3,6 +3,7 @@ package handler import ( "context" "encoding/json" + "fmt" "net/http" "strconv" @@ -64,7 +65,14 @@ func (h *LifecycleHandler) List(w http.ResponseWriter, r *http.Request) { filter.Statuses = nil break } - filter.Statuses = append(filter.Statuses, domain.RegistrationStatus(s)) + switch domain.RegistrationStatus(s) { + case domain.StatusPendingDNS, domain.StatusActive, domain.StatusDeprecated, domain.StatusRevoked: + filter.Statuses = append(filter.Statuses, domain.RegistrationStatus(s)) + default: + WriteError(w, domain.NewValidationError("INVALID_STATUS", + "status must be one of PENDING_DNS, ACTIVE, DEPRECATED, REVOKED, ALL")) + return + } } } else { filter.Statuses = []domain.RegistrationStatus{domain.StatusActive} @@ -375,11 +383,18 @@ func (h *LifecycleHandler) Revoke(w http.ResponseWriter, r *http.Request) { h.writeError(w, domain.NewValidationError("BAD_JSON", "invalid request body: "+err.Error())) return } + if req.Reason == "" { h.writeError(w, domain.NewValidationError("MISSING_REASON", "reason is required")) return } + if len(req.Comments) > maxCommentsLength { + WriteError(w, domain.NewValidationError("COMMENTS_TOO_LONG", + fmt.Sprintf("comments exceeds %d characters", maxCommentsLength))) + return + } + agentID := chi.URLParam(r, "agentId") res, err := h.svc.Revoke(r.Context(), agentID, service.RevokeInput{ Reason: domain.RevocationReason(req.Reason), diff --git a/internal/ra/handler/lifecycle_test.go b/internal/ra/handler/lifecycle_test.go index dca4b74..18a6997 100644 --- a/internal/ra/handler/lifecycle_test.go +++ b/internal/ra/handler/lifecycle_test.go @@ -120,6 +120,64 @@ func TestList_BadLimitReturns422(t *testing.T) { } } +func TestList_BadStatusReturns422(t *testing.T) { + t.Parallel() + fx := newHandlerFixture(t) + rec := fx.request(t, http.MethodGet, "/v2/ans/agents?status=BOGUS", nil, fx.asOwner("alice")) + if rec.Code != http.StatusUnprocessableEntity { + t.Fatalf("want 422, got %d body=%s", rec.Code, rec.Body) + } +} + +func TestList_UnfilterableStatusReturns422(t *testing.T) { + t.Parallel() + fx := newHandlerFixture(t) + // PENDING_VALIDATION/FAILED/EXPIRED are valid AgentLifecycleStatus + // values but are not in AgentLifecycleStatusFilter — not filterable. + rec := fx.request(t, http.MethodGet, "/v2/ans/agents?status=PENDING_VALIDATION", nil, fx.asOwner("alice")) + if rec.Code != http.StatusUnprocessableEntity { + t.Fatalf("want 422, got %d body=%s", rec.Code, rec.Body) + } +} + +func TestList_ValidFilterableStatusesReturn200(t *testing.T) { + t.Parallel() + // The four AgentLifecycleStatusFilter members (spec + // §AgentLifecycleStatusFilter, non-ALL) are each accepted by the + // status filter. A new caller owns nothing, so every valid filter + // resolves to 200 with an empty items list. + for _, status := range []string{"PENDING_DNS", "ACTIVE", "DEPRECATED", "REVOKED"} { + t.Run(status, func(t *testing.T) { + t.Parallel() + fx := newHandlerFixture(t) + rec := fx.request(t, http.MethodGet, "/v2/ans/agents?status="+status, nil, fx.asOwner("alice")) + if rec.Code != http.StatusOK { + t.Fatalf("status=%s want 200, got %d body=%s", status, rec.Code, rec.Body) + } + var resp struct { + Items []any `json:"items"` + } + if err := json.Unmarshal(rec.Body.Bytes(), &resp); err != nil { + t.Fatalf("unmarshal: %v", err) + } + if len(resp.Items) != 0 { + t.Errorf("new caller should see 0 items; got %d", len(resp.Items)) + } + }) + } +} + +func TestList_MultipleValidStatusesReturn200(t *testing.T) { + t.Parallel() + fx := newHandlerFixture(t) + // Multiple status values combine (OR); all valid → 200. + rec := fx.request(t, http.MethodGet, + "/v2/ans/agents?status=ACTIVE&status=DEPRECATED&status=REVOKED", nil, fx.asOwner("alice")) + if rec.Code != http.StatusOK { + t.Fatalf("want 200, got %d body=%s", rec.Code, rec.Body) + } +} + func TestDetail_OwnedReturns200(t *testing.T) { t.Parallel() fx := newHandlerFixture(t) @@ -844,6 +902,24 @@ func TestRevoke_BadReason_422(t *testing.T) { } } +func TestRevoke_CommentsTooLong_422(t *testing.T) { + t.Parallel() + fx := newHandlerFixture(t) + agentID, _ := fx.v1RegisterAgent(t, "alice", "agent.example.com", "1.0.0") + revBody, _ := json.Marshal(map[string]any{ + "reason": "KEY_COMPROMISE", + "comments": strings.Repeat("a", 201), + }) + rec := fx.request(t, http.MethodPost, "/v2/ans/agents/"+agentID+"/revoke", + bytes.NewReader(revBody), fx.asOwner("alice")) + if rec.Code != http.StatusUnprocessableEntity { + t.Fatalf("want 422, got %d body=%s", rec.Code, rec.Body) + } + if !strings.Contains(rec.Body.String(), "COMMENTS_TOO_LONG") { + t.Errorf("expected COMMENTS_TOO_LONG code, got %s", rec.Body) + } +} + func TestRevoke_NotOwnedReturns403(t *testing.T) { t.Parallel() fx := newHandlerFixture(t) diff --git a/internal/ra/handler/v1lifecycle.go b/internal/ra/handler/v1lifecycle.go index b0e4035..9c50068 100644 --- a/internal/ra/handler/v1lifecycle.go +++ b/internal/ra/handler/v1lifecycle.go @@ -2,6 +2,7 @@ package handler import ( "encoding/json" + "fmt" "net/http" "github.com/go-chi/chi/v5" @@ -11,6 +12,10 @@ import ( "github.com/godaddy/ans/internal/ra/service" ) +const ( + maxCommentsLength = 200 +) + // V1LifecycleHandler groups the V1 post-registration transitions: // verify-acme, verify-dns, revoke. Shares the `RegistrationService` // with V2; diverges only in DTO shape and TL-lane emission. @@ -151,6 +156,12 @@ func (h *V1LifecycleHandler) Revoke(w http.ResponseWriter, r *http.Request) { return } + if len(req.Comments) > maxCommentsLength { + WriteError(w, domain.NewValidationError("COMMENTS_TOO_LONG", + fmt.Sprintf("comments exceeds %d characters", maxCommentsLength))) + return + } + agentID := chi.URLParam(r, "agentId") res, err := h.svc.Revoke(r.Context(), agentID, service.RevokeInput{ Reason: domain.RevocationReason(req.Reason), diff --git a/internal/ra/handler/v1lifecycle_test.go b/internal/ra/handler/v1lifecycle_test.go index 9c0678c..7386c98 100644 --- a/internal/ra/handler/v1lifecycle_test.go +++ b/internal/ra/handler/v1lifecycle_test.go @@ -380,6 +380,24 @@ func TestV1Revoke_MissingReason_422(t *testing.T) { } } +func TestV1Revoke_CommentsTooLong_422(t *testing.T) { + t.Parallel() + fx := newHandlerFixture(t) + agentID, _ := fx.v1RegisterAgent(t, "alice", "agent.example.com", "1.0.0") + revBody, _ := json.Marshal(map[string]any{ + "reason": "KEY_COMPROMISE", + "comments": strings.Repeat("a", 201), + }) + rec := fx.request(t, http.MethodPost, "/v1/agents/"+agentID+"/revoke", + bytes.NewReader(revBody), fx.asOwner("alice")) + if rec.Code != http.StatusUnprocessableEntity { + t.Fatalf("want 422, got %d body=%s", rec.Code, rec.Body) + } + if !strings.Contains(rec.Body.String(), "COMMENTS_TOO_LONG") { + t.Errorf("expected COMMENTS_TOO_LONG code, got %s", rec.Body) + } +} + // TestV1Revoke_NotOwned_403 confirms WriteOwnership 403 on // not-owned revoke attempts (as opposed to read routes which 404). func TestV1Revoke_NotOwned_403(t *testing.T) { diff --git a/internal/tl/event/event.go b/internal/tl/event/event.go index 3e6473b..bf93a8a 100644 --- a/internal/tl/event/event.go +++ b/internal/tl/event/event.go @@ -38,6 +38,7 @@ import ( "time" anscrypto "github.com/godaddy/ans/internal/crypto" + "github.com/godaddy/ans/internal/domain" ) // SchemaVersion pins the envelope version. "V2" because our V2 RA @@ -279,6 +280,9 @@ func (ev *Event) Validate() error { if _, err := time.Parse(time.RFC3339, ev.Timestamp); err != nil { return fmt.Errorf("event: timestamp must be RFC3339: %w", err) } + if ev.RevocationReasonCode != "" && !domain.RevocationReason(ev.RevocationReasonCode).IsValid() { + return fmt.Errorf("event: invalid revocationReasonCode %q", ev.RevocationReasonCode) + } return nil } diff --git a/internal/tl/event/event_test.go b/internal/tl/event/event_test.go index 8459906..052d797 100644 --- a/internal/tl/event/event_test.go +++ b/internal/tl/event/event_test.go @@ -121,6 +121,15 @@ func TestEnvelope_Validate_Success(t *testing.T) { } } +func TestEnvelope_Validate_RevocationReasonCode_Valid(t *testing.T) { + t.Parallel() + env := fixedEnvelope() + env.Payload.Producer.Event.RevocationReasonCode = "AA_COMPROMISE" + if err := env.Validate(); err != nil { + t.Fatalf("Validate: %v", err) + } +} + func TestEnvelope_Validate_MissingFields(t *testing.T) { t.Parallel() cases := map[string]func(e *event.Envelope){ @@ -137,6 +146,9 @@ func TestEnvelope_Validate_MissingFields(t *testing.T) { "no ansName": func(e *event.Envelope) { e.Payload.Producer.Event.AnsName = "" }, "no timestamp": func(e *event.Envelope) { e.Payload.Producer.Event.Timestamp = "" }, "non-RFC3339 time": func(e *event.Envelope) { e.Payload.Producer.Event.Timestamp = "yesterday" }, + "bad revocationReasonCode": func(e *event.Envelope) { + e.Payload.Producer.Event.RevocationReasonCode = "BOGUS" + }, } for name, mutate := range cases { t.Run(name, func(t *testing.T) { diff --git a/internal/tl/event/v1/event.go b/internal/tl/event/v1/event.go index a449bc2..a7a2068 100644 --- a/internal/tl/event/v1/event.go +++ b/internal/tl/event/v1/event.go @@ -31,6 +31,8 @@ import ( "errors" "fmt" "time" + + "github.com/godaddy/ans/internal/domain" ) // SchemaVersion pins the envelope label for V1 events. Producer + @@ -186,6 +188,9 @@ func (e *Event) Validate() error { if _, err := time.Parse(time.RFC3339, e.Timestamp); err != nil { return fmt.Errorf("event/v1: event.timestamp not RFC3339: %w", err) } + if e.RevocationReasonCode != "" && !domain.RevocationReason(e.RevocationReasonCode).IsValid() { + return fmt.Errorf("event/v1: invalid revocationReasonCode %q", e.RevocationReasonCode) + } return nil } diff --git a/internal/tl/event/v1/event_test.go b/internal/tl/event/v1/event_test.go index 14d7e80..5374c00 100644 --- a/internal/tl/event/v1/event_test.go +++ b/internal/tl/event/v1/event_test.go @@ -140,6 +140,15 @@ func TestEnvelope_Validate_Success(t *testing.T) { } } +func TestEnvelope_Validate_RevocationReasonCode_Valid(t *testing.T) { + t.Parallel() + env := fixedEnvelope() + env.Payload.Producer.Event.RevocationReasonCode = "SUPERSEDED" + if err := env.Validate(); err != nil { + t.Fatalf("Validate: %v", err) + } +} + func TestEnvelope_Validate_Failures(t *testing.T) { t.Parallel() cases := map[string]func(e *v1.Envelope){ @@ -155,6 +164,9 @@ func TestEnvelope_Validate_Failures(t *testing.T) { "no ansName": func(e *v1.Envelope) { e.Payload.Producer.Event.AnsName = "" }, "no timestamp": func(e *v1.Envelope) { e.Payload.Producer.Event.Timestamp = "" }, "non-RFC3339 time": func(e *v1.Envelope) { e.Payload.Producer.Event.Timestamp = "yesterday" }, + "bad revocationReasonCode": func(e *v1.Envelope) { + e.Payload.Producer.Event.RevocationReasonCode = "BOGUS" + }, } for name, mutate := range cases { t.Run(name, func(t *testing.T) { diff --git a/internal/tl/service/schemas/V0.json b/internal/tl/service/schemas/V0.json index f80878e..c906987 100644 --- a/internal/tl/service/schemas/V0.json +++ b/internal/tl/service/schemas/V0.json @@ -256,7 +256,7 @@ "type": "string" }, "revocationReasonCode": { - "description": "RFC 5280 revocation reason code", + "description": "Revocation reason code", "enum": [ "AA_COMPROMISE", "AFFILIATION_CHANGED", diff --git a/internal/tl/service/schemas/V1.json b/internal/tl/service/schemas/V1.json index 736228b..1f053d8 100644 --- a/internal/tl/service/schemas/V1.json +++ b/internal/tl/service/schemas/V1.json @@ -189,7 +189,7 @@ "type": "string" }, "revocationReasonCode": { - "description": "RFC 5280 revocation reason code", + "description": "Revocation reason code", "enum": [ "AA_COMPROMISE", "AFFILIATION_CHANGED", diff --git a/internal/tl/service/schemas/V2.json b/internal/tl/service/schemas/V2.json index c2d5502..0d48783 100644 --- a/internal/tl/service/schemas/V2.json +++ b/internal/tl/service/schemas/V2.json @@ -124,6 +124,10 @@ "TXT" ], "type": "string" + }, + "dnssecVerified": { + "description": "Indicates that the RA's verifier observed the DNSSEC authenticated-data bit on the response that produced the attestation", + "type": "boolean" } }, "type": "object" @@ -180,19 +184,15 @@ "type": "string" }, "revocationReasonCode": { - "description": "RFC 5280 revocation reason code", + "description": "Revocation reason code", "enum": [ "AA_COMPROMISE", "AFFILIATION_CHANGED", - "CA_COMPROMISE", "CERTIFICATE_HOLD", "CESSATION_OF_OPERATION", - "EXPIRED_CERT", "KEY_COMPROMISE", "PRIVILEGE_WITHDRAWN", - "REMOVE_FROM_CRL", - "SUPERSEDED", - "UNSPECIFIED" + "SUPERSEDED" ], "type": "string" }, diff --git a/spec/api-spec-tl-v2.yaml b/spec/api-spec-tl-v2.yaml index 78cdcf7..d4ffa5b 100644 --- a/spec/api-spec-tl-v2.yaml +++ b/spec/api-spec-tl-v2.yaml @@ -997,7 +997,7 @@ components: ansName: { type: string, example: "ans://v1.0.0.agent.example.com" } eventType: type: string - enum: [AGENT_REGISTRATION, DOMAIN_VALIDATION, AGENT_ACTIVE, AGENT_REVOCATION] + enum: [AGENT_REGISTERED, AGENT_RENEWED, AGENT_DEPRECATED, AGENT_REVOKED] raId: { type: string, example: "ans-ra-local" } issuedAt: { type: string, format: date-time } timestamp: { type: string, format: date-time } diff --git a/spec/api-spec-v2.yaml b/spec/api-spec-v2.yaml index b214a8d..5c6cdbc 100644 --- a/spec/api-spec-v2.yaml +++ b/spec/api-spec-v2.yaml @@ -277,13 +277,12 @@ paths: description: | Registers a new agent with the Agent Name Service. - The Registration Authority (RA) validates the agent's identity and - submitted information, then interacts with the CA to issue certificates - or validates provided (BYOC) server certificates. + The request MAY include a Certificate Signing Request (CSR) so that + an Identity certificate can be issued. Identity certificates are + issued by the RA. - The request MUST include an identity CSR. The request can optionally - include a server CSR (for RA-issued server cert) or a BYOC server - certificate with its chain. + The request must include a server CSR (for RA-issued server cert) + or a BYOC server certificate with its chain. operationId: registerAgent requestBody: description: Agent registration request @@ -1807,7 +1806,7 @@ components: Protocol: type: string - enum: [A2A, MCP, HTTP-API] + enum: [A2A, MCP, HTTP_API] DiscoveryProfile: type: string @@ -1890,6 +1889,14 @@ components: endpoints: type: array minItems: 1 + description: >- + One or more protocol endpoints. Each protocol may appear at + most once across the array — a second endpoint with an + already-used protocol is rejected with 422 DUPLICATE_PROTOCOL, + and an exact protocol+agentUrl repeat with 422 + DUPLICATE_ENDPOINT. (By-field uniqueness is not expressible in + OpenAPI/JSON Schema; enforced in + internal/domain/endpoint.go AgentEndpoints.Validate.) items: $ref: '#/components/schemas/AgentEndpoint' serverCsrPEM: @@ -1942,6 +1949,9 @@ components: - agentHost - endpoints - version + oneOf: + - required: [serverCsrPEM] + - required: [serverCertificatePEM] AgentRevocationRequest: type: object @@ -2417,6 +2427,10 @@ components: metaDataHash: type: string pattern: '^SHA256:[a-f0-9]{64}$' + description: >- + Optional integrity pin over the metadata descriptor. + Meaningless on its own: it MUST be accompanied by metaDataUrl. + A metaDataHash without a metaDataUrl is rejected with 422 INVALID_ENDPOINT. documentationUrl: type: string format: uri @@ -2430,10 +2444,14 @@ components: type: array items: type: string - enum: [STREAMABLE-HTTP, SSE, JSON-RPC, GRPC, REST, HTTP] + enum: [STREAMABLE_HTTP, SSE, JSON_RPC, GRPC, REST, HTTP] required: - protocol - agentUrl + anyOf: + - not: + required: [metaDataHash] + - required: [metaDataUrl] AgentFunction: type: object