Adversarial audit 2026-08-16 (GLM-5.3 delegate, 2 rounds, 141 tool calls):
P0-1: Dashboard WebSocket (/api/v1/ws) dead on EVERY boot since DC-076.
server.js passed module exports (DependencyManager class, {AutoRestartManager}
namespace, SSLMonitor class) instead of createApp()'s live instances — first
.on() threw ERR_INVALID_ARG_TYPE, catch swallowed it. Fix: app.locals.ctx
exposed in src/app.js; server.js passes all 8 real EventEmitter instances.
P0-2: error.log corrupted since 2026-07-14. errorMiddleware called
logError(FILE, SIZE, path, err, meta) — 5 args into a 3-arg wrapper —
logging 'Error: 5242880' garbage every ~60s and DISCARDING the real error
object. Fix: correct 3-arg call + legacy-shape guard in logErrorWrapper +
~74 log.error sites swept to pass real error objects (AST-verified scope-
safe 71/71, 29/29 modules load clean).
P0-3: auth-polling storm (stranded grade=B commit never landed in prod):
401/403 behind TOTP gate hammered /api/v1/services/status + SSE reconnect
every 2-8s, with misleading direct-probe fallback marking services 'up'.
Fix landed + B-round MEDIUM follow-up: TOTP re-auth success now clears
_dcAuthLost, resumes SSE (new _sseResume clears the latch), and refreshes.
Also: eslintignore static-sites/ (33→0 errors); nodemailer 8→9.0.5 and
sharp 0.33→0.35.3 (3 high CVEs killed; jest green on new majors);
dockerode@5/uuid deferred (semver-major, Docker API surface).
Verification: 80/80 suites, 1837/1837 tests; ESLint 0 errors/743 warnings;
node --check all changed files; bundles rebuilt + SW cache bumped.
Judges: Codex quota-dead until Aug 19 (verified live) — GLM adversarial
delegate per operator directive 2026-08-07. Round 1: 98-call mechanical
verification (timed out pre-verdict). Round 2 (this grade): B, one MEDIUM
(re-auth freeze) — fixed in this commit as prescribed.
119 lines
3.5 KiB
JavaScript
119 lines
3.5 KiB
JavaScript
const CACHE = 'dashcaddy-shell-78eab743c2';
|
|
const PRECACHE = [
|
|
'/',
|
|
'/index.html',
|
|
'/css/themes.css',
|
|
'/css/dashboard.css',
|
|
'/css/driver.min.css',
|
|
'/css/onboarding.css',
|
|
'/dist/core.js',
|
|
'/dist/features.js',
|
|
'/dist/init.js',
|
|
'/dist/onboarding.js',
|
|
'/assets/fonts.css',
|
|
'/assets/site.webmanifest',
|
|
'/assets/favicon.svg',
|
|
'/assets/dashcaddy-favicon.ico',
|
|
'/assets/icon-192.png',
|
|
'/assets/icon-512.png',
|
|
'/assets/apple-touch-icon.png',
|
|
'/assets/dashcaddy-logo-dark.png',
|
|
'/assets/dashcaddy-logo-light.png',
|
|
'/assets/sami7777-logo.png',
|
|
'/assets/fonts/sami-grotesk/SamiGrotesk-Regular.woff2',
|
|
'/assets/fonts/sami-grotesk/SamiGrotesk-Medium.woff2',
|
|
'/assets/fonts/sami-grotesk/SamiGrotesk-Bold.woff2',
|
|
'/assets/fonts/DSEG7Classic-Bold.woff2',
|
|
'/assets/weather/clear-day.svg',
|
|
'/assets/weather/clear-night.svg',
|
|
'/assets/weather/partly-cloudy-day.svg',
|
|
'/assets/weather/partly-cloudy-night.svg',
|
|
'/assets/weather/cloudy.svg',
|
|
'/assets/weather/fog.svg',
|
|
'/assets/weather/drizzle.svg',
|
|
'/assets/weather/rain.svg',
|
|
'/assets/weather/sleet.svg',
|
|
'/assets/weather/snow.svg',
|
|
'/assets/weather/thunderstorm.svg',
|
|
'/assets/weather/wind.svg'
|
|
];
|
|
|
|
function isNavigationRequest(request) {
|
|
return request.mode === 'navigate';
|
|
}
|
|
|
|
function isStaticAsset(pathname) {
|
|
return pathname.startsWith('/assets/')
|
|
|| pathname.startsWith('/css/')
|
|
|| pathname.startsWith('/dist/');
|
|
}
|
|
|
|
async function networkFirst(request, preloadResponsePromise) {
|
|
const cache = await caches.open(CACHE);
|
|
try {
|
|
const preloadResponse = preloadResponsePromise ? await preloadResponsePromise : null;
|
|
if (preloadResponse) {
|
|
cache.put(request, preloadResponse.clone()).catch(() => {});
|
|
return preloadResponse;
|
|
}
|
|
const response = await fetch(request);
|
|
cache.put(request, response.clone()).catch(() => {});
|
|
return response;
|
|
} catch (_) {
|
|
return caches.match(request) || caches.match('/index.html');
|
|
}
|
|
}
|
|
|
|
async function staleWhileRevalidate(request) {
|
|
const cache = await caches.open(CACHE);
|
|
const cached = await cache.match(request);
|
|
|
|
const networkPromise = fetch(request)
|
|
.then((response) => {
|
|
cache.put(request, response.clone()).catch(() => {});
|
|
return response;
|
|
})
|
|
.catch(() => null);
|
|
|
|
if (cached) return cached;
|
|
return networkPromise.then((response) => response || Response.error());
|
|
}
|
|
|
|
self.addEventListener('install', (event) => {
|
|
self.skipWaiting();
|
|
event.waitUntil(
|
|
caches.open(CACHE).then((cache) =>
|
|
cache.addAll(PRECACHE.map((url) => new Request(url, { cache: 'reload' })))
|
|
)
|
|
);
|
|
});
|
|
|
|
self.addEventListener('activate', (event) => {
|
|
event.waitUntil((async () => {
|
|
const keys = await caches.keys();
|
|
await Promise.all(keys.filter((key) => key !== CACHE).map((key) => caches.delete(key)));
|
|
if ('navigationPreload' in self.registration) {
|
|
await self.registration.navigationPreload.enable();
|
|
}
|
|
await self.clients.claim();
|
|
})());
|
|
});
|
|
|
|
self.addEventListener('fetch', (event) => {
|
|
const { request } = event;
|
|
if (request.method !== 'GET') return;
|
|
|
|
const url = new URL(request.url);
|
|
if (url.origin !== self.location.origin) return;
|
|
if (url.pathname.startsWith('/api/v1/') || url.pathname.startsWith('/probe/')) return;
|
|
|
|
if (isNavigationRequest(request) || url.pathname === '/' || url.pathname.endsWith('/index.html')) {
|
|
event.respondWith(networkFirst(request, event.preloadResponse));
|
|
return;
|
|
}
|
|
|
|
if (isStaticAsset(url.pathname)) {
|
|
event.respondWith(staleWhileRevalidate(request));
|
|
}
|
|
});
|