mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 18:10:06 -05:00
Alert 564 (regex injection): releases/platform-native-packages.mjs compiled
its command-line platform and arch into a RegExp. The canvas package names
are now compared as strings. The upload naming of attachments and avatars,
the attachment rename popup and tools/mirror-menu.mjs built a RegExp from a
file extension or a name the same way; they use literal suffix and prefix
checks now. tests/noUnescapedDynamicRegExp.test.cjs parses every source file
and fails on a RegExp built from a value that is not escaped, unless the
site is listed with the reason its values are constants.
Alert 563 (incomplete escaping): name.replace('/', '%2F') replaced only the
first slash. registryPackagePath() replaces every one and refuses anything
that is not an npm package name. Seven tests escaped a regex the same
first-only way; 'g++'.replace('+', '\\+') let "- g+" pass a guard. They use
the complete escapeRegExp, and tests/noIncompleteRegExpEscaping.test.cjs
fails on any string-pattern replace that performs an escape.
Alert 562 (ReDoS): the CasaOS reverse-domain id pattern in
tests/platformTemplates.test.cjs let '.' be matched by both groups, so
'0.0.0...!' backtracked exponentially. Each separator now belongs to one
group, and the test runs CodeQL's attack string against it.
Thanks to GitHub CodeQL and xet7 !
63 lines
1.6 KiB
JavaScript
63 lines
1.6 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
const escapeRegExp = text => text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
|
|
const root = path.resolve(__dirname, '..');
|
|
const cardDate = fs.readFileSync(
|
|
path.join(root, 'client/components/cards/cardDate.js'),
|
|
'utf8',
|
|
);
|
|
const cardDetails = fs.readFileSync(
|
|
path.join(root, 'client/components/cards/cardDetails.js'),
|
|
'utf8',
|
|
);
|
|
const datePicker = fs.readFileSync(
|
|
path.join(root, 'client/lib/datepicker.js'),
|
|
'utf8',
|
|
);
|
|
|
|
for (const method of ['setReceived', 'setStart', 'setDue', 'setEnd']) {
|
|
assert.match(
|
|
cardDate,
|
|
new RegExp(`return currentCard\\.${method}\\(date\\);`),
|
|
`${method} callback must return its update promise`,
|
|
);
|
|
}
|
|
|
|
for (const method of ['unsetReceived', 'unsetStart', 'unsetDue', 'unsetEnd']) {
|
|
assert.match(
|
|
cardDate,
|
|
new RegExp(`return currentCard\\.${method}\\(\\);`),
|
|
`${method} callback must return its update promise`,
|
|
);
|
|
}
|
|
|
|
for (const method of [
|
|
'cards.setVoteEnd',
|
|
'cards.unsetVoteEnd',
|
|
'cards.setPokerEnd',
|
|
'cards.unsetPokerEnd',
|
|
]) {
|
|
assert.match(
|
|
cardDetails,
|
|
new RegExp(`await Meteor\\.callAsync\\('${escapeRegExp(method)}'`),
|
|
`${method} callback must await the server method`,
|
|
);
|
|
}
|
|
|
|
assert.match(
|
|
datePicker,
|
|
/datePicker\.date\.set\(dateObj\);/,
|
|
'a valid edited date must update the reactive popup draft',
|
|
);
|
|
assert.match(
|
|
datePicker,
|
|
/datePicker\.date\.set\(draftDate\);/,
|
|
'a valid edited time must update the reactive popup draft',
|
|
);
|
|
|
|
console.log('datePickerCallbacks: 14 tests passed');
|