mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
Per correction: use only the existing WeKan database via Meteor JavaScript
queries (works on FerretDB and MongoDB); do not create files/DBs under
WRITABLE_PATH; and have FerretDB report problems to WeKan rather than writing
itself.
- models/eventLog.js: one `eventlog` collection (stream: security|speed|tests).
- server/lib/{securityLog,speedLog,testLog}.js: thin wrappers that insert one
document via EventLog.insertAsync (fire-and-forget, never throw).
- models/lib/securityLogFormat.js slimmed to just sanitizeDetail; remove the
node:sqlite event store (server/lib/eventStore.js) and all file/path/schema
helpers.
- Add a Tests stream: log anything that would fail an existing WeKan test.
- Design docs (WeKan.md, FerretDB.md) rewritten: DB-collection storage, grouped
counts for the summary, Admin Reports read the collection, and FerretDB reports
problems to WeKan which records them (no FerretDB DB/file writes).
- tests/securityLog.test.cjs updated (sanitizer + catalog + collection wiring +
no-filesystem guards); verified via Python mirror.
38 lines
1.6 KiB
JavaScript
38 lines
1.6 KiB
JavaScript
// ============================================================================
|
|
// WeKan test-failure logger (docs/Security/Remediation/WeKan.md §9b)
|
|
// ----------------------------------------------------------------------------
|
|
// Logs "anything that would fail some existing WeKan test": one document per
|
|
// FAILING test (passing tests are not logged) in the existing WeKan database
|
|
// (models/eventLog.js, stream:'tests') via a normal Meteor JavaScript query.
|
|
// Surfaced in Admin Panel → Reports → Tests. Best-effort, never throws.
|
|
// Server-only.
|
|
// ============================================================================
|
|
|
|
import EventLog from '/models/eventLog';
|
|
const { sanitizeDetail } = require('/models/lib/securityLogFormat');
|
|
|
|
// Record one FAILING test. Never throws.
|
|
// recordFailure({ suite:'unit', test:'tests/foo.test.cjs:does X', message:'expected a to equal b' })
|
|
export function recordFailure(evt = {}) {
|
|
try {
|
|
const sev = { security: 'high', e2e: 'low', unit: 'medium' }[evt.suite] || 'medium';
|
|
const doc = {
|
|
stream: 'tests',
|
|
at: new Date(),
|
|
severity: evt.severity || sev,
|
|
category: evt.category || 'test-failure',
|
|
bleed: evt.bleed || 'TestBleed',
|
|
action: evt.action || 'failed',
|
|
source: evt.test || evt.source || evt.suite || 'test',
|
|
cwe: '',
|
|
detail: sanitizeDetail(evt.message || evt.detail),
|
|
};
|
|
const p = EventLog.insertAsync(doc);
|
|
if (p && typeof p.catch === 'function') p.catch(() => {});
|
|
} catch (e) {
|
|
if (process.env.DEBUG === 'true') console.warn('testLog.recordFailure failed:', e && e.message);
|
|
}
|
|
}
|
|
|
|
export default { recordFailure };
|