mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 20:45:00 -05:00
#3022 (decided 2026-10-14): a site admin builds named roles in Admin Panel / People / Roles from the capability matrix - sees all cards, comments, edits, moves cards, invites - and a board admin gives one to a member in the same popup as the built-in roles. Board admin stays built-in. Every permission check asks boardRoleCapabilities, which answers a custom role from the role; the member's built-in flags carry the strongest built-in role that grants nothing more (fallbackRoleFor, checked for every combination), so code reading a flag never grants more, and a deleted role leaves exactly that. Where a role is asked by name (hasWorker, isCommentOnly, ...) a custom role reads as the built-in role that does what it does; commenting is asked as a capability everywhere. Invites, REST whole-board reads, imports (a foreign custom role is dropped) and member mapping (all eight flags now, not four) follow it. The six new strings are translated in all 234 locales. #4178 (decided 2026-10-14): a team or organization that gives board memberships takes them away again when the user leaves it - only those: each records where it came from (grantedBy), a direct membership is never touched, a board admin is kept, and a board admin's own add or removal is final. Teams through user edits, LDAP, OIDC and the board sidebar; organizations where they propagate members. Also: the Roles Status table gets a Move cards column; the comment form, reactions and chat ask the comment capability (a No comments member was offered reactions the server refused). Tests: customBoardRoles and groupBoardMembership node suites, and the runtime suites (9 passing) against a real database. Thanks to xet7 and mfnalex ! Fixes #3022, Fixes #4178.
122 lines
5.3 KiB
JavaScript
122 lines
5.3 KiB
JavaScript
'use strict';
|
|
|
|
// AssignedBleed — GHSA-f396-42fx-vr88, CWE-863.
|
|
// REST write authorization duplicated role flags and omitted Only Assigned
|
|
// Comment. The shared check and both attachment variants now read the canonical
|
|
// role capability table instead.
|
|
// Run: node tests/assignedbleed.test.cjs
|
|
|
|
const assert = require('assert');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const { roleCan } = require('../models/lib/boardRoleCapabilities');
|
|
|
|
const root = path.resolve(__dirname, '..');
|
|
const read = rel => fs.readFileSync(path.join(root, rel), 'utf8');
|
|
const authentication = read('server/authentication.js');
|
|
const attachmentMethod = read('server/attachmentApi.js');
|
|
const attachmentRest = read('server/routes/attachmentApi.js');
|
|
const cards = read('server/models/cards.js');
|
|
|
|
let passed = 0;
|
|
function test(name, fn) { fn(); passed += 1; console.log(' ok -', name); }
|
|
|
|
const writeCheck = authentication.slice(
|
|
authentication.indexOf('async checkBoardWriteAccess('),
|
|
authentication.indexOf('// Helper function. Will throw an error if the user is not a board admin.'),
|
|
);
|
|
|
|
console.log('assignedbleed:');
|
|
|
|
test('Only Assigned Comment has no canonical write capability', () => {
|
|
assert.strictEqual(roleCan('comment-assigned-only', 'write'), false);
|
|
});
|
|
|
|
test('the shared REST write check asks the canonical capability helper', () => {
|
|
assert.match(writeCheck,
|
|
/allowIsBoardMemberWithWriteAccess\(userId, board\)/);
|
|
});
|
|
|
|
test('negative: the shared check contains no hand-written role flags', () => {
|
|
const executable = writeCheck
|
|
.replace(/\/\*[\s\S]*?\*\//g, '')
|
|
.replace(/^\s*\/\/.*$/gm, '');
|
|
for (const flag of [
|
|
'isNoComments', 'isCommentOnly', 'isCommentAssignedOnly', 'isWorker',
|
|
'isReadOnly', 'isReadAssignedOnly',
|
|
]) {
|
|
assert.ok(!executable.includes(flag), flag);
|
|
}
|
|
});
|
|
|
|
test('all card mutation routes continue through the repaired shared check', () => {
|
|
const calls = cards.match(/Authentication\.checkBoardWriteAccess\(/g) || [];
|
|
assert.ok(calls.length >= 10, `found ${calls.length} card write checks`);
|
|
});
|
|
|
|
test('both attachment APIs use the canonical capability too', () => {
|
|
for (const [name, source] of [
|
|
['Meteor attachment methods', attachmentMethod],
|
|
['REST attachment routes', attachmentRest],
|
|
]) {
|
|
const helper = source.slice(
|
|
source.indexOf('async function userHasBoardWriteAccess('),
|
|
source.indexOf('\n}\n', source.indexOf('async function userHasBoardWriteAccess(')) + 2,
|
|
);
|
|
assert.match(helper, /allowIsBoardMemberWithWriteAccess\(userId, board\)/,
|
|
name);
|
|
assert.ok(!helper.includes('isCommentAssignedOnly'), name);
|
|
}
|
|
});
|
|
|
|
test('denied shared and attachment writes trip the AssignedBleed canary', () => {
|
|
// The shared check picks the canary through writeRefusalCanary(): a
|
|
// read-only member is ReadOnlyBleed's (2026-10-02), everyone else this one.
|
|
assert.match(writeCheck, /tripCanary\(writeRefusalCanary\(board, userId\), \{ userId \}\)/);
|
|
assert.match(authentication,
|
|
/return member && member\.isReadOnly \? 'board\.readonly-write' : 'board\.write-without-capability';/);
|
|
for (const source of [attachmentMethod, attachmentRest]) {
|
|
assert.match(source,
|
|
/tripCanary\('board\.write-without-capability', \{ userId \}\)/);
|
|
}
|
|
});
|
|
|
|
test('all non-writing roles are denied by the shared decision', () => {
|
|
for (const role of [
|
|
'comment-only', 'comment-assigned-only', 'worker', 'read-only',
|
|
'read-assigned-only',
|
|
]) {
|
|
assert.strictEqual(roleCan(role, 'write'), false, role);
|
|
}
|
|
});
|
|
|
|
test('negative: legitimate writing roles retain REST write access', () => {
|
|
for (const role of ['board-admin', 'normal', 'normal-assigned-only', 'no-comments']) {
|
|
assert.strictEqual(roleCan(role, 'write'), true, role);
|
|
}
|
|
});
|
|
|
|
// AssignedBleed sibling (2026-10-02): the REST read check let assigned-only
|
|
// members through to routes that return the whole board. Drive the real
|
|
// check: they are refused; an ordinary member still reads (negative).
|
|
test('REST board-wide reads refuse assigned-only members (checkBoardAccess)', () => {
|
|
const auth = require('fs').readFileSync(require('path').join(__dirname, '..', 'server/authentication.js'), 'utf8');
|
|
const at = auth.indexOf('async checkBoardAccess(userId, boardId) {');
|
|
const body = auth.slice(at, auth.indexOf('\n },', at));
|
|
// Since #3022 the decision is the pure memberReadsWholeBoard
|
|
// (models/lib/boardReadAccess.js), which also knows custom roles; the route
|
|
// must still ask it for the caller's own entry.
|
|
assert.match(body, /const normalAccess = board\.members\.some\(e => memberReadsWholeBoard\(e, userId\)\);/);
|
|
const { memberReadsWholeBoard } = require('../models/lib/boardReadAccess');
|
|
const allowed = (b, userId) => b.members.some(e => memberReadsWholeBoard(e, userId));
|
|
const board = flags => ({ members: [{ userId: 'u', isActive: true, ...flags }] });
|
|
for (const flags of [{ isNormalAssignedOnly: true }, { isCommentAssignedOnly: true }, { isReadAssignedOnly: true }]) {
|
|
assert.strictEqual(allowed(board(flags), 'u'), false, JSON.stringify(flags));
|
|
}
|
|
assert.strictEqual(allowed(board({}), 'u'), true, 'a normal member reads');
|
|
assert.strictEqual(allowed(board({ isAdmin: true }), 'u'), true);
|
|
assert.strictEqual(allowed(board({ isActive: false }), 'u'), false, 'a removed member does not');
|
|
});
|
|
|
|
console.log(`\nassignedbleed: ${passed} tests passed`);
|