MCPcopy Create free account
hub / github.com/garrytan/gstack / logAttempt

Function logAttempt

browse/src/security.ts:512–527  ·  view source on GitHub ↗
(record: AttemptRecord)

Source from the content-addressed store, hash-verified

510 * Returns true if the local write succeeded.
511 */
512export function logAttempt(record: AttemptRecord): boolean {
513 // Fire telemetry first, async — even if local write fails, we still want
514 // the event reported (it goes to a different directory anyway).
515 reportAttemptTelemetry(record);
516 try {
517 mkdirSecure(SECURITY_DIR);
518 rotateIfNeeded();
519 const line = JSON.stringify(record) + '\n';
520 appendSecureFile(ATTEMPTS_LOG, line);
521 return true;
522 } catch (err) {
523 // Non-fatal. Log to stderr for debugging but don't block.
524 console.error('[security] logAttempt write failed:', (err as Error).message);
525 return false;
526 }
527}
528
529// ─── Cross-process session state ─────────────────────────────
530

Callers 1

security.test.tsFile · 0.90

Calls 4

mkdirSecureFunction · 0.90
appendSecureFileFunction · 0.90
reportAttemptTelemetryFunction · 0.85
rotateIfNeededFunction · 0.70

Tested by

no test coverage detected