mirror of
https://github.com/wekan/wekan.git
synced 2026-11-25 10:48:06 -05:00
Alert 565 (ReDoS): the package-specifier pattern in
releases/prune-unreachable-npm.mjs allowed `/` both between and inside path
segments, so a quoted `-/-/-/...` could be split in exponentially many ways;
es-module-lexer's minified lexer alone took over two seconds. A `/` now only
separates segments. Over the 23,812 files in node_modules it finds every
package it found before, and also `require('querystring-es3/')`, the
trailing-slash form the old pattern missed.
Alert 566 (bad tag filter): the Sandstorm readiness test matched <script>
case-sensitively. It and three negative checks that said "no <script" in
sanitized output now match any case; one of those also collected tag names
with a case-sensitive pattern that an <SCRIPT> tag would have escaped.
Alerts 567 and 568 (code sanitization): a test wrote dictionary paths into
generated JavaScript with JSON.stringify. It copies the dictionaries beside
its entry so the source is constant, and four more test probes take module
paths as arguments instead. The i18n loader the test drives, which writes an
asset name into generated server code, refuses a name outside a locale
tag's characters and escapes the literal.
tests/securityAlerts20261012.test.cjs fails on any case-sensitive script,
noscript or iframe pattern and on JSON.stringify spliced into an import,
require or asset path anywhere in the tree.
Thanks to GitHub CodeQL and xet7 !
70 lines
4.2 KiB
JavaScript
70 lines
4.2 KiB
JavaScript
'use strict';
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
const vm = require('node:vm');
|
|
const file = fs.readFileSync(path.join(__dirname, '../client/components/boards/multiboardCalendarView.js'), 'utf8');
|
|
// Resolve the real module's imports explicitly; no Filter/FlowRouter globals.
|
|
const source = file.replace(/^import\s+\{([^}]+)\}\s+from\s+(['"])([^'"]+)\2;/gm,
|
|
// The specifier is re-emitted as the very literal the source wrote.
|
|
(_, names, quote, specifier) => `const {${names}} = require(${quote}${specifier}${quote});`);
|
|
let created, helpers, active = false, ready = true, rtl = false, instance;
|
|
const start = new Date('2026-03-21T12:00:00Z'), end = new Date('2026-03-22T12:00:00Z');
|
|
const boards = ['a', 'b'].map(id => ({
|
|
_id: id, title: `Board ${id}`, slug: id,
|
|
cardsInInterval(from, to, selector) {
|
|
assert.equal(from, start); assert.equal(to, end);
|
|
assert.equal(Boolean(selector), active);
|
|
return [{ _id: `${id}-visible`, title: 'Visible', startAt: start, endAt: end },
|
|
...(!selector ? [{ _id: `${id}-hidden`, title: 'Hidden', startAt: start, endAt: end }] : [])];
|
|
},
|
|
cardsReceivedInBetween() { return []; }, cardsDueInBetween() { return []; }, cardsEndInBetween() { return []; },
|
|
}));
|
|
const dependencies = {
|
|
'/client/lib/filter': { Filter: { isActive: () => active, _getMongoSelector: () => ({ labelIds: 'visible' }) } },
|
|
'meteor/ostrio:flow-router-extra': { FlowRouter: { path(name, params) {
|
|
assert.equal(name, 'card'); return `/b/${params.boardId}/${params.slug}/${params.cardId}`;
|
|
} } },
|
|
'/client/lib/dateDisplay': { calendarDateDisplayOptions: () => ({ initialView: 'selectedCalendarMonth' }) },
|
|
'/imports/reactiveCache': { ReactiveCache: {
|
|
getBoards(query) { assert.equal(query['members.userId'], 'member'); assert.equal(query.archived, false); assert.equal(query.type, 'board'); return boards; },
|
|
getCurrentUser: () => null,
|
|
} },
|
|
'/imports/i18n': { TAPi18n: { __: key => key, getLanguage: () => 'en', isRTL: () => rtl } },
|
|
'meteor/reactive-var': { ReactiveVar: class { constructor(value) { this.value = value; } get() { return this.value; } set(value) { this.value = value; } } },
|
|
'/client/lib/calendarFirstDay': { toFullCalendarFirstDay: value => value },
|
|
'/models/lib/weekStart': { weekNumberByFirstDay: () => 1 },
|
|
'/models/lib/helperBoards': { notHelperBoardTitle: () => ({ $nin: ['Templates'] }) },
|
|
};
|
|
vm.runInNewContext(source, {
|
|
Meteor: { userId: () => 'member' },
|
|
Template: { multiboardCalendarView: { onCreated: callback => { created = callback; }, helpers: value => { helpers = value; } }, instance: () => instance },
|
|
require(specifier) { assert.ok(dependencies[specifier], `unexpected import ${specifier}`); return dependencies[specifier]; },
|
|
});
|
|
instance = { autorun(callback) { callback(); }, subscribe(name, id, lazy) {
|
|
assert.equal(name, 'board'); assert.ok(['a', 'b'].includes(id)); assert.equal(lazy, false);
|
|
return { ready: () => ready || id === 'a' };
|
|
} };
|
|
created.call(instance); assert.equal(helpers.isLoading(), false);
|
|
const options = helpers.multiboardCalendarOptions();
|
|
assert.equal(options.initialView, 'selectedCalendarMonth');
|
|
assert.equal(options.direction, 'ltr');
|
|
assert.equal(Object.hasOwn(options, 'isRTL'), false, 'FullCalendar 5 rejects the legacy isRTL option');
|
|
rtl = true;
|
|
assert.equal(helpers.multiboardCalendarOptions().direction, 'rtl');
|
|
rtl = false;
|
|
const boardSource = fs.readFileSync(path.join(__dirname, '../client/components/boards/boardBody.js'), 'utf8');
|
|
assert.match(boardSource, /direction: TAPi18n\.isRTL\(\) \? 'rtl' : 'ltr'/);
|
|
assert.doesNotMatch(boardSource, /isRTL\s*:/);
|
|
|
|
let events;
|
|
options.events({ start, end }, result => { events = result; });
|
|
assert.equal(events.length, 4);
|
|
assert.ok(events.some(event => event.title === '[Board a] Visible'));
|
|
assert.ok(events.some(event => event.url === '/b/b/b/b-visible'));
|
|
active = true;
|
|
options.events({ start, end }, result => { events = result; });
|
|
assert.equal(events.length, 2); assert.ok(events.every(event => !event.title.includes('Hidden')));
|
|
ready = false; created.call(instance); assert.equal(helpers.isLoading(), true);
|
|
console.log('multi-board calendar runtime: module imports, membership scope, card URLs, selected view, active filters and subscription readiness pass');
|