From 55b9f6bb01a9a3f870c74e03ca9518c760a1f843 Mon Sep 17 00:00:00 2001 From: Brandon Corbett Date: Wed, 11 Nov 2026 11:26:58 -0500 Subject: [PATCH] feat(audit): ship syslog audit sinks with the Fells Code SD-ID Syslog records carry seq and hash in the structured data element seamless@67592, under the Fells Code IANA Private Enterprise Number. Creating or updating a syslog sink is no longer refused. Closes #586 --- .changeset/syslog-audit-sinks.md | 5 ++++ docs/adr/0005-extensibility-callouts.md | 4 +-- docs/configuration.md | 6 ++-- openapi.json | 2 +- src/generated/api.ts | 2 +- src/lib/auditSinkTransport.ts | 17 ++--------- src/routes/auditSinks.routes.ts | 2 +- src/services/auditSinkService.ts | 5 ---- tests/integration/admin/auditSinks.spec.ts | 31 ++------------------ tests/postgres/auditSinks.spec.ts | 8 +---- tests/unit/lib/auditSinkTransport.spec.ts | 2 +- tests/unit/services/auditSinkService.spec.ts | 16 ++-------- 12 files changed, 22 insertions(+), 78 deletions(-) create mode 100644 .changeset/syslog-audit-sinks.md diff --git a/.changeset/syslog-audit-sinks.md b/.changeset/syslog-audit-sinks.md new file mode 100644 index 00000000..577723fc --- /dev/null +++ b/.changeset/syslog-audit-sinks.md @@ -0,0 +1,5 @@ +--- +'seamless-auth-api': patch +--- + +Syslog audit sinks are available (#586). Creating or updating a syslog sink no longer returns a 400. Records go over RFC 5424 on TLS with octet counting, and carry `seq` and `hash` in the structured data element `seamless@67592`, under the Fells Code IANA Private Enterprise Number 67592. Key collector parsing rules on that SD-ID. diff --git a/docs/adr/0005-extensibility-callouts.md b/docs/adr/0005-extensibility-callouts.md index cc9d64f0..263403a1 100644 --- a/docs/adr/0005-extensibility-callouts.md +++ b/docs/adr/0005-extensibility-callouts.md @@ -100,8 +100,8 @@ Among roles of one kind, sets apply in role-name order, so the last name alphabe - Credentials are never stored. A sink names env vars ending `_AUDIT_SINK_SECRET`, the same pattern OAuth providers use. A send whose named env var is unset or unusable, or whose settings production does not allow (plain TCP syslog), fails as `misconfigured` before any connection. - Retention never deletes past the oldest sink cursor, and a disabled sink holds it too (decided 2026-11-07). An audit event deleted before a SIEM receives it cannot be recovered, so a disabled sink holds retention until it is deleted. Retention logs a warning naming the holding sink and saying to delete it to release retention. - An OTLP 2xx counts as delivered, including one whose `partialSuccess` reports rejected records (decided 2026-11-07). A collector rejects such records for their content, so retrying them would stall the sink forever. -- Syslog records carry `seq` and `hash` in the SD-ID `seamless@32473`. 32473 is the RFC 5612 documentation number, a placeholder until Fells Code has an IANA Private Enterprise Number (#586). A release must not ship with it. -- 0.23.0 ships with OTLP only (decided 2026-11-08). Collectors key their parsing rules on the SD-ID, so shipping the placeholder and changing it later would break those rules. The syslog transport is in the code, but creating or updating a syslog sink is refused with a 400 until 0.23.1 sets the real SD-ID and lifts the refusal (#586). +- Syslog records carry `seq` and `hash` in the SD-ID `seamless@67592`, under the Fells Code IANA Private Enterprise Number 67592 (#586). Collectors key their parsing rules on the SD-ID, so it does not change. +- 0.23.0 shipped with OTLP only (decided 2026-11-08), so no release ever used a placeholder SD-ID. Syslog sinks arrive in 0.23.1 with the real one (#586). ### E8. Every callout follows the same reachability rules diff --git a/docs/configuration.md b/docs/configuration.md index fe795b78..92ce208e 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -127,9 +127,9 @@ export does. A sink retries until its collector takes the events, backing off to reports how far behind the chain head it is. Destinations follow the same rules as webhooks, including `CALLOUT_PRIVATE_HOSTS`, and plain TCP syslog is refused in production. -Syslog sinks arrive in 0.23.1. Until then the API refuses to create or update one with a 400, -because the syslog records' SD-ID needs the Fells Code IANA enterprise number first (#586). Use an -OTLP sink in the meantime. +Syslog records carry `seq` and `hash` in the structured data element `seamless@67592` (67592 is +the Fells Code IANA Private Enterprise Number). Key collector parsing rules on that SD-ID. Syslog +sinks need API 0.23.1 or later; 0.23.0 refuses them with a 400. | Variable | Required | Default | Notes | | -------------------------- | -------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | diff --git a/openapi.json b/openapi.json index 877933b9..6e277e0c 100644 --- a/openapi.json +++ b/openapi.json @@ -10391,7 +10391,7 @@ }, "post": { "summary": "Create an audit sink", - "description": "Starts after the newest event unless `startAfterSeq` replays from an earlier one. Credentials are named as `_AUDIT_SINK_SECRET` env vars, never stored. A syslog sink is refused with a 400 until 0.23.1.", + "description": "Starts after the newest event unless `startAfterSeq` replays from an earlier one. Credentials are named as `_AUDIT_SINK_SECRET` env vars, never stored.", "tags": ["Admin", "Audit sinks"], "security": [{ "bearerAuth": [] }], "requestBody": { diff --git a/src/generated/api.ts b/src/generated/api.ts index 88abaffc..715cdbb7 100644 --- a/src/generated/api.ts +++ b/src/generated/api.ts @@ -9838,7 +9838,7 @@ export interface paths { put?: never; /** * Create an audit sink - * @description Starts after the newest event unless `startAfterSeq` replays from an earlier one. Credentials are named as `_AUDIT_SINK_SECRET` env vars, never stored. A syslog sink is refused with a 400 until 0.23.1. + * @description Starts after the newest event unless `startAfterSeq` replays from an earlier one. Credentials are named as `_AUDIT_SINK_SECRET` env vars, never stored. */ post: { parameters: { diff --git a/src/lib/auditSinkTransport.ts b/src/lib/auditSinkTransport.ts index 7a4bf91b..66c10f98 100644 --- a/src/lib/auditSinkTransport.ts +++ b/src/lib/auditSinkTransport.ts @@ -33,21 +33,10 @@ const MAX_RESPONSE_BYTES = 64 * 1024; /** * The structured data element carrying `seq` and `hash` in each syslog record. RFC 5424 needs - * a private SD-ID to be `name@`. 32473 is the number RFC 5612 reserves - * for documentation, a placeholder until Fells Code has its own. + * a private SD-ID to be `name@`, and 67592 is the Fells Code number. + * Collectors key their parsing rules on it, so changing it is a breaking change. */ -// TODO(#586): replace 32473 with the Fells Code IANA enterprise number before release. -export const SYSLOG_SD_ID = 'seamless@32473'; - -/** - * Collectors key their parsing rules on the SD-ID, so changing it once adopters have written - * those rules is a breaking change. Syslog sinks stay refused until the real number is in. - */ -// TODO(#586): set to true in 0.23.1 together with the real SD-ID. -export const SYSLOG_SINKS_AVAILABLE = false; - -export const SYSLOG_UNAVAILABLE = - 'Syslog audit sinks are not available in this release; they arrive in Seamless Auth 0.23.1. Use an OTLP sink until then.'; +export const SYSLOG_SD_ID = 'seamless@67592'; export const AUDIT_SINK_SCOPE = 'seamless-auth.audit'; diff --git a/src/routes/auditSinks.routes.ts b/src/routes/auditSinks.routes.ts index c9598607..f8dea86e 100644 --- a/src/routes/auditSinks.routes.ts +++ b/src/routes/auditSinks.routes.ts @@ -53,7 +53,7 @@ router.post( ...write, summary: 'Create an audit sink', description: - 'Starts after the newest event unless `startAfterSeq` replays from an earlier one. Credentials are named as `_AUDIT_SINK_SECRET` env vars, never stored. A syslog sink is refused with a 400 until 0.23.1.', + 'Starts after the newest event unless `startAfterSeq` replays from an earlier one. Credentials are named as `_AUDIT_SINK_SECRET` env vars, never stored.', schemas: { body: CreateAuditSinkRequestSchema, response: { 201: AuditSinkResponseSchema, 400: ErrorSchema, 403: StepUpRequiredErrorSchema }, diff --git a/src/services/auditSinkService.ts b/src/services/auditSinkService.ts index ad84ca98..88f88636 100644 --- a/src/services/auditSinkService.ts +++ b/src/services/auditSinkService.ts @@ -16,8 +16,6 @@ import { eventRecord, sendToSink, sinkDestinationProblem, - SYSLOG_SINKS_AVAILABLE, - SYSLOG_UNAVAILABLE, testRecord, } from '../lib/auditSinkTransport.js'; import { AuditSink } from '../models/auditSinks.js'; @@ -86,9 +84,6 @@ export function serializeSink(sink: AuditSink, head: number) { } function assertSettings(settings: AuditSinkSettings) { - if (settings.kind === 'syslog' && !SYSLOG_SINKS_AVAILABLE) { - throw new AuditSinkError(400, SYSLOG_UNAVAILABLE); - } const problem = sinkDestinationProblem(settings); if (problem) throw new AuditSinkError(400, problem); } diff --git a/tests/integration/admin/auditSinks.spec.ts b/tests/integration/admin/auditSinks.spec.ts index aa0b882f..863285f5 100644 --- a/tests/integration/admin/auditSinks.spec.ts +++ b/tests/integration/admin/auditSinks.spec.ts @@ -2,7 +2,7 @@ import { Application } from 'express'; import request from 'supertest'; import { beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'; -const { query, gate } = vi.hoisted(() => ({ query: vi.fn(), gate: { syslog: false } })); +const { query } = vi.hoisted(() => ({ query: vi.fn() })); vi.mock('../../../src/models/index.js', async (importOriginal) => { const actual = await importOriginal(); @@ -14,14 +14,11 @@ vi.mock('../../../src/lib/auditSinkTransport.js', async (importOriginal) => { return { ...actual, sendToSink: vi.fn(), - get SYSLOG_SINKS_AVAILABLE() { - return gate.syslog; - }, }; }); import { createApp } from '../../../src/app'; -import { sendToSink, SYSLOG_UNAVAILABLE } from '../../../src/lib/auditSinkTransport.js'; +import { sendToSink } from '../../../src/lib/auditSinkTransport.js'; import { AuditSink } from '../../../src/models/auditSinks.js'; import { Session } from '../../../src/models/sessions.js'; import { AuthEventService } from '../../../src/services/authEventService.js'; @@ -68,7 +65,6 @@ beforeAll(async () => { beforeEach(() => { vi.clearAllMocks(); - gate.syslog = false; (Session.findOne as any).mockResolvedValue(buildFreshStepUpSession()); query.mockResolvedValue([{ head: '42', oldest: '1' }]); }); @@ -118,29 +114,7 @@ describe('audit sinks', () => { expect(AuditSink.create).not.toHaveBeenCalled(); }); - it('refuses a syslog sink until its SD-ID is registered', async () => { - const created = await request(app) - .post('/admin/audit-sinks') - .send({ name: 'SIEM', settings: { kind: 'syslog', host: 'collector.example.com' } }); - - expect(created.status).toBe(400); - expect(created.body.error).toBe(SYSLOG_UNAVAILABLE); - expect(AuditSink.create).not.toHaveBeenCalled(); - - const record = buildSink(); - vi.mocked(AuditSink.findByPk).mockResolvedValue(record); - - const updated = await request(app) - .patch(`/admin/audit-sinks/${sinkId}`) - .send({ settings: { kind: 'syslog', host: 'collector.example.com' } }); - - expect(updated.status).toBe(400); - expect(updated.body.error).toBe(SYSLOG_UNAVAILABLE); - expect(record.update).not.toHaveBeenCalled(); - }); - it('refuses plain TCP syslog in production', async () => { - gate.syslog = true; vi.stubEnv('NODE_ENV', 'production'); const res = await request(app) @@ -167,7 +141,6 @@ describe('audit sinks', () => { }); it('reads, updates and deletes a sink, auditing each write', async () => { - gate.syslog = true; const record = buildSink(); vi.mocked(AuditSink.findByPk).mockResolvedValue(record); diff --git a/tests/postgres/auditSinks.spec.ts b/tests/postgres/auditSinks.spec.ts index 6017d0f6..a94f5c91 100644 --- a/tests/postgres/auditSinks.spec.ts +++ b/tests/postgres/auditSinks.spec.ts @@ -9,13 +9,7 @@ import { import { tmpdir } from 'node:os'; import { join } from 'node:path'; -import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'; - -// The syslog transport stays tested end to end while the API refuses new syslog sinks (#586). -vi.mock('../../src/lib/auditSinkTransport.js', async (importOriginal) => ({ - ...(await importOriginal()), - SYSLOG_SINKS_AVAILABLE: true, -})); +import { afterAll, beforeAll, beforeEach, describe, expect, it } from 'vitest'; import { AuditSink } from '../../src/models/auditSinks.js'; import { getSequelize, initializeModels } from '../../src/models/index.js'; diff --git a/tests/unit/lib/auditSinkTransport.spec.ts b/tests/unit/lib/auditSinkTransport.spec.ts index 5762ac06..a3cb8c53 100644 --- a/tests/unit/lib/auditSinkTransport.spec.ts +++ b/tests/unit/lib/auditSinkTransport.spec.ts @@ -387,7 +387,7 @@ describe('syslog', () => { it('marks the test record with its own MSGID and no chain fields', () => { const message = syslogMessage(testRecord('sink-1'), syslog(1), 'host'); - expect(message).toMatch(/^<86>1 \S+ host seamless-auth - test \[seamless@32473 test="true"\] /); + expect(message).toMatch(/^<86>1 \S+ host seamless-auth - test \[seamless@67592 test="true"\] /); expect(message).not.toContain('seq='); }); diff --git a/tests/unit/services/auditSinkService.spec.ts b/tests/unit/services/auditSinkService.spec.ts index a4ad284e..818e6868 100644 --- a/tests/unit/services/auditSinkService.spec.ts +++ b/tests/unit/services/auditSinkService.spec.ts @@ -3,20 +3,10 @@ import type { AddressInfo } from 'node:net'; import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; -const { query, transaction, gate } = vi.hoisted(() => { +const { query, transaction } = vi.hoisted(() => { const query = vi.fn(); const transaction = vi.fn(async (fn: (t: unknown) => unknown) => fn({ id: 'tx' })); - return { query, transaction, gate: { syslog: false } }; -}); - -vi.mock('../../../src/lib/auditSinkTransport.js', async (importOriginal) => { - const actual = await importOriginal(); - return { - ...actual, - get SYSLOG_SINKS_AVAILABLE() { - return gate.syslog; - }, - }; + return { query, transaction }; }); vi.mock('../../../src/models/index.js', () => ({ @@ -55,7 +45,6 @@ let bodies: string[]; let status: number; beforeEach(async () => { - gate.syslog = false; bodies = []; status = 200; transaction.mockImplementation(async (fn: (t: unknown) => unknown) => fn({ id: 'tx' })); @@ -222,7 +211,6 @@ describe('sinks', () => { }); it('updates fields and clears the backoff, keeping the cursor', async () => { - gate.syslog = true; const record = sink({ failureCount: 4, nextAttemptAt: new Date(Date.now() + 60_000) }); vi.mocked(AuditSink.findByPk).mockResolvedValue(record);