Skip to content

Commit

Permalink
fix(core): Prevent shared user details being saved alongside executio…
Browse files Browse the repository at this point in the history
…n data (#5334)

* 🔨 - Remove `shared` key from execution save data

* 👕 - Using import type where needed

* remove console.log

* 🔨 - Create new clean workflowData instead of removing shared

If IWorkflowBase changes in future, TS will error out here ensuring it's kept up to date

* 🔨 - use lodash.pick for less verbosity

* 🔨 - fix lodash imports
  • Loading branch information
freya authored Feb 2, 2023
1 parent 93a2dac commit 6ca49f9
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion packages/cli/src/WorkflowExecuteAdditionalData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import {
WorkflowHooks,
} from 'n8n-workflow';

import pick from 'lodash.pick';
import { LessThanOrEqual } from 'typeorm';
import { DateUtils } from 'typeorm/util/DateUtils';
import config from '@/config';
Expand Down Expand Up @@ -583,13 +584,28 @@ function hookFunctionsSave(parentProcessMode?: string): IWorkflowExecuteHooks {
}
}

// Although it is treated as IWorkflowBase here, it's being instantiated elsewhere with properties that may be sensitive
// As a result, we should create an IWorkflowBase object with only the data we want to save in it.
const pristineWorkflowData: IWorkflowBase = pick(this.workflowData, [
'id',
'name',
'active',
'createdAt',
'updatedAt',
'nodes',
'connections',
'settings',
'staticData',
'pinData',
]);

const fullExecutionData: IExecutionDb = {
data: fullRunData.data,
mode: fullRunData.mode,
finished: fullRunData.finished ? fullRunData.finished : false,
startedAt: fullRunData.startedAt,
stoppedAt: fullRunData.stoppedAt,
workflowData: this.workflowData,
workflowData: pristineWorkflowData,
waitTill: fullRunData.waitTill,
};

Expand Down

0 comments on commit 6ca49f9

Please sign in to comment.