pentesting 0.7.34 → 0.7.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +56 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5492,6 +5492,51 @@ var SessionManager = class extends EventEmitter5 {
|
|
|
5492
5492
|
return [];
|
|
5493
5493
|
}
|
|
5494
5494
|
}
|
|
5495
|
+
/**
|
|
5496
|
+
* Clean up old sessions (older than maxAgeDays)
|
|
5497
|
+
*/
|
|
5498
|
+
async cleanupOldSessions(maxAgeDays = 7) {
|
|
5499
|
+
const sessions = await this.listSessions();
|
|
5500
|
+
const now = Date.now();
|
|
5501
|
+
const maxAgeMs = maxAgeDays * 24 * 60 * 60 * 1e3;
|
|
5502
|
+
let deletedCount = 0;
|
|
5503
|
+
for (const session of sessions) {
|
|
5504
|
+
const sessionAge = now - new Date(session.updatedAt).getTime();
|
|
5505
|
+
if (sessionAge > maxAgeMs && session.status !== "active") {
|
|
5506
|
+
const deleted = await this.deleteSession(session.id);
|
|
5507
|
+
if (deleted) {
|
|
5508
|
+
deletedCount++;
|
|
5509
|
+
}
|
|
5510
|
+
}
|
|
5511
|
+
}
|
|
5512
|
+
if (deletedCount > 0) {
|
|
5513
|
+
this.emit("sessions_cleaned", { count: deletedCount });
|
|
5514
|
+
}
|
|
5515
|
+
return deletedCount;
|
|
5516
|
+
}
|
|
5517
|
+
/**
|
|
5518
|
+
* Clean up empty or corrupted sessions
|
|
5519
|
+
*/
|
|
5520
|
+
async cleanupInvalidSessions() {
|
|
5521
|
+
await this.initialize();
|
|
5522
|
+
let deletedCount = 0;
|
|
5523
|
+
try {
|
|
5524
|
+
const entries = await fs3.readdir(this.sessionsDir, { withFileTypes: true });
|
|
5525
|
+
for (const entry of entries) {
|
|
5526
|
+
if (entry.isDirectory()) {
|
|
5527
|
+
const metadataPath = path3.join(this.sessionsDir, entry.name, "metadata.json");
|
|
5528
|
+
try {
|
|
5529
|
+
await fs3.access(metadataPath);
|
|
5530
|
+
} catch {
|
|
5531
|
+
await fs3.rm(path3.join(this.sessionsDir, entry.name), { recursive: true });
|
|
5532
|
+
deletedCount++;
|
|
5533
|
+
}
|
|
5534
|
+
}
|
|
5535
|
+
}
|
|
5536
|
+
} catch {
|
|
5537
|
+
}
|
|
5538
|
+
return deletedCount;
|
|
5539
|
+
}
|
|
5495
5540
|
/**
|
|
5496
5541
|
* Get most recent session
|
|
5497
5542
|
*/
|
|
@@ -6624,7 +6669,17 @@ var App = ({ autoApprove = false, target }) => {
|
|
|
6624
6669
|
}
|
|
6625
6670
|
});
|
|
6626
6671
|
});
|
|
6627
|
-
|
|
6672
|
+
sessionManager2.cleanupOldSessions(7).then((count) => {
|
|
6673
|
+
if (count > 0) {
|
|
6674
|
+
console.log(`[Session] Cleaned up ${count} old sessions`);
|
|
6675
|
+
}
|
|
6676
|
+
});
|
|
6677
|
+
sessionManager2.cleanupInvalidSessions().then((count) => {
|
|
6678
|
+
if (count > 0) {
|
|
6679
|
+
console.log(`[Session] Removed ${count} invalid sessions`);
|
|
6680
|
+
}
|
|
6681
|
+
});
|
|
6682
|
+
}, [sessionManager2]);
|
|
6628
6683
|
const startTimeRef = useRef(0);
|
|
6629
6684
|
const timerRef = useRef(null);
|
|
6630
6685
|
const addMessage = useCallback((type, content, duration) => {
|