mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
AssignedBleed follow-up, GHSA-3cgr-47wm-9cc9. An assigned-only member
(isNormalAssignedOnly, isCommentAssignedOnly, isReadAssignedOnly) sees only
the cards assigned to them. 1a218ead02 applied that to the attachment API,
but six other paths asked only for board membership, which such a member
has:
- the /cdn/storage/attachments and /cfs/files/attachments downloads
(universalFileServer isAuthorizedForBoard) served any card's file;
- Attachments.protected, ostrio:files' own download check, likewise;
- the legacy /cfs/files/attachments route likewise;
- searchAttachmentDocumentText matched the extracted text of every card's
PDF/DOCX/XLSX/PPTX on the board and returned snippets with their
attachment and card ids - no id needed, and it supplied the ids for the
downloads;
- legacyBoardAttachments without a cardId published every legacy
attachment record of the board;
- linkedListCards published every card of the source list.
The downloads now also ask mayReadBoardAttachment(), which names the
refusing path in Admin Panel -> Problems (authz.assigned, medium: never
disables). The document search and the legacy publication are narrowed to
the member's cards (assignedOnlyCardIds); asking the publication for a card
not assigned to them is refused and recorded, as card details always pass
the open card. Linked-list cards take the source board's
assignedOnlyCardScope; searching and viewing a linked list are ordinary
use, so those are not recorded.
The board's own files - background (sidebar or API upload) and map image -
carry no card and are part of the board every member sees; they stay
readable, where the attachment API refused them to an assigned-only
member. Any other card-less file is still refused.
tests/assignedOnlyReads.test.cjs pins each path, the board-file rule and
the refusal source, and fails when any file in server/ or models/ that
serves attachment or document data lacks the rule without a stated
exemption. The Playwright spec checks both downloads refuse the hidden
card's file but not the member's own, that the search finds only the
member's card, and that the owner is unaffected. Four source guards that
pinned the old lines now pin the new ones.
Thanks to crypto-nidh and xet7 !
54 lines
3.6 KiB
JavaScript
54 lines
3.6 KiB
JavaScript
'use strict';
|
|
|
|
// #2809: a linked whole list - a live mirror of another board's list,
|
|
// editable by whoever may write the source board.
|
|
// Run: node tests/linkedList.test.cjs
|
|
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
const { isLinkedList, linkedListCardsSelector, validLink } = require('../models/lib/linkedList.js');
|
|
|
|
const ROOT = path.join(__dirname, '..');
|
|
const read = f => fs.readFileSync(path.join(ROOT, f), 'utf8');
|
|
|
|
const linked = { _id: 'L', boardId: 'B', linkedBoardId: 'S', linkedListId: 'SL' };
|
|
|
|
// Positive.
|
|
assert.equal(isLinkedList(linked), true);
|
|
assert.deepEqual(linkedListCardsSelector(linked, { swimlaneId: 'w1', firstSwimlaneId: 'w1' }), { boardId: 'S', listId: 'SL', archived: false });
|
|
assert.deepEqual(linkedListCardsSelector(linked, {}), { boardId: 'S', listId: 'SL', archived: false }, 'the Lists view');
|
|
assert.equal(validLink({ boardId: 'B', sourceBoardId: 'S', sourceListId: 'SL', sourceList: { boardId: 'S' } }), true);
|
|
console.log(' ok - the source list\'s cards, once');
|
|
|
|
// Negative.
|
|
assert.deepEqual(linkedListCardsSelector(linked, { swimlaneId: 'w2', firstSwimlaneId: 'w1' }), { _id: { $in: [] } }, 'not repeated in other swimlanes');
|
|
assert.equal(linkedListCardsSelector({ _id: 'x' }), null, 'an ordinary list');
|
|
for (const bad of [
|
|
{ boardId: 'B', sourceBoardId: 'B', sourceListId: 'x', sourceList: { boardId: 'B' } },
|
|
{ boardId: 'B', sourceBoardId: 'S', sourceListId: 'SL', sourceList: { boardId: 'OTHER' } },
|
|
{ boardId: 'B', sourceBoardId: 'S', sourceListId: 'SL', sourceList: { boardId: 'S', archived: true } },
|
|
{ boardId: 'B', sourceBoardId: 'S', sourceListId: 'SL', sourceList: { boardId: 'S', linkedBoardId: 'T', linkedListId: 'TL' } },
|
|
{ boardId: 'B', sourceBoardId: 'S', sourceListId: 'SL', sourceList: null },
|
|
]) assert.equal(validLink(bad), false, JSON.stringify(bad));
|
|
console.log(' ok - no self link, foreign or archived list, or a mirror of a mirror');
|
|
|
|
// Server: both boards visible to see it; the source's write right to add to it.
|
|
const server = read('server/linkedLists.js');
|
|
assert.ok(server.includes('const source = await visibleBoard(this.userId, list.linkedBoardId);') &&
|
|
server.includes('if (!(await visibleBoard(this.userId, list.boardId)) || !source) return this.ready();'),
|
|
'the cards only to a subscriber who sees both boards');
|
|
// ...and of the source board only the cards they see there (GHSA-3cgr-47wm-9cc9).
|
|
assert.ok(server.includes('...(assignedOnlyCardScope(source, this.userId) || {}) }, { limit: 1000 })'),
|
|
'an assigned-only member of the source board gets their own cards');
|
|
assert.match(server, /if \(!\(await canWriteInList\(this\.userId, source, sourceList\._id\)\)\) throw new Meteor\.Error\('not-authorized'\);/);
|
|
assert.match(server, /if \(!board \|\| board\.archived \|\| !allowIsBoardMemberWithWriteAccess\(this\.userId, board\)\) throw/);
|
|
assert.match(server, /if \(!validLink\(\{ \.\.\.input, sourceList \}\)\) throw new Meteor\.Error\('linked-list-invalid'\);/);
|
|
assert.match(read('models/lists.js'), /linkedBoardId: \{[\s\S]{0,300}type: String,\s*optional: true,/);
|
|
const body = read('client/components/lists/listBody.js');
|
|
assert.match(body, /if \(isLinkedList\(list\)\) \{\s*tpl\.subscribe\('linkedListCards', list\._id\);/);
|
|
assert.match(body, /if \(data\.linkedListId\) \{\s*await Meteor\.callAsync\('addCardToLinkedList', data\._id, title\);/);
|
|
assert.match(read('client/components/swimlanes/swimlanes.jade'), /a\.js-link-list \{\{_ 'link-list-from-board'\}\}/);
|
|
console.log(' ok - visibility of both boards, the source board\'s write rule, the UI');
|
|
console.log('\nlinkedList: all tests passed');
|