fix(core): Restrict read/write file paths access (#6582)

This commit is contained in:
Michael Kret
2023-07-31 15:20:39 +03:00
committed by GitHub
parent 7cd45885bf
commit f6bf9e9887
8 changed files with 141 additions and 18 deletions

View File

@@ -25,8 +25,8 @@ import { isEqual, isNull, merge } from 'lodash';
* // => [['a', 'b', 'c'], ['d']]
*/
export function chunk(array: any[], size = 1) {
const length = array == null ? 0 : array.length;
export function chunk<T>(array: T[], size = 1) {
const length = array === null ? 0 : array.length;
if (!length || size < 1) {
return [];
}
@@ -37,7 +37,7 @@ export function chunk(array: any[], size = 1) {
while (index < length) {
result[resIndex++] = array.slice(index, (index += size));
}
return result;
return result as T[][];
}
/**
@@ -51,20 +51,22 @@ export function chunk(array: any[], size = 1) {
*
*/
export function flatten(nestedArray: any[][]) {
export function flatten<T>(nestedArray: T[][]) {
const result = [];
(function loop(array: any[] | any) {
(function loop(array: T[] | T[][]) {
for (let i = 0; i < array.length; i++) {
if (Array.isArray(array[i])) {
loop(array[i]);
loop(array[i] as T[]);
} else {
result.push(array[i]);
}
}
})(nestedArray);
return result;
//TODO: check logic in MicrosoftSql.node.ts
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-return
return result as any;
}
export function updateDisplayOptions(
@@ -210,7 +212,7 @@ export function wrapData(data: IDataObject | IDataObject[]): INodeExecutionData[
export const keysToLowercase = <T>(headers: T) => {
if (typeof headers !== 'object' || Array.isArray(headers) || headers === null) return headers;
return Object.entries(headers).reduce((acc, [key, value]) => {
acc[key.toLowerCase()] = value;
acc[key.toLowerCase()] = value as IDataObject;
return acc;
}, {} as IDataObject);
};