mirror of
https://github.com/wekan/wekan.git
synced 2026-11-25 04:49:41 -05:00
AssignedBleed follow-up, GHSA-r4gm-mjj9-g3x8. An assigned-only member (isNormalAssignedOnly, isCommentAssignedOnly, isReadAssignedOnly, and custom roles through those flags) sees only the cards assigned to them. The Board Email View checked board.isVisibleBy() alone, so it published the title, description and email metadata of every card in a list or label, counted them, and searched them. It now merges assignedOnlyCardScope into its folder and search selector for the page and the count, and a reply on another card is refused. An audit of every path that returns or changes a card found the same shape - "a member of the board, so every card of it" - elsewhere, all fixed here: - reads: the board publication's ancestor cards, linked source cards with their subtasks and dependency targets, and comment reactions; All Boards tile counts; a board's activities from linked boards; the Chat view and the All Boards feed, which also let card MEMBERS through (assignees is the rule); My Attachments' card; GET /api/user/cards; position history of a card; the cross-board subtask picker; Scrum rollover counts; and the notification publications, which kept sending the full documents of cards named in old notifications - also to members removed from the board; - writes on a card the member cannot see: the canonical canEditCardOrLinkedCard / editableCardIds (every Cards.allow update, checklists, items, attachments, text notes, custom fields, the shared description, card methods) now ask the card - the role's `write` is a board answer, and the card is read when a caller passed it without assignees; DDP and REST comments, button rules on a card, checklist moves, issue state, watching, the card-opened webhook, moveBoardObjects, moveSwimlane and attachment moves; - REST writes: checkBoardWriteAccess refuses assigned-only members, as checkBoardAccess already does for reads - those routes act on any card, list or swimlane by id. The GHSA-f396 canary still fires for a role without the write capability. A refusal no view would produce is recorded under AssignedBleed in Admin Panel -> Problems (authz.assigned, medium: never disables); opening a view, searching and REST calls are narrowed or refused without a record. tests/boardRoleViews.test.cjs runs the Email View selector, pins every path above, and fails when any server file that serves card data has no role rule and no stated exemption; the "assignee or card member" rule is rejected anywhere in server/ and models/. server/lib/tests/editableCardIds adds an assigned-only case for both edit checks (meteor test; not run here). Seven guards that pinned the old lines now pin the new ones. Thanks to crypto-nidh, binary-lover and xet7 !
98 lines
4.4 KiB
JavaScript
98 lines
4.4 KiB
JavaScript
// Board View / Version Control: the board as a GitHub / Gitea issue tracker
|
|
// (client/components/boards/versionControlView.*,
|
|
// docs/Features/Board/Version-Control-View.md). Reading needs nothing new -
|
|
// the cards, labels, comments and attachments are the board's own, already
|
|
// published to whoever can see the board. Only two writes need the server:
|
|
//
|
|
// vcsCreateIssue New issue: a card in the board's open list
|
|
// vcsSetIssueState Close / Reopen: the card moves to the closed / open list
|
|
//
|
|
// Both write through the ordinary collections, not `.direct`, so the change
|
|
// history hooks (server/models/changeHistoryHooks.js) record them and the
|
|
// History tab - the board's history table - can undo them like any other move.
|
|
import { Meteor } from 'meteor/meteor';
|
|
import { check, Match } from 'meteor/check';
|
|
import { ReactiveCache } from '/imports/reactiveCache';
|
|
import Cards from '/models/cards';
|
|
import { cardCreation } from '/models/cards';
|
|
import Lists from '/models/lists';
|
|
import { allowIsBoardMemberWithWriteAccess } from '/server/lib/utils';
|
|
import { canEditCardOrLinkedCard } from '/server/lib/linkedCardPermission';
|
|
|
|
const { cleanNewIssue, stateTarget, isSyncedIssue } = require('/models/lib/versionControlView');
|
|
|
|
async function writableBoard(userId, boardId) {
|
|
const board = await ReactiveCache.getBoard(boardId);
|
|
if (!userId || !board || !allowIsBoardMemberWithWriteAccess(userId, board)) throw new Meteor.Error('not-authorized');
|
|
return board;
|
|
}
|
|
|
|
// The list a state lives in, made when the board has none (a board that was
|
|
// not imported from a tracker has no "Closed" list until an issue is closed).
|
|
async function listFor(board, state) {
|
|
const lists = await ReactiveCache.getLists({ boardId: board._id, archived: false }, { sort: { sort: 1 } });
|
|
const target = stateTarget(lists || [], state);
|
|
if (target.listId) return target.listId;
|
|
const last = (lists || []).reduce((max, l) => Math.max(max, Number(l.sort) || 0), -1);
|
|
return Lists.insertAsync({
|
|
title: target.create, boardId: board._id, sort: last + 1, archived: false, createdAt: new Date(),
|
|
});
|
|
}
|
|
|
|
Meteor.methods({
|
|
async vcsCreateIssue(boardId, input) {
|
|
check(boardId, String);
|
|
check(input, { title: String, body: Match.Optional(String), labelIds: Match.Optional([String]) });
|
|
const userId = this.userId;
|
|
const board = await writableBoard(userId, boardId);
|
|
let issue;
|
|
try {
|
|
issue = cleanNewIssue(input);
|
|
} catch (e) {
|
|
throw new Meteor.Error(e.message);
|
|
}
|
|
const known = new Set((board.labels || []).map(l => l._id));
|
|
const listId = await listFor(board, 'open');
|
|
const swimlane = await board.getDefaultSwimlineAsync();
|
|
if (!listId || !swimlane) throw new Meteor.Error('vcs-no-list');
|
|
const siblings = await ReactiveCache.getCards({ boardId: board._id, listId, archived: false });
|
|
const cardId = await Cards.insertAsync({
|
|
title: issue.title,
|
|
description: issue.body,
|
|
boardId: board._id,
|
|
listId,
|
|
swimlaneId: swimlane._id,
|
|
userId,
|
|
labelIds: issue.labelIds.filter(id => known.has(id)),
|
|
sort: (siblings || []).length,
|
|
cardNumber: await board.getNextCardNumber(),
|
|
});
|
|
const created = await ReactiveCache.getCard(cardId);
|
|
if (created) await cardCreation(userId, created);
|
|
return { cardId };
|
|
},
|
|
|
|
async vcsSetIssueState(cardId, state) {
|
|
check(cardId, String);
|
|
check(state, Match.OneOf('open', 'closed'));
|
|
const userId = this.userId;
|
|
const card = await ReactiveCache.getCard(cardId);
|
|
if (!card) throw new Meteor.Error('not-found');
|
|
const board = await writableBoard(userId, card.boardId);
|
|
// Closing an issue moves its card: only a card the caller may edit, which
|
|
// for an assigned-only member is their own (GHSA-r4gm-mjj9-g3x8).
|
|
if (!(await canEditCardOrLinkedCard(userId, card, board))) throw new Meteor.Error('not-authorized');
|
|
// A synced issue is closed and reopened in its tracker, and the next sync
|
|
// brings the state: moving the card out of its synced list would make
|
|
// the sync see the issue as gone.
|
|
if (isSyncedIssue(card)) throw new Meteor.Error('vcs-synced-issue');
|
|
// An archived card is a closed issue; reopening it restores it.
|
|
if (state === 'open' && card.archived) await card.restore();
|
|
const listId = await listFor(board, state);
|
|
if (listId && listId !== card.listId) {
|
|
await Cards.updateAsync(card._id, { $set: { listId, dateLastActivity: new Date() } });
|
|
}
|
|
return { listId };
|
|
},
|
|
});
|