From a49329cdde1a65e925f6e848cbd53e7d8533e48b Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 30 Jul 2026 09:21:52 +0000 Subject: [PATCH 1/2] test(analytics): cover buildScurve zero-total-duration guard Add a unit test for the `totalDays <= 0` early-return in buildScurve (analytics.js), the divide-by-zero guard on the cumulative S-curve weight math (`dur / totalDays`). This branch was previously unexercised: the existing buildScurve tests covered only a normal two-task curve and the empty-input case (`!dated.length`). No assertion hit the path where tasks DO carry both planned dates (so they populate `dated`) yet contribute zero duration, leaving totalDays == 0. The new case feeds two tasks with inverted date ranges (end < start), which the injected calcDuration maps to 0 days, and asserts the function returns `{ timeline: [], planned: [] }` and that the planned series contains no NaN. Verification (test-only change; no production source modified): - Removing the guard from analytics.js and rerunning analytics.test.mjs still passed before this change (proving the branch was uncovered) and fails with the new assertion after it (proving the test exercises it). - node tests/unit/analytics.test.mjs -> passed - npm run test:unit -> all 13 suites passed Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01REEc4WtvMHbGD23XK6xbLK --- tests/unit/analytics.test.mjs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/unit/analytics.test.mjs b/tests/unit/analytics.test.mjs index 9f0163d1..7c6b5137 100644 --- a/tests/unit/analytics.test.mjs +++ b/tests/unit/analytics.test.mjs @@ -74,4 +74,22 @@ assert.ok(midIdx > 0 && Math.abs(s.planned[midIdx] - 0.5) < 1e-6, 'midpoint ≈ // empty / undated tasks → empty series, no throw assert.deepEqual(buildScurve({ tasks: [], calcPlannedRatio, calcDuration, buildTimeline }), { timeline: [], planned: [] }); +// dated tasks whose total duration is zero → empty series (no 0/0 NaN weight). +// Distinct from the empty-input case above: these tasks DO pass the "has both +// planned dates" filter, so they populate `dated`, but each contributes 0 days +// (end Number.isFinite(v)), 'no NaN in planned series'); + console.log('✓ analytics (EVM + S-curve) unit tests passed'); From c125b783d81224cd24aabec31423dc5d002013da Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 30 Jul 2026 09:32:22 +0000 Subject: [PATCH 2/2] fix(ci): remediate pre-existing trivy-fs + Semgrep findings on develop Two security gates were failing on this PR from base-branch debt (this PR otherwise only adds a unit test), so remediate them here per scopeweave's AGENTS.md trivy protocol -- the fixes ride along and land on develop at merge. trivy-fs / osv (GHSA-frvp-7c67-39w9, path traversal in @hono/node-server serve-static on Windows via encoded backslash %5C; affects <2.0.5): bump @hono/node-server ^1.19.14 -> ^2.0.12 (npm-reported fix). server.mjs uses only the stable `serve({ fetch, port }, cb)` API, which is unchanged across the 1.x -> 2.x major, so the bump is behavior-preserving here. Both lockfiles updated (package-lock.json for CI; pnpm-lock.yaml kept in sync). npm audit now reports 0 vulnerabilities. Semgrep detect-non-literal-regexp at cloud-sync.js:743 (warning): verified false positive. The `tag(block, name)` helper in parseMsProjectXml is called only with hardcoded XML tag literals (UID, Name, OutlineLevel, PercentComplete, Start, Finish) -- never user input -- and the capture group `[^<]*` is a single linear character class with no nested/ambiguous quantifier, so it cannot backtrack catastrophically for any `block`. Suppressed with a scoped, documented `// nosemgrep: ` plus an explanatory comment; no behavior change. Verified locally (Node 22): npm run test:unit (all suites incl. MS Project import + cloud-sync-security), npm run test:api (API smoke + rate-limit, boots the server on the bumped @hono/node-server), npm audit -> 0 vulnerabilities. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01REEc4WtvMHbGD23XK6xbLK --- cloud-sync.js | 7 ++++++- package-lock.json | 10 +++++----- package.json | 2 +- pnpm-lock.yaml | 12 ++++++------ 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/cloud-sync.js b/cloud-sync.js index 7e44932b..322a95c6 100644 --- a/cloud-sync.js +++ b/cloud-sync.js @@ -740,7 +740,12 @@ function openReportModal() { // hand-edited files ever matter. export function parseMsProjectXml(xml) { const tag = (block, name) => { - const m = block.match(new RegExp(`<${name}>([^<]*)`)); + // `name` is always a hardcoded XML tag literal from the callers below + // (UID, Name, OutlineLevel, Start, Finish, ...), never user input, and the + // capture group `[^<]*` is a single linear character class with no nested + // or ambiguous quantifier, so this pattern cannot backtrack catastrophically + // regardless of `block` — there is no ReDoS surface. + const m = block.match(new RegExp(`<${name}>([^<]*)`)); // nosemgrep: javascript.lang.security.audit.detect-non-literal-regexp.detect-non-literal-regexp return m ? m[1].trim() : ''; }; const unescape = (s) => s diff --git a/package-lock.json b/package-lock.json index 21575e82..7abe7165 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,7 +8,7 @@ "name": "scopeweave", "version": "1.0.0", "dependencies": { - "@hono/node-server": "^1.19.14", + "@hono/node-server": "^2.0.12", "hono": "^4.12.27" }, "devDependencies": { @@ -17,12 +17,12 @@ } }, "node_modules/@hono/node-server": { - "version": "1.19.14", - "resolved": "https://registry.npmjs.org/@hono/node-server/-/node-server-1.19.14.tgz", - "integrity": "sha512-GwtvgtXxnWsucXvbQXkRgqksiH2Qed37H9xHZocE5sA3N8O8O8/8FA3uclQXxXVzc9XBZuEOMK7+r02FmSpHtw==", + "version": "2.0.12", + "resolved": "https://registry.npmjs.org/@hono/node-server/-/node-server-2.0.12.tgz", + "integrity": "sha512-eWpQYr67tqJLeaSUl0Q+TquuYfUdTibpOJlUMV2FfUP7+KqCC5TufnwnlXL6mobZBJbGAYRd7ZvEBDCbLInjhg==", "license": "MIT", "engines": { - "node": ">=18.14.1" + "node": ">=20" }, "peerDependencies": { "hono": "^4" diff --git a/package.json b/package.json index 9ae8b292..2f90e2a3 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "fuzz": "node --test tests/fuzz/*.mjs" }, "dependencies": { - "@hono/node-server": "^1.19.14", + "@hono/node-server": "^2.0.12", "hono": "^4.12.27" }, "devDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bffabf92..5d7b7de5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,8 +9,8 @@ importers: .: dependencies: '@hono/node-server': - specifier: ^1.19.14 - version: 1.19.14(hono@4.12.28) + specifier: ^2.0.12 + version: 2.0.12(hono@4.12.28) hono: specifier: ^4.12.27 version: 4.12.28 @@ -24,9 +24,9 @@ importers: packages: - '@hono/node-server@1.19.14': - resolution: {integrity: sha512-GwtvgtXxnWsucXvbQXkRgqksiH2Qed37H9xHZocE5sA3N8O8O8/8FA3uclQXxXVzc9XBZuEOMK7+r02FmSpHtw==} - engines: {node: '>=18.14.1'} + '@hono/node-server@2.0.12': + resolution: {integrity: sha512-eWpQYr67tqJLeaSUl0Q+TquuYfUdTibpOJlUMV2FfUP7+KqCC5TufnwnlXL6mobZBJbGAYRd7ZvEBDCbLInjhg==} + engines: {node: '>=20'} peerDependencies: hono: ^4 @@ -63,7 +63,7 @@ packages: snapshots: - '@hono/node-server@1.19.14(hono@4.12.28)': + '@hono/node-server@2.0.12(hono@4.12.28)': dependencies: hono: 4.12.28