mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-26 09:52:11 +03:00
* fix(build): spawn npx.cmd through a shell in the electron better-sqlite3 rebuild Node's CVE-2024-27980 hardening makes spawnSync of .cmd/.bat shims fail with status null unless shell:true — the v3.8.47 tag build died on the Windows job with 'better-sqlite3 rebuild against electron 43.1.0 failed (exit null)'. Extracted the spawn plan into electronRebuildPlan.mjs (pure, import-safe) with a regression test; args are fixed literals, no untrusted input reaches the shell. * fix(build): ship head-response-guard.cjs in the npm tarball (#7065) The prepublish prune allowlist (pack-artifact-policy.ts) lacked head-response-guard.cjs, so assembleStandalone copied it and the prune deleted it — every boot of the published 3.8.47 crashed with ERR_MODULE_NOT_FOUND (3rd occurrence of this class; tls-options/3.8.41). Also added to PACK_ARTIFACT_REQUIRED_PATHS so check:pack-artifact fails loudly, plus a closure test that derives every server-ws.mjs sibling import and asserts both lists cover it. * fix(ci): zero the Sonar quality-gate findings on new code - ci.yml sonarqube job: download the coverage artifact into coverage/ so lcov.info lands where sonar.javascript.lcov.reportPaths points — the upload strips the common coverage/ prefix, so 'path: .' left new-code coverage at 0% on every scan - kiro auto-import: await the async isCloudEnabled() gate (S6544 — a bare truthiness check on the Promise made syncToCloud run even with cloud sync disabled) - stream.ts: real JSON fallback in the reasoning-split clone (S3923 — both ternary branches called structuredClone, the promised fallback was dead) - codex executor: handle the async reader.cancel() rejection (S4822) - deterministic localeCompare sorts (S2871 x2) - classify-pr-changes.mjs: confine the argv list file to the workspace (jssecurity:S8707 path-traversal guard) + behavioral tests - Dockerfile: rebuild better-sqlite3 with npm's bundled node-gyp instead of npx --yes (docker:S6505 — no on-demand registry install) * chore(ci): make the Sonar quality gate informational (wait=false) The org's SonarCloud FREE plan cannot associate a custom quality gate — only the built-in Sonar way (80% new coverage) applies, which no full-cycle release PR can realistically meet. The scan still uploads (dashboard, PR decoration); the CI job just no longer fails on the gate. A tuned 'OmniRoute way' gate (coverage >=60, duplication <=5) is already configured in the org for the day the plan is upgraded — re-enable wait=true then. * chore(release): v3.8.48 hotfix bump + changelog (npm 3.8.47 unbootable, #7065) * test: align pack-artifact + dockerfile guards to the corrected contracts pack-artifact-policy.test.ts encoded the pre-#7065 REQUIRED list (without head-response-guard.cjs) and dockerfile-better-sqlite3-node-gyp-6700.test.ts asserted the npx invocation the Sonar fix replaced with npm's bundled node-gyp — both now assert the corrected behavior.
129 lines
3.7 KiB
JavaScript
129 lines
3.7 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* PR change classification for ci.yml path filters.
|
|
*
|
|
* Why this exists (not "skip work for free"):
|
|
* - code → typecheck, unit/vitest, lint bag, quality ratchets (code regressions)
|
|
* - docs → docs-sync / prose (doc/API contract regressions)
|
|
* - i18n → message/UI-key validation (translation regressions)
|
|
* - workflow → CI definition changes (always treat as code — gates protect the gates)
|
|
*
|
|
* Pure docs or pure message-catalog PRs should NOT pay full unit/lint wall time.
|
|
* Unknown paths default to code (fail-safe: better over-run than under-protect).
|
|
*/
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
/**
|
|
* @param {string[]} files relative paths from git diff
|
|
* @returns {{ code: boolean, docs: boolean, i18n: boolean, workflow: boolean }}
|
|
*/
|
|
export function classifyPaths(files) {
|
|
let code = false;
|
|
let docs = false;
|
|
let i18n = false;
|
|
let workflow = false;
|
|
|
|
for (const raw of files) {
|
|
const f = String(raw || "")
|
|
.trim()
|
|
.replace(/\\/g, "/");
|
|
if (!f) continue;
|
|
|
|
if (f.startsWith(".github/workflows/") || f === ".zizmor.yml") {
|
|
workflow = true;
|
|
// Workflow edits can weaken or remove gates — treat as code.
|
|
code = true;
|
|
continue;
|
|
}
|
|
|
|
// Message catalogs only: translation content, not runtime TS.
|
|
if (f.startsWith("src/i18n/messages/")) {
|
|
i18n = true;
|
|
continue;
|
|
}
|
|
|
|
// i18n tooling / non-message i18n source → also code (scripts, config, loaders).
|
|
if (
|
|
f.startsWith("scripts/i18n/") ||
|
|
f === "config/i18n.json" ||
|
|
f.startsWith("src/i18n/")
|
|
) {
|
|
i18n = true;
|
|
code = true;
|
|
continue;
|
|
}
|
|
|
|
if (f.startsWith("docs/") || f.endsWith(".md")) {
|
|
docs = true;
|
|
continue;
|
|
}
|
|
|
|
if (
|
|
f.startsWith("src/") ||
|
|
f.startsWith("open-sse/") ||
|
|
f.startsWith("bin/") ||
|
|
f.startsWith("electron/") ||
|
|
f.startsWith("tests/") ||
|
|
f.startsWith("scripts/") ||
|
|
f.startsWith("db/") ||
|
|
f.startsWith("config/") ||
|
|
f === "package.json" ||
|
|
f === "package-lock.json" ||
|
|
/^tsconfig.*\.json$/.test(f) ||
|
|
f.startsWith("next.config.") ||
|
|
f.startsWith("vitest") ||
|
|
f.startsWith("playwright.config.")
|
|
) {
|
|
code = true;
|
|
continue;
|
|
}
|
|
|
|
// Fail-safe: unknown path class → code (do not skip heavy gates by accident).
|
|
code = true;
|
|
}
|
|
|
|
return { code, docs, i18n, workflow };
|
|
}
|
|
|
|
function main() {
|
|
const listPath = process.argv[2];
|
|
let files;
|
|
if (listPath && listPath !== "-") {
|
|
// Both CI callers pass a workspace-relative file (changed-files.txt); confine
|
|
// the argument to the working directory so a stray/hostile path can never
|
|
// read outside the checkout (path-traversal guard).
|
|
const resolved = path.resolve(process.cwd(), listPath);
|
|
const rel = path.relative(process.cwd(), resolved);
|
|
if (rel.startsWith("..") || path.isAbsolute(rel)) {
|
|
console.error(`[classify-pr-changes] list path escapes the workspace: ${listPath}`);
|
|
process.exit(1);
|
|
}
|
|
files = fs
|
|
.readFileSync(resolved, "utf8")
|
|
.split(/\r?\n/)
|
|
.map((s) => s.trim())
|
|
.filter(Boolean);
|
|
} else {
|
|
const stdin = fs.readFileSync(0, "utf8");
|
|
files = stdin
|
|
.split(/\r?\n/)
|
|
.map((s) => s.trim())
|
|
.filter(Boolean);
|
|
}
|
|
const c = classifyPaths(files);
|
|
// GitHub Actions output format (also human-readable key=value).
|
|
process.stdout.write(
|
|
`code=${c.code}\ndocs=${c.docs}\ni18n=${c.i18n}\nworkflow=${c.workflow}\n`
|
|
);
|
|
}
|
|
|
|
const isMain =
|
|
process.argv[1] &&
|
|
path.resolve(fileURLToPath(import.meta.url)) === path.resolve(process.argv[1]);
|
|
|
|
if (isMain) {
|
|
main();
|
|
}
|