mirror of
https://github.com/n8n-io/n8n.git
synced 2026-06-01 17:27:14 +02:00
fix(LDAP Node): Bump ldapts to 8.1.7 to fix silent rename on long DN paths (#30712)
Co-authored-by: Alexander Gekov <40495748+alexander-gekov@users.noreply.github.com> Co-authored-by: Alexander Gekov <alexander.gekov@n8n.io> Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
70ab5e5828
commit
7db3eb8b2e
|
|
@ -182,7 +182,7 @@
|
|||
"jsonschema": "1.4.1",
|
||||
"jsonwebtoken": "catalog:",
|
||||
"langsmith": "catalog:",
|
||||
"ldapts": "4.2.6",
|
||||
"ldapts": "catalog:",
|
||||
"lodash": "catalog:",
|
||||
"luxon": "catalog:",
|
||||
"n8n-core": "workspace:*",
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import {
|
|||
import { Container } from '@n8n/di';
|
||||
import { validate } from 'jsonschema';
|
||||
import type { Entry as LdapUser } from 'ldapts';
|
||||
import { Filter } from 'ldapts/filters/Filter';
|
||||
import { randomString } from 'n8n-workflow';
|
||||
|
||||
import { BINARY_AD_ATTRIBUTES, LDAP_CONFIG_SCHEMA } from './constants';
|
||||
|
|
@ -53,8 +52,15 @@ export const createFilter = (filter: string, userFilter: string) => {
|
|||
};
|
||||
|
||||
export const escapeFilter = (filter: string): string => {
|
||||
//@ts-ignore
|
||||
return new Filter().escape(filter); /* eslint-disable-line */
|
||||
return (
|
||||
filter
|
||||
.replace(/\\/g, '\\5c')
|
||||
.replace(/\*/g, '\\2a')
|
||||
.replace(/\(/g, '\\28')
|
||||
.replace(/\)/g, '\\29')
|
||||
// eslint-disable-next-line no-control-regex
|
||||
.replace(/\x00/g, '\\00')
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -252,4 +252,62 @@ describe('Ldap', () => {
|
|||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('rename', () => {
|
||||
let mockBind: jest.Mock;
|
||||
let mockModifyDN: jest.Mock;
|
||||
let mockUnbind: jest.Mock;
|
||||
|
||||
beforeEach(() => {
|
||||
mockBind = jest.fn().mockResolvedValue(undefined);
|
||||
mockModifyDN = jest.fn().mockResolvedValue(undefined);
|
||||
mockUnbind = jest.fn().mockResolvedValue(undefined);
|
||||
|
||||
const mockClient = {
|
||||
bind: mockBind,
|
||||
modifyDN: mockModifyDN,
|
||||
unbind: mockUnbind,
|
||||
};
|
||||
|
||||
jest.spyOn(Helpers, 'createLdapClient').mockResolvedValue(mockClient as unknown as Client);
|
||||
|
||||
executeFunctions.getCredentials.mockResolvedValue({
|
||||
hostname: 'ldap.example.com',
|
||||
port: 389,
|
||||
bindDN: 'cn=admin,dc=example,dc=com',
|
||||
bindPassword: 'password',
|
||||
connectionSecurity: 'none',
|
||||
});
|
||||
});
|
||||
|
||||
it('should rename an entry when targetDn is longer than 127 bytes', async () => {
|
||||
const dn = 'cn=source-user,ou=users,dc=example,dc=com';
|
||||
const targetDn = `cn=${'renamed-user-'.repeat(8)},ou=users,dc=example,dc=com`;
|
||||
|
||||
expect(Buffer.byteLength(targetDn, 'utf8')).toBeGreaterThan(127);
|
||||
|
||||
executeFunctions.getNodeParameter.mockImplementation((parameterName, _idx, defaultValue) => {
|
||||
const params: Record<string, unknown> = {
|
||||
nodeDebug: false,
|
||||
operation: 'rename',
|
||||
dn,
|
||||
targetDn,
|
||||
};
|
||||
|
||||
return parameterName in params ? params[parameterName] : defaultValue;
|
||||
});
|
||||
|
||||
const result = await new Ldap().execute.call(executeFunctions);
|
||||
|
||||
expect(mockModifyDN).toHaveBeenCalledWith(dn, targetDn);
|
||||
expect(result).toEqual([
|
||||
[
|
||||
{
|
||||
json: { dn: targetDn, result: 'success' },
|
||||
pairedItem: { item: 0 },
|
||||
},
|
||||
],
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -938,7 +938,7 @@
|
|||
"jsdom": "23.0.1",
|
||||
"jsonwebtoken": "catalog:",
|
||||
"kafkajs": "catalog:",
|
||||
"ldapts": "4.2.6",
|
||||
"ldapts": "catalog:",
|
||||
"lodash": "catalog:",
|
||||
"lossless-json": "1.0.5",
|
||||
"luxon": "catalog:",
|
||||
|
|
|
|||
|
|
@ -228,6 +228,9 @@ catalogs:
|
|||
langchain:
|
||||
specifier: 1.2.30
|
||||
version: 1.2.30
|
||||
ldapts:
|
||||
specifier: 8.1.7
|
||||
version: 8.1.7
|
||||
luxon:
|
||||
specifier: 3.7.2
|
||||
version: 3.7.2
|
||||
|
|
@ -2960,8 +2963,8 @@ importers:
|
|||
specifier: 0.6.0
|
||||
version: 0.6.0(@opentelemetry/api@1.9.0)(@opentelemetry/exporter-trace-otlp-proto@0.217.0(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@2.7.1(@opentelemetry/api@1.9.0))(openai@6.19.0(ws@8.20.1(bufferutil@4.0.9)(utf-8-validate@5.0.10))(zod@3.25.67))(ws@8.20.1(bufferutil@4.0.9)(utf-8-validate@5.0.10))
|
||||
ldapts:
|
||||
specifier: 4.2.6
|
||||
version: 4.2.6
|
||||
specifier: 'catalog:'
|
||||
version: 8.1.7
|
||||
lodash:
|
||||
specifier: 4.18.1
|
||||
version: 4.18.1
|
||||
|
|
@ -4489,8 +4492,8 @@ importers:
|
|||
specifier: 'catalog:'
|
||||
version: 2.2.4
|
||||
ldapts:
|
||||
specifier: 4.2.6
|
||||
version: 4.2.6
|
||||
specifier: 'catalog:'
|
||||
version: 8.1.7
|
||||
lodash:
|
||||
specifier: 4.18.1
|
||||
version: 4.18.1
|
||||
|
|
@ -13139,15 +13142,6 @@ packages:
|
|||
supports-color:
|
||||
optional: true
|
||||
|
||||
debug@4.3.5:
|
||||
resolution: {integrity: sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==}
|
||||
engines: {node: '>=6.0'}
|
||||
peerDependencies:
|
||||
supports-color: '*'
|
||||
peerDependenciesMeta:
|
||||
supports-color:
|
||||
optional: true
|
||||
|
||||
debug@4.4.3:
|
||||
resolution: {integrity: sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==}
|
||||
engines: {node: '>=6.0'}
|
||||
|
|
@ -15836,9 +15830,9 @@ packages:
|
|||
resolution: {integrity: sha512-b94GiNHQNy6JNTrt5w6zNyffMrNkXZb3KTkCZJb2V1xaEGCk093vkZ2jk3tpaeP33/OiXC+WvK9AxUebnf5nbw==}
|
||||
engines: {node: '>= 0.6.3'}
|
||||
|
||||
ldapts@4.2.6:
|
||||
resolution: {integrity: sha512-r1eOj2PtTJi+9aZxLirktoHntuYXlbQD9ZXCjiZmJx0VBQtBcWc+rueqABuh/AxMcFHNPDSJLJAXxoj5VevTwQ==}
|
||||
engines: {node: '>=14'}
|
||||
ldapts@8.1.7:
|
||||
resolution: {integrity: sha512-TJl6T92eIwMf/OJ0hDfKVa6ISwzo+lqCWCI5Mf//ARlKa3LKQZaSrme/H2rCRBhW0DZCQlrsV+fgoW5YHRNLUw==}
|
||||
engines: {node: '>=20'}
|
||||
|
||||
leac@0.6.0:
|
||||
resolution: {integrity: sha512-y+SqErxb8h7nE/fiEX07jsbuhrpO9lL8eca7/Y1nuWV2moNlXhyd59iDGcRf6moVyDMbmTNzL40SUyrFU/yDpg==}
|
||||
|
|
@ -31672,10 +31666,6 @@ snapshots:
|
|||
dependencies:
|
||||
ms: 2.1.2
|
||||
|
||||
debug@4.3.5:
|
||||
dependencies:
|
||||
ms: 2.1.2
|
||||
|
||||
debug@4.4.3(supports-color@8.1.1):
|
||||
dependencies:
|
||||
ms: 2.1.3
|
||||
|
|
@ -35135,17 +35125,9 @@ snapshots:
|
|||
dependencies:
|
||||
readable-stream: 2.3.8
|
||||
|
||||
ldapts@4.2.6:
|
||||
ldapts@8.1.7:
|
||||
dependencies:
|
||||
'@types/asn1': 0.2.0
|
||||
'@types/node': 20.19.21
|
||||
'@types/uuid': 10.0.0
|
||||
asn1: 0.2.6
|
||||
debug: 4.3.5
|
||||
strict-event-emitter-types: 2.0.0
|
||||
uuid: 13.0.1
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
leac@0.6.0: {}
|
||||
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@ catalog:
|
|||
kafkajs: 2.2.4
|
||||
langchain: 1.2.30
|
||||
langsmith: 0.6.0
|
||||
ldapts: 8.1.7
|
||||
lodash: 4.18.1
|
||||
luxon: 3.7.2
|
||||
mime-types: 3.0.2
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user