mirror of
https://github.com/wekan/wekan.git
synced 2026-11-20 21:45:01 -05:00
A developer laptop with many programs open showed in Admin Panel / Problems / Memory usage: "RamBleed, high, high RAM usage started (>= 90%): RAM 16.1/30.9 GB (52%), swap 18.7/30.9 GB (60%)". Swap at or above 25% started a high-memory period by itself, made it high severity, and the text still said ">= 90%". Idle pages in swap while RAM is free are not pressure. - Swap now counts only while RAM is also at or above the low threshold (80%), and a period ends when RAM is back under it. - The start row says what started it: (RAM >= 90%) or (swap >= 25% with RAM >= 80%). Only RAM at 95% or more is high severity. - The RAM, CPU, disk and speed monitors named their rows like Hall of Fame entries (RamBleed, CpuBleed, DiskBleed, SlowBleed) with CWE-400. They are HighRamUsage, HighCpuUsage, HighDiskUsage and SlowRequest now, without a CWE, and stored rows are renamed once at startup. tests/ramHighTracker.test.cjs replays the laptop's numbers as a negative case; tests/resourceStreamNames.test.cjs pins the names. Thanks to xet7 !
51 lines
2.4 KiB
JavaScript
51 lines
2.4 KiB
JavaScript
// ============================================================================
|
|
// WeKan speed / performance event logger (docs/Security/Remediation/WeKan.md §9)
|
|
// ----------------------------------------------------------------------------
|
|
// Records performance problems NOT auto-remediated (slow method/request,
|
|
// oversized publication, big board, repeated full scans) — and problems FerretDB
|
|
// reports back to WeKan — as documents in the existing WeKan database
|
|
// (models/eventLog.js, stream:'speed') via a normal Meteor JavaScript query.
|
|
// Best-effort, never throws. Server-only.
|
|
// ============================================================================
|
|
|
|
import EventLog from '/models/eventLog';
|
|
// One row per problem, not per event - see server/lib/eventLogFold.js.
|
|
import { foldEventFireAndForget } from '/server/lib/eventLogFold';
|
|
import { Meteor } from 'meteor/meteor';
|
|
import { renameLegacyRows } from '/server/lib/resourceLog';
|
|
|
|
// Speed rows stored under the old name join the new one (resourceLog.js).
|
|
if (Meteor.isServer) Meteor.startup(() => { renameLegacyRows('speed', 'SlowBleed', 'SlowRequest'); });
|
|
const { sanitizeDetail } = require('/models/lib/securityLogFormat');
|
|
|
|
// Record one performance event. Never throws.
|
|
// record({ category:'slow-method', severity:'medium', source:'ddp.method:cardsLoad',
|
|
// detail:'2.4s > 2s threshold' })
|
|
// FerretDB-reported problems use source 'ferretdb'/'sqlite.*' (WeKan saves them here).
|
|
export function record(evt = {}) {
|
|
try {
|
|
const doc = {
|
|
stream: 'speed',
|
|
at: new Date(),
|
|
severity: evt.severity || 'low',
|
|
category: evt.category || 'performance',
|
|
// A slow request, not a vulnerability: named for what happened
|
|
// (resourceLog.js renames the rows stored as 'SlowBleed').
|
|
bleed: evt.bleed || 'SlowRequest',
|
|
action: evt.action || 'detected',
|
|
source: evt.source || '',
|
|
cwe: evt.cwe || '',
|
|
detail: sanitizeDetail(evt.detail),
|
|
};
|
|
if (evt.userId || evt.userid) doc.userId = String(evt.userId || evt.userid);
|
|
if (evt.username) doc.username = String(evt.username).slice(0, 100);
|
|
if (evt.ip) doc.ip = String(evt.ip).slice(0, 64);
|
|
if (evt.location) doc.location = evt.location;
|
|
foldEventFireAndForget(doc, 'speedLog');
|
|
} catch (e) {
|
|
if (process.env.DEBUG === 'true') console.warn('speedLog.record failed:', e && e.message);
|
|
}
|
|
}
|
|
|
|
export default { record };
|