Skip to content

Commit b33289b

Browse files
committed
fix(eslint): add eslint-disable comments for security rules in sync-node-tests, enhance, and test-utils
1 parent adfeddd commit b33289b

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

scripts/sync-node-tests.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ function adaptTest(content: string, fileName: string): string {
207207
// Match test('name', ...) or suite('name', ...) with any quote style
208208
// and transform to test.skip('name', /* reason */ ...) or suite.skip(...)
209209
adapted = adapted.replace(
210+
// eslint-disable-next-line security/detect-non-literal-regexp -- `escaped` is sanitized above
210211
new RegExp(`(test|suite)\\((['"\`])${escaped}\\2`, "g"),
211212
`$1.skip($2${name}$2 /* ${reason} */`,
212213
);

src/enhance.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,10 @@ function expandRowFromArray(
195195
): Record<string, Record<string, unknown>> {
196196
const result: Record<string, Record<string, unknown>> = {};
197197
for (let i = 0; i < columnMap.length && i < row.length; i++) {
198-
const { table, column } = columnMap[i]!;
198+
const { table, column } = columnMap[i]!; // eslint-disable-line security/detect-object-injection
199+
// eslint-disable-next-line security/detect-object-injection -- table/column from our own columnMap
199200
result[table] ??= {};
200-
result[table]![column] = row[i];
201+
result[table]![column] = row[i]; // eslint-disable-line security/detect-object-injection
201202
}
202203
return result;
203204
}
@@ -214,9 +215,10 @@ function expandRowFromObject(
214215
const result: Record<string, Record<string, unknown>> = {};
215216
const keys = Object.keys(row);
216217
for (let i = 0; i < keys.length && i < columnMap.length; i++) {
217-
const { table, column } = columnMap[i]!;
218+
const { table, column } = columnMap[i]!; // eslint-disable-line security/detect-object-injection
219+
// eslint-disable-next-line security/detect-object-injection -- table/column from our own columnMap
218220
result[table] ??= {};
219-
result[table]![column] = row[keys[i]!];
221+
result[table]![column] = row[keys[i]!]; // eslint-disable-line security/detect-object-injection
220222
}
221223
return result;
222224
}
@@ -498,6 +500,7 @@ export function enhance<T extends EnhanceableDatabaseSync>(
498500
}
499501

500502
// Wrap prepare() to add pluck() to returned statements
503+
// eslint-disable-next-line security/detect-object-injection -- ENHANCED_PREPARE is a Symbol
501504
if (!(db as any)[ENHANCED_PREPARE]) {
502505
const originalPrepare: any = db.prepare.bind(db);
503506

test/common/test-utils.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const tmpdir = {
2121
} catch {
2222
// Ignore errors if directory doesn't exist
2323
}
24-
fs.mkdirSync(testDir, { recursive: true });
24+
fs.mkdirSync(testDir, { recursive: true }); // eslint-disable-line security/detect-non-literal-fs-filename
2525
},
2626
};
2727

0 commit comments

Comments
 (0)