mirror of
https://github.com/wekan/wekan.git
synced 2026-11-20 15:45:01 -05:00
GHSA-83w9-74mx-7v83. A board admin can refuse a role write access in one list (#4527, roleExceptions). REST DELETE /api/boards/:boardId/cards/bulk and POST /api/boards/:boardId/cards/labels take their cards from the body, so no URL names a list, and asked only for board write access; the methods archiveSelectedCards, copyCard and createLinkedCard write from server code, past the Cards allow/deny rules. A normal member the list refused could delete, relabel and archive its cards and copy or link new cards into it. - The bulk routes read every card and ask each list before the first write (assertCardListsNotRefused): any refusal is a 403 and nothing changes, recorded in Admin Panel / Problems as ListLockBulkBleed (authz.list-locked-bulk, medium). Each removal and relabel is keyed on the list that was checked. - The methods refuse with not-authorized (assertListsWritable), not recorded: Copy Card and Multi-Selection reach them in ordinary use. - The same shape, fixed with the same check: createBoardFromCard, addSubtaskCard, createCardWithDueDate (which also did not check that the list is on the board), the iCalendar import over DDP and REST, sending and receiving board email, vcsCreateIssue, moveBoardObjects, History's undo/redo/Restore, position history undo/redo of a card, renameAttachment, the scoped import and a card's rule button. Dependency lines keep their own board-wide rule. tests/listLockBulkBleed.test.cjs runs the gate on the reporter's board and pins every path; tests/playwright/specs/list-lock-bulk.e2e.js replays the proof of concept. Older guards that pinned the previous shape are updated with the reason. Thanks to immanuwell and xet7 !
140 lines
5.9 KiB
JavaScript
140 lines
5.9 KiB
JavaScript
import { Meteor } from 'meteor/meteor';
|
|
import { WebApp } from 'meteor/webapp';
|
|
import { check } from 'meteor/check';
|
|
import Cards from '/models/cards';
|
|
import Lists from '/models/lists';
|
|
import Swimlanes from '/models/swimlanes';
|
|
import { ReactiveCache } from '/imports/reactiveCache';
|
|
import { icsToCards } from '/server/lib/icsImport';
|
|
import { Authentication } from '/server/authentication';
|
|
import { sendJsonResult } from '/server/apiMiddleware';
|
|
import { allowIsBoardMemberWithWriteAccess } from '/server/lib/utils';
|
|
import { tripCanary } from '/server/lib/canary';
|
|
import { assertListNotRefused, assertListsWritable } from '/server/lib/listPermissionGate';
|
|
|
|
// Shared import logic used by both the Meteor method and the REST endpoint.
|
|
// Validates that the target list/swimlane belong to the board (no cross-board
|
|
// writes), parses the .ics text into card shapes and inserts them.
|
|
async function importIcsCards(userId, boardId, listId, swimlaneId, icsText) {
|
|
const list = await Lists.findOneAsync(listId);
|
|
if (!list || list.boardId !== boardId) {
|
|
throw new Meteor.Error('list-not-found', 'List not found on this board.');
|
|
}
|
|
const swimlane = await Swimlanes.findOneAsync(swimlaneId);
|
|
if (!swimlane || swimlane.boardId !== boardId) {
|
|
throw new Meteor.Error('swimlane-not-found', 'Swimlane not found on this board.');
|
|
}
|
|
// ListLockBulkBleed: the list may refuse this role new cards (#4527).
|
|
await assertListsWritable(userId, await ReactiveCache.getBoard(boardId), [listId]);
|
|
const cardShapes = icsToCards(icsText, { boardId, listId, swimlaneId });
|
|
const cardIds = [];
|
|
for (const shape of cardShapes) {
|
|
const doc = {
|
|
title: shape.title,
|
|
description: shape.description,
|
|
boardId,
|
|
listId,
|
|
swimlaneId,
|
|
userId,
|
|
sort: cardIds.length,
|
|
};
|
|
if (shape.startAt) doc.startAt = shape.startAt;
|
|
if (shape.dueAt) doc.dueAt = shape.dueAt;
|
|
// eslint-disable-next-line no-await-in-loop
|
|
const cardId = await Cards.insertAsync(doc);
|
|
cardIds.push(cardId);
|
|
}
|
|
return { created: cardIds.length, cardIds };
|
|
}
|
|
|
|
/**
|
|
* Server-side Meteor method for WeKan issue #6323 (part 1: import only).
|
|
*
|
|
* Parses an uploaded iCalendar (.ics) file and creates WeKan cards on the
|
|
* given board / list / swimlane, populating each card's startAt and dueAt so
|
|
* the imported events appear on the Calendar / Gantt views.
|
|
*
|
|
* This is import-only. Two-way Google Calendar sync is out of scope; for the
|
|
* read-only export direction (WeKan -> iCal feed) see `wekan-ical-server`.
|
|
*/
|
|
Meteor.methods({
|
|
/**
|
|
* Import an .ics file into a board as cards.
|
|
*
|
|
* @param {string} boardId target board id
|
|
* @param {string} listId target list id (cards are created here)
|
|
* @param {string} swimlaneId target swimlane id
|
|
* @param {string} icsText raw .ics file contents
|
|
* @returns {{ created: number, cardIds: string[] }}
|
|
*/
|
|
async importIcsToBoard(boardId, listId, swimlaneId, icsText) {
|
|
check(boardId, String);
|
|
check(listId, String);
|
|
check(swimlaneId, String);
|
|
check(icsText, String);
|
|
|
|
if (!this.userId) {
|
|
throw new Meteor.Error('not-authorized', 'You must be logged in.');
|
|
}
|
|
|
|
const board = await ReactiveCache.getBoard(boardId);
|
|
if (!board || !board.isVisibleBy({ _id: this.userId })) {
|
|
throw new Meteor.Error('not-authorized', 'You do not have access to this board.');
|
|
}
|
|
// CalendarBleed (GHSA-fpm6-r5fg-2mrg): importing creates cards, so it must
|
|
// use the canonical write capability. Membership plus !hasReadOnly() let
|
|
// Comment Only, Only Assigned Comment and Worker members create arbitrary
|
|
// cards through DDP even though the role table gives them no write access.
|
|
// Keep this identical to the REST sibling below.
|
|
if (!allowIsBoardMemberWithWriteAccess(this.userId, board)) {
|
|
tripCanary('calendar.import-without-write', { userId: this.userId });
|
|
throw new Meteor.Error('not-authorized', 'You do not have write access to this board.');
|
|
}
|
|
|
|
return importIcsCards(this.userId, boardId, listId, swimlaneId, icsText);
|
|
},
|
|
});
|
|
|
|
/**
|
|
* @operation import_ics
|
|
* @tag Cards
|
|
*
|
|
* @summary Import an iCalendar (.ics) file into a board as cards
|
|
*
|
|
* @description Parses the supplied iCalendar text and creates a card on the
|
|
* given board / list / swimlane for each VEVENT, populating each card's
|
|
* startAt (DTSTART) and dueAt (DTEND, or DTSTART when there is no DTEND) so the
|
|
* imported events appear on the Calendar and Gantt views. Requires write access
|
|
* to the board. See WeKan issue #6323. Import-only; two-way calendar sync is not
|
|
* provided.
|
|
*
|
|
* @param {string} boardId the board ID
|
|
* @param {string} swimlaneId the swimlane ID the cards are created in
|
|
* @param {string} listId the list ID the cards are created in
|
|
* @param {string} ics the raw .ics (iCalendar) file contents
|
|
* @return_type { created: number, cardIds: string[] }
|
|
*/
|
|
WebApp.handlers.post(
|
|
'/api/boards/:boardId/swimlanes/:swimlaneId/lists/:listId/ics',
|
|
async function(req, res) {
|
|
Authentication.checkLoggedIn(req.userId);
|
|
const { boardId, swimlaneId, listId } = req.params;
|
|
const board = await ReactiveCache.getBoard(boardId);
|
|
if (!board || !allowIsBoardMemberWithWriteAccess(req.userId, board)) {
|
|
res.writeHead(401, { 'Content-Type': 'application/json' });
|
|
res.end(JSON.stringify({ error: 'not-authorized' }));
|
|
return;
|
|
}
|
|
// ListLockBulkBleed: over REST a refusal is an attempt (403, recorded).
|
|
await assertListNotRefused(req.userId, board, listId, 'write', 'rest:ics-import');
|
|
const icsText = (req.body && (req.body.ics || req.body.icsText)) || '';
|
|
if (typeof icsText !== 'string' || icsText.trim() === '') {
|
|
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
res.end(JSON.stringify({ error: 'missing-ics', message: 'Provide the .ics file contents in the "ics" field.' }));
|
|
return;
|
|
}
|
|
const result = await importIcsCards(req.userId, boardId, listId, swimlaneId, icsText);
|
|
sendJsonResult(res, { code: 200, data: result });
|
|
},
|
|
);
|