mirror of
https://github.com/wekan/wekan.git
synced 2026-11-25 17:45:18 -05:00
From docs/Compliance/README.md's P3 list and row 2.2: - Emergency access: Admin Panel / People's user popup has "Emergency access" with a note before Impersonate. It is kept as reason emergency with the note (shown in the Impersonation Report), and every other administrator who can sign in gets an e-mail at once; a failed e-mail never stops the impersonation (models/lib/emergencyAccess.js). - The administrators' audit log is hash-chained: each row carries its place, the previous row's hash and its own. Its _id is its place, so two servers writing at once cannot both take it - the unique _id refuses the second, which takes the next. A daily check, and verifyAdminAuditChain, walk it from the oldest row kept and report an edited or removed row in Problems / Filesystem integrity (models/lib/auditChain.js). - REGISTRATION_MINIMUM_AGE: the sign-up form asks "I am at least N years old" and a password sign-up without it is refused; administrators' accounts and identity providers' are not asked, and nothing is stored (models/lib/registrationAge.js). On every platform and the Helm chart. - Records of processing (draft) in Admin Panel / Settings / Legal pages: every collection holding personal data, why, how long with this server's values, and the outside services this server really uses, as Markdown to complete (models/lib/ropaDraft.js). Seven new strings, translated in every language. Low confidence: chr, dz, bo, gv, ak, ay, bm, ee, ff, fj, gn, haw, bua, cv, ba, csb, ace, bi, fur, an, ast-ES, co, fo, hsb, gd, ht, bho, as, iu, kl, kw, ks, nah, rup, sah, lld, szl, sm, ss, nd, qu, om, pap, lg, rn, rw, nso, st, sn, ny, mai, kok, sc, scn, nap, mg, la, ig, ky, ja-HI, tig, tlh, vo, ve-PP, wal, zgh, uz-AR, to, tpi, ts, tn, ve, wa, wa-RR, wo, wuu-Hans, yi, yo, tk_TM, ug, tt, ti, oc, rm, sd, ps. The wrong-language catalog values the translators saw are in TODO.md. Thanks to xet7 !
64 lines
2.9 KiB
JavaScript
64 lines
2.9 KiB
JavaScript
'use strict';
|
|
|
|
// P3 (docs/Compliance/README.md): the administrators' audit log is
|
|
// hash-chained, and Admin Panel / Problems / Integrity says where it breaks.
|
|
// Run: node --test tests/auditChain.test.cjs
|
|
|
|
const { test } = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
|
|
const ROOT = path.join(__dirname, '..');
|
|
const read = rel => fs.readFileSync(path.join(ROOT, rel), 'utf8');
|
|
const C = require('../models/lib/auditChain');
|
|
|
|
function chain(n) {
|
|
const rows = [];
|
|
for (let i = 0; i < n; i += 1) {
|
|
rows.push(C.chainedRow({ at: new Date(Date.UTC(2026, 10, 24, 0, i)), actorId: 'a1', actorUsername: 'root',
|
|
method: 'setPassword', args: '["[redacted]","u1"]', ok: true, ip: '::1' }, rows[rows.length - 1]));
|
|
}
|
|
return rows;
|
|
}
|
|
|
|
test('each row follows the one before it, with the _id its place gives it', () => {
|
|
const rows = chain(3);
|
|
assert.deepEqual(rows.map(r => r.seq), [1, 2, 3]);
|
|
assert.equal(rows[0].prevHash, C.GENESIS);
|
|
assert.equal(rows[1].prevHash, rows[0].hash);
|
|
assert.equal(rows[2]._id, 'audit-000000000003');
|
|
assert.match(rows[0].hash, /^[0-9a-f]{64}$/);
|
|
assert.deepEqual(C.verifyChain(rows), { checked: 3, ok: true, broken: [] });
|
|
});
|
|
|
|
test('negative: an edited row, a row removed from the middle and a broken link are each found', () => {
|
|
const edited = chain(4);
|
|
edited[1] = { ...edited[1], actorUsername: 'someone-else' };
|
|
assert.deepEqual(C.verifyChain(edited).broken, [{ seq: 2, reason: 'changed' }]);
|
|
const removed = chain(4);
|
|
removed.splice(2, 1);
|
|
assert.deepEqual(C.verifyChain(removed).broken, [{ seq: 3, reason: 'missing' }]);
|
|
const relinked = chain(3);
|
|
const forged = C.chainedRow({ at: new Date(), actorId: 'x', method: 'm', ok: true }, { seq: 1, hash: 'f'.repeat(64) });
|
|
assert.deepEqual(C.verifyChain([relinked[0], forged]).broken, [{ seq: 2, reason: 'link' }]);
|
|
});
|
|
|
|
test('the retention removing the oldest rows does not break it', () => {
|
|
const rows = chain(5).slice(2);
|
|
assert.equal(C.verifyChain(rows).ok, true);
|
|
});
|
|
|
|
test('every audit row is appended to the chain; a race takes the next place; the check reports to Integrity', () => {
|
|
assert.match(read('server/adminAudit.js'), /await require\('\/server\/lib\/auditChainAppend'\)\.appendAuditRow\(doc\)/);
|
|
assert.match(read('server/lib/adminRouteAudit.js'), /appendAuditRow\(doc\)/);
|
|
const append = read('server/lib/auditChainAppend.js');
|
|
assert.match(append, /if \(!isDuplicate\(e\)\) throw e;/, 'only a taken place is retried');
|
|
assert.match(append, /stream: 'integrity', severity: 'high', category: 'audit-log'/);
|
|
assert.match(append, /foldEventFireAndForget\(/, 'a summarised problem, not a row per check');
|
|
// No other writer of the audit log goes around the chain.
|
|
for (const f of ['server/adminAudit.js', 'server/lib/adminRouteAudit.js']) {
|
|
assert.doesNotMatch(read(f), /AdminAuditLog\.insertAsync\(/, f);
|
|
}
|
|
});
|