mirror of
https://github.com/n8n-io/n8n.git
synced 2026-08-28 17:22:01 +08:00
fix(core): Syslog message id RFC5424 compliance (#25321)
This commit is contained in:
@@ -42,7 +42,7 @@ export const logOptionsSchema = z.object({
|
||||
appName: z.string().max(48).optional(),
|
||||
syslogHostname: z.string().optional(),
|
||||
timestamp: z.instanceof(Date).optional(),
|
||||
msgid: z.string().optional(),
|
||||
msgid: z.string().max(32).optional(), // RFC 5424 limit
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
@@ -138,6 +138,45 @@ describe('SyslogClient - Message Formats', () => {
|
||||
client.close();
|
||||
});
|
||||
|
||||
it('should accept msgid up to 32 characters (RFC 5424 limit)', async () => {
|
||||
const hostname = 'testhostname';
|
||||
const client = new SyslogClient('127.0.0.1', {
|
||||
port: SYSLOG_UDP_PORT,
|
||||
syslogHostname: hostname,
|
||||
transport: Transport.Udp,
|
||||
});
|
||||
|
||||
const maxLengthMsgid = '550e8400e29b41d4a716446655440000'; // 32 chars (UUID without hyphens)
|
||||
await client.log('Max length msgid', {
|
||||
rfc3164: false,
|
||||
msgid: maxLengthMsgid,
|
||||
});
|
||||
|
||||
const msg = await awaitUdpMsg();
|
||||
expect(msg).toMatch(constructRfc5424Regex(134, hostname, 'Max length msgid', maxLengthMsgid));
|
||||
|
||||
client.close();
|
||||
});
|
||||
|
||||
it('should reject msgid longer than 32 characters (RFC 5424 limit)', async () => {
|
||||
const hostname = 'testhostname';
|
||||
const client = new SyslogClient('127.0.0.1', {
|
||||
port: SYSLOG_UDP_PORT,
|
||||
syslogHostname: hostname,
|
||||
transport: Transport.Udp,
|
||||
});
|
||||
|
||||
const tooLongMsgid = '550e8400-e29b-41d4-a716-446655440000'; // 36 chars (UUID with hyphens)
|
||||
await expect(
|
||||
client.log('Too long msgid', {
|
||||
rfc3164: false,
|
||||
msgid: tooLongMsgid,
|
||||
}),
|
||||
).rejects.toThrow();
|
||||
|
||||
client.close();
|
||||
});
|
||||
|
||||
it('should send back-dated RFC 5424 messages', async () => {
|
||||
const hostname = 'testhostname';
|
||||
const client = new SyslogClient('127.0.0.1', {
|
||||
|
||||
+1
-1
@@ -95,7 +95,7 @@ export class MessageEventBusDestinationSyslog
|
||||
JSON.stringify(serializedMessage),
|
||||
{
|
||||
severity: msg.eventName.toLowerCase().endsWith('error') ? Severity.Error : Severity.Debug,
|
||||
msgid: msg.id,
|
||||
msgid: msg.id.length > 32 ? msg.id.replace(/-/g, '').substring(0, 32) : msg.id,
|
||||
timestamp: msg.ts.toJSDate(),
|
||||
},
|
||||
async (error) => {
|
||||
|
||||
Reference in New Issue
Block a user