mirror of
https://github.com/wekan/wekan.git
synced 2026-11-25 04:49:41 -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 !
47 lines
2.2 KiB
JavaScript
47 lines
2.2 KiB
JavaScript
// Appending to the hash-chained audit log (models/lib/auditChain.js): read the
|
|
// newest chained row, write the next one with the _id its seq gives it, and
|
|
// if another server took that place first - the unique _id refuses it - read
|
|
// again and take the next. Never throws into the action being audited: after
|
|
// a few attempts the row is written unchained rather than lost.
|
|
import { AdminAuditLog } from '/server/adminAudit';
|
|
|
|
const { chainedRow } = require('/models/lib/auditChain');
|
|
|
|
const ATTEMPTS = 8;
|
|
const isDuplicate = e => e && (e.code === 11000 || /E11000|duplicate key/i.test(String(e.message || e.errmsg || '')));
|
|
|
|
export async function appendAuditRow(doc) {
|
|
for (let i = 0; i < ATTEMPTS; i += 1) {
|
|
// eslint-disable-next-line no-await-in-loop
|
|
const last = await AdminAuditLog.findOneAsync({ seq: { $exists: true } }, { sort: { seq: -1 }, fields: { seq: 1, hash: 1 } });
|
|
const row = chainedRow(doc, last);
|
|
try {
|
|
// eslint-disable-next-line no-await-in-loop
|
|
await AdminAuditLog.insertAsync(row);
|
|
return row;
|
|
} catch (e) {
|
|
if (!isDuplicate(e)) throw e;
|
|
}
|
|
}
|
|
console.error('[admin-audit] could not take a place in the chain; writing the row unchained');
|
|
return AdminAuditLog.insertAsync(doc);
|
|
}
|
|
|
|
// Admin Panel / Problems / Integrity: the chain, verified from the oldest row
|
|
// still kept. A break is one summarised problem in the integrity stream.
|
|
export async function verifyAuditChain() {
|
|
const { verifyChain } = require('/models/lib/auditChain');
|
|
const rows = await AdminAuditLog.find({ seq: { $exists: true } }, { sort: { seq: 1 } }).fetchAsync();
|
|
const unchained = await AdminAuditLog.find({ seq: { $exists: false } }).countAsync();
|
|
const result = { ...verifyChain(rows), unchained };
|
|
if (!result.ok) {
|
|
try {
|
|
require('/server/lib/eventLogFold').foldEventFireAndForget({
|
|
stream: 'integrity', severity: 'high', category: 'audit-log', action: 'detected', source: 'admin-audit-chain',
|
|
detail: `The administrators' audit log chain is broken: ${result.broken.map(b => `row ${b.seq} ${b.reason}`).join(', ')}.`,
|
|
}, 'adminAuditChain');
|
|
} catch (e) { /* the verification result matters more than its record */ }
|
|
}
|
|
return result;
|
|
}
|