mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-11-16 17:09:09 +00:00
test(db): escape every metacharacter in the gate test's string builders
CodeQL flagged two js/incomplete-sanitization alerts in check-migration-numbering-base-diff.test.ts. One test built a RegExp from a migration file name by escaping only the dot. Another built JS string literals from a fixture by escaping only the quotes, never the backslash. Today's inputs have neither metacharacters nor backslashes, so the tests behaved the same, but a future name or fixture could have broken them silently. The RegExp builder now escapes every metacharacter, and both literal builders escape backslashes before quotes. The suite still passes 58/58.
This commit is contained in:
@@ -482,7 +482,7 @@ function assertStrictRemovalMessage(stderr: string, name: string) {
|
||||
assert.match(
|
||||
stderr,
|
||||
new RegExp(
|
||||
`${name.replace(/\./g, "\\.")}: migration já mesclada não pode ser apagada nem renomeada`
|
||||
`${name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}: migration já mesclada não pode ser apagada nem renomeada`
|
||||
)
|
||||
);
|
||||
assert.match(stderr, /homologação, Docker :next, VPS, sync do Enterprise/);
|
||||
@@ -726,8 +726,8 @@ test("parser: declarations inside string literals are ignored; zero or two real
|
||||
const real = "export const RENAMED_MIGRATION_COMPATIBILITY = [];";
|
||||
for (const decoy of [
|
||||
`const NOTE = \`${fake}\`;`,
|
||||
`const NOTE = '${fake.replace(/"/g, "\\'")}';`,
|
||||
`const NOTE = "${fake.replace(/"/g, '\\"')}";`,
|
||||
`const NOTE = '${fake.replace(/\\/g, "\\\\").replace(/"/g, "\\'")}';`,
|
||||
`const NOTE = "${fake.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}";`,
|
||||
]) {
|
||||
assert.deepEqual(lib.parseRenamedMigrationCompatibility(`${decoy}\n${real}\n`), [], decoy);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user