port: apply 7 upstream security/robustness patches

Ports from isolated upstream-port branch (base b3c5a4b), verified in
isolation via baseline-vs-port failure-set diff and re-verified live
(195 pass / 0 fail on affected tests):
- redact Discord bot tokens in outbound (router.ts SECRET_PATTERNS)
- block SSRF to private hosts in MoA base URL (moa.ts)
- refuse public dashboard bind without auth token (web-dashboard-server.ts)
- merge upstream .gitignore rules for python/build/secret noise
- real CPU utilization from /proc/stat instead of load avg (unified-dashboard.ts)
- width-safe placeholder for missing usage window on mobile (unified-dashboard.ts)
- bump direct deps to patch known vulnerabilities (discord.js/yaml/cron-parser)

Risky upstream commits (d5a94af phantom reset-time, patch 6 Codex usage)
intentionally skipped to avoid touching the credential-isolation tree.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Codex
2026-08-24 19:35:59 +09:00
parent b3c5a4b41b
commit c016b9c2fa
11 changed files with 393 additions and 205 deletions

View File

@@ -8,11 +8,38 @@ import {
formatStatusHeader,
msUntilNextMinuteBoundary,
getDashboardDuplicateCleanupIntervalMs,
readCpuUtilizationPct,
renderUsageTable,
resetCpuUtilizationSample,
shouldPurgeDashboardChannelOnStart,
summarizeWatcherTasks,
} from './unified-dashboard.js';
describe('readCpuUtilizationPct', () => {
it('computes busy percentage from consecutive /proc/stat samples', () => {
resetCpuUtilizationSample();
expect(
readCpuUtilizationPct(() => 'cpu 100 0 100 800 0 0 0 0 0 0\n'),
).toBeNull();
// +100 total ticks: +30 busy, +70 idle => 30%.
expect(
readCpuUtilizationPct(() => 'cpu 115 0 115 870 0 0 0 0 0 0\n'),
).toBe(30);
});
it('counts iowait as idle and rejects malformed samples', () => {
resetCpuUtilizationSample();
expect(readCpuUtilizationPct(() => 'not-a-cpu-line\n')).toBeNull();
expect(
readCpuUtilizationPct(() => 'cpu 100 0 100 700 100 0 0 0 0 0\n'),
).toBeNull();
// +100 total, all +100 is iowait: CPU busy must be 0%, not 100%.
expect(
readCpuUtilizationPct(() => 'cpu 100 0 100 700 200 0 0 0 0 0\n'),
).toBe(0);
});
});
describe('summarizeWatcherTasks', () => {
it('counts active and paused watcher tasks only', () => {
const summary = summarizeWatcherTasks([