feat(core)!: Introduce insecure mode in task runner (#16911)

This commit is contained in:
Iván Ovejero
2025-07-04 08:32:49 +02:00
committed by GitHub
parent 60e78a4fec
commit 7317f67797
10 changed files with 107 additions and 40 deletions

View File

@@ -26,6 +26,7 @@ describe('TaskRunnerProcess', () => {
const runnerConfig = mockInstance(TaskRunnersConfig);
runnerConfig.enabled = true;
runnerConfig.mode = 'internal';
runnerConfig.insecureMode = false;
const authService = mock<TaskBrokerAuthService>();
let taskRunnerProcess = new TaskRunnerProcess(logger, runnerConfig, authService, mock());
@@ -78,7 +79,7 @@ describe('TaskRunnerProcess', () => {
'DEPLOYMENT_NAME',
'NODE_PATH',
'GENERIC_TIMEZONE',
'N8N_RUNNERS_ALLOW_PROTOTYPE_MUTATION',
'N8N_RUNNERS_INSECURE_MODE',
])('should propagate %s from env as is', async (envVar) => {
jest.spyOn(authService, 'createGrantToken').mockResolvedValue('grantToken');
process.env[envVar] = 'custom value';
@@ -150,7 +151,7 @@ describe('TaskRunnerProcess', () => {
);
});
it('should use --disallow-code-generation-from-strings and --disable-proto=delete flags', async () => {
it('on secure mode, should use --disallow-code-generation-from-strings and --disable-proto=delete flags', async () => {
jest.spyOn(authService, 'createGrantToken').mockResolvedValue('grantToken');
await taskRunnerProcess.start();
@@ -161,5 +162,22 @@ describe('TaskRunnerProcess', () => {
expect.stringContaining('/packages/@n8n/task-runner/dist/start.js'),
]);
});
it('on insecure mode, should not use --disallow-code-generation-from-strings and --disable-proto=delete flags', async () => {
jest.spyOn(authService, 'createGrantToken').mockResolvedValue('grantToken');
runnerConfig.insecureMode = true;
const insecureTaskRunnerProcess = new TaskRunnerProcess(
logger,
runnerConfig,
authService,
mock(),
);
await insecureTaskRunnerProcess.start();
expect(spawnMock.mock.calls[0].at(1)).toEqual([
expect.stringContaining('/packages/@n8n/task-runner/dist/start.js'),
]);
});
});
});