mirror of
https://github.com/wekan/wekan.git
synced 2026-11-26 01:49:41 -05:00
The board publication shows an assigned-only member only the cards assigned to them, but the attachment API (REST and DDP list, download and info), the activities publication, Due Cards with all users, Global Search, the structural move pickers and position history asked only for board membership and so showed every card of the board. Each now applies the same rule; a download or info request for another card's attachment is recorded under AssignedBleed in Admin Panel -> Problems. Thanks to xet7 !
72 lines
2.6 KiB
JavaScript
72 lines
2.6 KiB
JavaScript
'use strict';
|
|
|
|
// Regression coverage for SearchBleed.
|
|
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
|
|
const root = path.resolve(__dirname, '..');
|
|
const cards = fs.readFileSync(
|
|
path.join(root, 'server/publications/cards.js'),
|
|
'utf8',
|
|
);
|
|
|
|
assert.match(
|
|
cards,
|
|
/import \{ MATCH_NOTHING, selectorIsInjection \} from '\/server\/lib\/selectorGuard';/,
|
|
'global search must use the shared NoSQL execution guard',
|
|
);
|
|
|
|
const buildSelectorBranch = cards.match(
|
|
/if \(queryParams\.selector\) \{[\s\S]*?\n \} else \{/,
|
|
);
|
|
assert.ok(buildSelectorBranch, 'the client-selector branch must remain identifiable');
|
|
assert.match(
|
|
buildSelectorBranch[0],
|
|
/selectorIsInjection\(queryParams\.selector, 'globalSearch'\)/,
|
|
'an executable client selector must be rejected',
|
|
);
|
|
assert.match(
|
|
buildSelectorBranch[0],
|
|
/\$and: \[[\s\S]*queryParams\.selector[\s\S]*boardId:[\s\S]*Boards\.userBoardIds/,
|
|
'a benign client selector must be conjoined with the caller board scope',
|
|
);
|
|
assert.doesNotMatch(
|
|
buildSelectorBranch[0],
|
|
/selector = queryParams\.selector;/,
|
|
'the publication must never adopt a client selector verbatim',
|
|
);
|
|
|
|
const findCards = cards.match(
|
|
/async function findCards\(sessionId, query, userId\) \{[\s\S]*?ReactiveCache\.getCards\(databaseSelector/,
|
|
);
|
|
assert.ok(findCards, 'the shared initial and pagination query path must exist');
|
|
assert.match(
|
|
findCards[0],
|
|
/selectorIsInjection\([\s\S]*?query\.selector,[\s\S]*?'globalSearch\.pagination'/,
|
|
'stored selectors must be checked again before pagination executes them',
|
|
);
|
|
assert.match(
|
|
findCards[0],
|
|
/\$and: \[storedSelector, boardScope\]/,
|
|
'stored selectors from older releases must be constrained to current access',
|
|
);
|
|
// boardScope is the authorized boards, narrowed to assigned cards on a board
|
|
// where the user is an assigned-only member (2026-10-02). Both arms stay
|
|
// inside authorizedBoardIds.
|
|
assert.match(findCards[0], /\? \{ boardId: \{ \$in: authorizedBoardIds \} \}/);
|
|
assert.match(findCards[0], /\{ boardId: \{ \$in: authorizedBoardIds\.filter\(id => !assignedOnlyBoardIds\.includes\(id\)\) \} \},\n\s*\{ boardId: \{ \$in: assignedOnlyBoardIds \}, assignees: userId \},/);
|
|
assert.ok(
|
|
findCards[0].indexOf('selectorIsInjection(query.selector') <
|
|
findCards[0].indexOf('ReactiveCache.getCards(databaseSelector'),
|
|
'the guard must run before the database query',
|
|
);
|
|
assert.match(
|
|
cards,
|
|
/selector: SessionData\.pickle\(storedSelector\)/,
|
|
'an injected legacy selector must be replaced before it is stored again',
|
|
);
|
|
|
|
console.log('globalSearchSelectorAuthorization: 10 assertions passed');
|