feat(audit,backup,cli): upgrade Audit Log, harden async Backup + scheduled backups & CLI tools
This commit is contained in:
parent
1b2e425a00
commit
9a27525def
8 changed files with 1590 additions and 222 deletions
|
|
@ -17,6 +17,7 @@ import { MonitoringService } from './monitoring/monitoring-service.js';
|
|||
import { ProbeRunner } from './monitoring/probes.js';
|
||||
import { AuditService } from './security/audit.js';
|
||||
import { AuthService } from './security/auth.js';
|
||||
import { BackupScheduler } from './security/backup-scheduler.js';
|
||||
import {
|
||||
DEFAULT_TRUSTED_PROXY_CIDRS,
|
||||
RateLimiter,
|
||||
|
|
@ -88,6 +89,7 @@ export interface GCoordinatorInstance {
|
|||
customSystemsEngine: CustomSystemsEngine;
|
||||
serverInspector: ServerInspector;
|
||||
monitoringService: MonitoringService;
|
||||
backupScheduler: BackupScheduler;
|
||||
transferEngine: TransferEngine;
|
||||
workflowEngine: WorkflowEngine;
|
||||
broadcastService: BroadcastService;
|
||||
|
|
@ -231,6 +233,15 @@ export async function createGCoordinatorServer(
|
|||
wsHub,
|
||||
auditService,
|
||||
);
|
||||
const backupScheduler = new BackupScheduler(
|
||||
dataDir,
|
||||
db,
|
||||
configManager,
|
||||
vaultService,
|
||||
sftpService,
|
||||
auditService,
|
||||
getRuntimeLimits,
|
||||
);
|
||||
|
||||
wsHub.registerUpgradeHandler('/proxy/', (req, socket, head) => {
|
||||
tunnelManager.handleWsProxyUpgrade(req, socket, head);
|
||||
|
|
@ -319,11 +330,16 @@ export async function createGCoordinatorServer(
|
|||
app.use('/proxy', createProxyRouter({ authService, tunnelManager }));
|
||||
|
||||
const jsonParser = express.json({ limit: '2mb' });
|
||||
const backupJsonParser = express.json({ limit: '16mb' });
|
||||
app.use((req, res, next) => {
|
||||
if (req.path.endsWith('/sftp/upload')) {
|
||||
next();
|
||||
return;
|
||||
}
|
||||
if (req.path.startsWith('/api/backup/')) {
|
||||
backupJsonParser(req, res, next);
|
||||
return;
|
||||
}
|
||||
jsonParser(req, res, next);
|
||||
});
|
||||
|
||||
|
|
@ -356,9 +372,12 @@ export async function createGCoordinatorServer(
|
|||
customSystemsEngine.syncBackgroundChecks();
|
||||
workflowEngine.start();
|
||||
alertEngine.start();
|
||||
backupScheduler.start();
|
||||
auditService.pruneOlderThan(configManager.getSettings().auditRetentionDays);
|
||||
|
||||
vaultService.onSeal(() => {
|
||||
aiService.cancelAll();
|
||||
backupScheduler.stop();
|
||||
alertEngine.handlePanicLock();
|
||||
workflowEngine.handlePanicLock();
|
||||
broadcastService.cancelAll();
|
||||
|
|
@ -372,6 +391,7 @@ export async function createGCoordinatorServer(
|
|||
|
||||
vaultService.onPanicLock(() => {
|
||||
aiService.cancelAll();
|
||||
backupScheduler.stop();
|
||||
alertEngine.handlePanicLock();
|
||||
workflowEngine.handlePanicLock();
|
||||
broadcastService.cancelAll();
|
||||
|
|
@ -421,6 +441,7 @@ export async function createGCoordinatorServer(
|
|||
monitoringService.syncServers();
|
||||
customSystemsEngine.syncBackgroundChecks();
|
||||
workflowEngine.syncCronJobs();
|
||||
backupScheduler.sync();
|
||||
void tunnelManager.syncAutoStart();
|
||||
}
|
||||
});
|
||||
|
|
@ -461,6 +482,7 @@ export async function createGCoordinatorServer(
|
|||
monitoringService.syncServers();
|
||||
customSystemsEngine.syncBackgroundChecks();
|
||||
workflowEngine.syncCronJobs();
|
||||
backupScheduler.sync();
|
||||
void tunnelManager.syncAutoStart();
|
||||
},
|
||||
onVaultChanged: (snapshotReason) => {
|
||||
|
|
@ -480,18 +502,27 @@ export async function createGCoordinatorServer(
|
|||
configManager,
|
||||
auditService,
|
||||
stepUpGuard,
|
||||
getRuntimeLimits,
|
||||
backupScheduler,
|
||||
onRestored: async ({ inner, vaultKeyCandidate }) => {
|
||||
if (inner.vaultEnvelopeRaw !== null) {
|
||||
try {
|
||||
vaultService.reloadFromDisk(vaultKeyCandidate);
|
||||
} catch {
|
||||
// Keep existing runtime state untouched if backup vault used a different key
|
||||
// Avoid keeping an old runtime master key unlocked against a newly restored foreign vault
|
||||
vaultService.seal();
|
||||
vaultService.dropLocalKeyFile();
|
||||
}
|
||||
}
|
||||
knownHosts.replaceAllKnownHosts(inner.knownHosts);
|
||||
configManager.reloadAllFromDisk();
|
||||
sshPool.syncWithConfig();
|
||||
if (authService.isBootstrapped() && vaultService.isRuntimeReady) {
|
||||
backupScheduler.sync();
|
||||
if (
|
||||
authService.isBootstrapped() &&
|
||||
vaultService.isRuntimeReady &&
|
||||
configManager.getSettings().security.enableEmergencySecretsBackup
|
||||
) {
|
||||
authService.syncRecovery({ snapshotReason: 'backup-restore' });
|
||||
}
|
||||
wsHub.broadcastAll({
|
||||
|
|
@ -620,6 +651,7 @@ export async function createGCoordinatorServer(
|
|||
customSystemsEngine,
|
||||
serverInspector,
|
||||
monitoringService,
|
||||
backupScheduler,
|
||||
transferEngine,
|
||||
workflowEngine,
|
||||
broadcastService,
|
||||
|
|
@ -629,6 +661,7 @@ export async function createGCoordinatorServer(
|
|||
port: actualPort,
|
||||
async close() {
|
||||
aiService.close();
|
||||
backupScheduler.close();
|
||||
alertEngine.close();
|
||||
workflowEngine.close();
|
||||
broadcastService.cancelAll();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue