Implement managed browser security, individual agents and observability
This commit is contained in:
1 parent
ff482ebe23
commit
ea448de2d4
172 files changed
+5404
-347
No files matched your search
@@ -14,7 +14,7 @@ export function pruneAuditEvents(store,{days,limit=500,exportedThrough,now=Date.
|
||||
const protectedCase=hasCases?'AND NOT EXISTS (SELECT 1 FROM incident_cases c WHERE c.event_id=e.id)':'';
|
||||
const hasEvidence=!!db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='protected_evidence'").get();
|
||||
const protectedEvidence=hasEvidence?'AND NOT EXISTS (SELECT 1 FROM protected_evidence p WHERE p.source_event_id=e.id)':'';
|
||||
const candidates=db.prepare(`SELECT e.id FROM events e WHERE e.time<? AND e.id<=? ${protectedCase} ${protectedEvidence} ORDER BY e.id LIMIT ?`).all(cutoff,exportedThrough,options.limit);
|
||||
const candidates=db.prepare(`SELECT e.id FROM events e WHERE e.kind!='audit.retention-applied' AND e.time<? AND e.id<=? ${protectedCase} ${protectedEvidence} ORDER BY e.id LIMIT ?`).all(cutoff,exportedThrough,options.limit);
|
||||
const ids=new Set(candidates.map(r=>r.id));
|
||||
// A batch boundary must not leave a retained correlation pointing at an event
|
||||
// we removed. It is safe to remove children first and their source next run.
|
||||
@@ -26,11 +26,13 @@ export function pruneAuditEvents(store,{days,limit=500,exportedThrough,now=Date.
|
||||
const selected=[...ids];
|
||||
if(!dryRun&&selected.length){
|
||||
const placeholders=selected.map(()=>'?').join(',');
|
||||
store.event(null,'audit.retention-applied',{count:selected.length,retentionDays:days,exportedThrough});
|
||||
const retentionEventId=db.prepare('SELECT max(id) AS id FROM events').get().id;
|
||||
store.auditIntegrity.authorizePrune(selected,retentionEventId);
|
||||
db.prepare(`DELETE FROM alerts WHERE event_id IN (${placeholders})`).run(...selected);
|
||||
db.prepare(`DELETE FROM events WHERE id IN (${placeholders})`).run(...selected);
|
||||
// Device event UUIDs deliberately survive: removing them would let a replay
|
||||
// recreate expired events. No signing/history/enrollment state is pruned.
|
||||
store.event(null,'audit.retention-applied',{count:selected.length,retentionDays:days,exportedThrough});
|
||||
}
|
||||
db.exec('RELEASE audit_retention');
|
||||
return {dryRun,cutoff,eligible:selected.length,exportedThrough,incidentEvidencePreserved:true,deduplicationPreserved:true};
|
||||
|
||||
Reference in new issue
Block a user