mirror of
https://github.com/wekan/wekan.git
synced 2026-11-25 04:49:41 -05:00
docs/Compliance/README.md WP-11 (rows 4.2 and 4.3 b):
- Admin Panel / People / Audit log has a Data access tab: who downloaded
what - a board as JSON, CSV, Excel, PDF or ZIP, a chart, a card, every
board, a person's data, an Admin Panel list - one row per person, day,
kind and target with a count, the first and last time and the last
address, never a row per download. A raw middleware in front of every
route (server/lib/dataAccessLog.js) counts each export that answers 200,
and a test fails when an export route is not in its list. Kept as the
audit log (ADMIN_AUDIT_RETENTION_DAYS); erasing an account removes its
username and address from it. Export CSV on the tab.
- AUDIT_LOG_STDOUT=json writes every audit row, security problem and data
access also to stdout as one JSON line ({"wekan":"audit"|"security"|
"data-access", ...}), with only the fields the Admin Panel shows - the
arguments as stored, already redacted (models/lib/auditStdout.js). On
every platform's settings, the snap and the Helm chart.
- The admin CSV exports obey Admin Panel's switch that turns all export
off.
Five new strings, translated in every language. Low confidence: ace, ak,
ay, bi, bm, bo, bua, chr, csb, cv, dz, ee, ff, fj, gn, gv, haw, fur, co, ba,
bho, as, br, an, ast-ES, ha, ht, fo, iu, kl, ks, kw, nah, lld, rup, qu, sah,
se, szl, nap, scn, sc, rm, pap, lg, rn, nd, ss, nso, st, sn, ny, om, mai,
kok, la, sm, mi, tig, ve-PP, vo, wal, tlh, zgh, uz-AR, to, tpi, ts, ve, wa,
wa-RR, wo, yo, yi.
Thanks to xet7 !
72 lines
3.1 KiB
JavaScript
72 lines
3.1 KiB
JavaScript
'use strict';
|
|
|
|
// The data-access log (docs/Compliance/README.md WP-11, row 4.2; [HIPAA]
|
|
// § 164.312(b), [GDPR] Art. 32(1)(b) and 5(2), [CRA] Annex I Part I(2)(l)):
|
|
// who downloaded what - a board, every board, a person's data, an Admin Panel
|
|
// list. Admin Panel / People / Audit log / Data access shows it.
|
|
//
|
|
// One row per person, day, kind of export and target, with a count - never a
|
|
// row per download (CLAUDE.md: a summary, never a row per event), so a
|
|
// script pulling a board every minute is one row that says 1440, not 1440
|
|
// rows. Written by server/lib/dataAccessLog.js for every export route that
|
|
// answers 200, and kept as long as the audit log (ADMIN_AUDIT_RETENTION_DAYS).
|
|
//
|
|
// Pure: tests/dataAccessLog.test.cjs.
|
|
|
|
// The export routes, most specific first: [pattern, kind, which match is the target].
|
|
const ROUTES = Object.freeze([
|
|
[/^\/api\/boards\/([^/]+)\/lists\/[^/]+\/cards\/([^/]+)\/exportPDF$/, 'card-pdf', 2],
|
|
[/^\/api\/boards\/([^/]+)\/charts\/[^/]+\/exportExcel$/, 'chart-excel', 1],
|
|
[/^\/api\/boards\/([^/]+)\/charts\/[^/]+\/exportPDF$/, 'chart-pdf', 1],
|
|
[/^\/api\/boards\/([^/]+)\/export\/csv$/, 'board-csv', 1],
|
|
[/^\/api\/boards\/([^/]+)\/exportExcel$/, 'board-excel', 1],
|
|
[/^\/api\/boards\/([^/]+)\/exportPDF$/, 'board-pdf', 1],
|
|
[/^\/api\/boards\/([^/]+)\/exportZip$/, 'board-zip', 1],
|
|
[/^\/api\/boards\/([^/]+)\/export$/, 'board-json', 1],
|
|
[/^\/api\/export-all-boards\/([^/]+)$/, 'all-boards', 1],
|
|
[/^\/api\/admin\/export\/([^/]+)$/, 'admin-csv', 1],
|
|
[/^\/api\/user\/export$/, 'personal-data', 0],
|
|
]);
|
|
|
|
const MAX_TARGET = 100;
|
|
|
|
const clean = value => String(value || '').replace(/[^\w.@:-]/g, '').slice(0, MAX_TARGET);
|
|
|
|
// Which export a request is, or null. The personal-data export's target is
|
|
// the account it was for: the one asked for, or the requester's own ('self').
|
|
function classifyExport(pathname, query = {}) {
|
|
const path = String(pathname || '').replace(/\/+$/, '');
|
|
for (const [re, kind, group] of ROUTES) {
|
|
const m = re.exec(path);
|
|
if (!m) continue;
|
|
const target = group ? m[group] : (typeof query.userId === 'string' && query.userId ? query.userId : 'self');
|
|
return { kind, target: clean(decodeURIComponentSafe(target)) };
|
|
}
|
|
return null;
|
|
}
|
|
|
|
function decodeURIComponentSafe(value) {
|
|
try { return decodeURIComponent(value); } catch (e) { return value; }
|
|
}
|
|
|
|
function dayOf(date) {
|
|
return new Date(date).toISOString().slice(0, 10);
|
|
}
|
|
|
|
// The one row this download is counted in: its id names the person, the day,
|
|
// the kind and the target, so the same download on the same day adds to it.
|
|
function foldUpdate({ userId, username, ip, kind, target, at = new Date() }) {
|
|
const day = dayOf(at);
|
|
const who = clean(userId) || '-';
|
|
return {
|
|
selector: { _id: `${day}:${who}:${kind}:${target || '-'}` },
|
|
modifier: {
|
|
$inc: { count: 1 },
|
|
$set: { at, username: String(username || '').slice(0, 200), ip: String(ip || '').slice(0, 100) },
|
|
$setOnInsert: { day, userId: userId || null, kind, target: target || '', firstAt: at },
|
|
},
|
|
};
|
|
}
|
|
|
|
module.exports = { ROUTES, classifyExport, foldUpdate, dayOf };
|