@rightkit/release 0.6.86 → 0.6.87
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/package.json +1 -1
- package/publish-local-npm.mjs +1 -1
- package/release-switch-scan.mjs +70 -2
- package/rightkit-versions.json +9 -5
package/README.md
CHANGED
|
@@ -61,9 +61,10 @@ The module imports node builtins only (preflight runs with no `node_modules`), r
|
|
|
61
61
|
```
|
|
62
62
|
|
|
63
63
|
- `name` (required, unique): environment variable, argument flag, settings key or `VITE_*` name.
|
|
64
|
-
- `class` (required): `S1`..`
|
|
64
|
+
- `class` (required): `S1`..`S7`. `channel` (required): `env`, `argv`, `settings`, `preference` or `frontend`.
|
|
65
65
|
- S1-S4 need `compiledOut`: `feature:<name>`, `cfg:test`, `cfg:debug_assertions` or, for Swift, `swift:<CONDITION>` (`swift:DEBUG`, `swift:PULSE_QA`: the read sits inside `#if <CONDITION>`; the read exists only there). The source walk skips test directories, including Swift bundles named `Tests`, `UITests`, `<App>Tests` and `<App>UITests`. S5 needs `userGesture: true`. S6 needs `valueType` of `bool`, `int` or `enum`.
|
|
66
66
|
- `swift:<CONDITION>` (#1169) is any Swift compilation condition (`swift:DEBUG`, or the app's own, e.g. `swift:PULSE_QA`), and it is checked, not trusted: every read of the name must sit in a Swift file inside an `#if <CONDITION>` (or `#elseif`) branch that requires it (`A && COND` does; `#else`, `COND || A` and `!COND` do not), and the project must not define the condition for Release (`SWIFT_ACTIVE_COMPILATION_CONDITIONS` in a Release `buildSettings` block of a `project.pbxproj`, a Release or unscoped `.xcconfig` line, or a SwiftPM `.define("X")` not limited to `.when(configuration: .debug)`). A condition a separate QA build adds on the command line is in no project file and passes; the finding is `not-compiled-out`.
|
|
67
|
+
- **S7, a handoff.** A one-time value (a token, a nonce) the app's own code sets in the environment of a child process it starts, which the child reads and then removes. It selects no test mode, data root, executable, library or identity, so it stays in release; both ends are checked in source instead. The entry needs `channel: "env"` and `handoff: { "setBy": "<path>:<line>", "clearedAt": "<path>:<line>" }`: the first line must show the name being set on a child (`.env(`, `.envs(`, `set_var(`, an `env…insert(` into the child's environment map), the second must show it being removed (`remove_var(`, `env_remove(`, `unsetenv(`). Where the code names it through a constant, add `"nameConst": "<path>:<line>"` pointing at `const X: &str = "NAME";`; the two ends may then show `X`. An entry whose lines do not show this is `inventory-invalid`. S7 names are not on the binary deny list. Example: `{ "name": "PULSE_AGENT_RUN_TOKEN", "class": "S7", "channel": "env", "handoff": { "nameConst": "engine/src/journal/agent_act.rs:170", "setBy": "engine/src/journal/agent_act.rs:1419", "clearedAt": "engine/src/journal/agent_act.rs:2225" } }`.
|
|
67
68
|
- `anchor` and `note` are informational (except a `releasePresence` anchor, below). Fixtures: `fixtures/release-switches/` (`app/` is a clean example).
|
|
68
69
|
- **Minimal inventory and opt-out (#397).** Every release build reads one inventory (`switches.json`, or the file `releaseSwitches.inventory` names); a missing file fails a non-dry-run release. An app with no source switches commits the smallest valid one, and that is its explicit opt-out: `{ "schema": 1, "app": "<name>", "switches": [] }`. The walk then still refuses any environment read the app source makes, so the empty list is a claim the source proves. Names the operating system or Cargo supply are not selectors and need no entry (below).
|
|
69
70
|
- **OS-provided and Cargo-provided variables (#1045).** The registry's `osProvided` list (`HOME`, `HOMEDRIVE`, `HOMEPATH`, `USERPROFILE`, `APPDATA`, `LOCALAPPDATA`, `PROGRAMDATA`, `ALLUSERSPROFILE`, `PATH`, `PATHEXT`, `SystemRoot`, `SystemDrive`, `windir`, `COMSPEC`, `ProgramFiles`, `ProgramFiles(x86)`, `ProgramW6432`, `TEMP`, `TMP`, `TMPDIR`, `USER`, `USERNAME`, `LOGNAME`, the `XDG_*` base directories) is read by the walk as not-a-switch; an app cannot add to it (that list is a registry change, so a selector cannot be declared "OS provided"), and an app that registers one of these names keeps its entry checked. In a file named `build.rs` the variables Cargo sets for a build script (`OUT_DIR`, `TARGET`, `HOST`, `PROFILE`, `DEBUG`, `OPT_LEVEL`, `NUM_JOBS`, `RUSTC*`, `CARGO_CFG_*`, `CARGO_FEATURE_*`, `DEP_*`, `CARGO_MANIFEST_DIR`, `CARGO_PKG_*`) are exempt as well; `env!`/`option_env!` keep the Cargo-set list.
|
package/package.json
CHANGED
package/publish-local-npm.mjs
CHANGED
|
@@ -94,7 +94,7 @@ export function toolCommand(command, args, platform = process.platform, comspec
|
|
|
94
94
|
return [command, args];
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
export function publishLocalNpm(argv, { run = spawnSync, log = console.log, platform = process.platform, readToken = () => readKeychainToken(run), npmrc = accountNpmrc, exists = fs.existsSync, verifyTries =
|
|
97
|
+
export function publishLocalNpm(argv, { run = spawnSync, log = console.log, platform = process.platform, readToken = () => readKeychainToken(run), npmrc = accountNpmrc, exists = fs.existsSync, verifyTries = 60, verifyDelaySeconds = 15 } = {}) {
|
|
98
98
|
const o = parseArgs(argv);
|
|
99
99
|
if (platform !== "darwin" && platform !== "win32") fail(`publish-local npm runs on the Mac (the token is the Keychain item ${NPM_KEYCHAIN_SERVICE}) or Windows (the account's own npm sign-in); this host is ${platform}`);
|
|
100
100
|
const userNpmrc = platform === "win32" ? npmrc() : null;
|
package/release-switch-scan.mjs
CHANGED
|
@@ -66,7 +66,13 @@ import { WIN_PACKAGE_DEFAULT_TRIPLE } from "./win-package-recipe.mjs";
|
|
|
66
66
|
export const TEST_MODE_MARKER = "RIGHTKIT-TEST-MODE-COMPILED"; // identical to `TEST_MODE_MARKER_TEXT` in rightkit-daemon/src/mode.rs
|
|
67
67
|
const CHUNK = 4 * 1024 * 1024;
|
|
68
68
|
const FORBIDDEN_CLASSES = new Set(["S1", "S2", "S3", "S4"]);
|
|
69
|
-
const CLASSES = new Set(["S1", "S2", "S3", "S4", "S5", "S6"]);
|
|
69
|
+
const CLASSES = new Set(["S1", "S2", "S3", "S4", "S5", "S6", "S7"]);
|
|
70
|
+
// S7, a handoff: a one-time value (a token, a nonce) the app's own code sets on a child process it starts, which the child reads and
|
|
71
|
+
// removes. It selects no test mode, data root, executable, library or identity (M23 names those), so it is not compiled out; both ends
|
|
72
|
+
// are checked in source instead (handoffFindings): the line that sets it on the child and the line that removes it after the read.
|
|
73
|
+
const ANCHOR = /^[^:\s][^:]*:[1-9][0-9]*$/;
|
|
74
|
+
const HANDOFF_SET = /(?:\.envs?\s*\(|\bset_var\s*\(|\bsetenv\s*\(|\benvironment\s*\[|\benv\w*\s*\.\s*insert\s*\()/;
|
|
75
|
+
const HANDOFF_CLEAR = /(?:\benv_remove\s*\(|\bremove_var\s*\(|\bunsetenv\s*\(|\bremoveValue\s*\()/;
|
|
70
76
|
const CHANNELS = new Set(["env", "argv", "settings", "preference", "frontend"]);
|
|
71
77
|
// `swift:<CONDITION>`: the read sits inside `#if <CONDITION>`, a Swift compilation condition the Release build does not define
|
|
72
78
|
// (`DEBUG`, or the app's own, e.g. `PULSE_QA`); the source walk confirms the enclosure and the project's Release settings.
|
|
@@ -337,7 +343,7 @@ export function parseInventory(text, label = "switches.json") {
|
|
|
337
343
|
if (typeof entry?.name !== "string" || !entry.name) { bad("every switch needs a `name`"); continue; }
|
|
338
344
|
if (names.has(entry.name)) bad(`${where} is listed twice`);
|
|
339
345
|
names.add(entry.name);
|
|
340
|
-
if (!CLASSES.has(entry.class)) bad(`${where}: \`class\` must be one of S1..
|
|
346
|
+
if (!CLASSES.has(entry.class)) bad(`${where}: \`class\` must be one of S1..S7`);
|
|
341
347
|
if (!CHANNELS.has(entry.channel)) bad(`${where}: \`channel\` must be one of ${[...CHANNELS].join(", ")}`);
|
|
342
348
|
if (FORBIDDEN_CLASSES.has(entry.class)) {
|
|
343
349
|
if (typeof entry.compiledOut !== "string" || !COMPILED_OUT.test(entry.compiledOut)) {
|
|
@@ -355,6 +361,12 @@ export function parseInventory(text, label = "switches.json") {
|
|
|
355
361
|
}
|
|
356
362
|
} else if (entry.class === "S6") {
|
|
357
363
|
if (!["bool", "int", "enum"].includes(entry.valueType)) bad(`${where}: class S6 needs a bounded \`valueType\` (bool, int or enum)`);
|
|
364
|
+
} else if (entry.class === "S7") {
|
|
365
|
+
if (entry.channel !== "env") bad(`${where}: class S7 is a value handed to a child process in its environment; \`channel\` must be env`);
|
|
366
|
+
const handoff = entry.handoff;
|
|
367
|
+
if (!handoff || typeof handoff !== "object" || Array.isArray(handoff) || !ANCHOR.test(handoff.setBy ?? "") || !ANCHOR.test(handoff.clearedAt ?? "")) {
|
|
368
|
+
bad(`${where}: class S7 needs \`handoff\`: { setBy: "<path>:<line>", clearedAt: "<path>:<line>" } (where the app sets it on its child, and where the child removes it after reading)`);
|
|
369
|
+
}
|
|
358
370
|
} else if (entry.class === "S5") {
|
|
359
371
|
if (entry.userGesture !== true) bad(`${where}: class S5 needs \`userGesture: true\` (chosen by a picker, saved preference or the user's own argument)`);
|
|
360
372
|
}
|
|
@@ -588,6 +600,7 @@ export function sourceSwitchFindings({ sourceRoot, sourceRoots, inventoryText, i
|
|
|
588
600
|
if (swift) swiftConditions.add(swift[1]);
|
|
589
601
|
}
|
|
590
602
|
findings.push(...swiftReleaseConditionFindings(walkRoots, skipAbs, sourceRoot, swiftConditions));
|
|
603
|
+
findings.push(...handoffFindings(doc, sourceRoot, inventoryLabel));
|
|
591
604
|
return findings;
|
|
592
605
|
}
|
|
593
606
|
|
|
@@ -599,6 +612,61 @@ const ownerNameMatches = (pattern, name) => (pattern.endsWith("*") ? name.starts
|
|
|
599
612
|
const treeHasCrate = (treeText, crate) => typeof treeText === "string" && new RegExp(`(^|[^A-Za-z0-9_-])${escapeRegExp(crate)} v[0-9]`, "m").test(treeText);
|
|
600
613
|
const PRESENCE_CALL = { scrub: /(?:env_remove|remove_var|env_clear|scrub\w*|clear\w*|retain)/, clear: /(?:env_remove|remove_var|env_clear|scrub\w*|clear\w*|retain)/, set: /(?:set_var|\.envs?\s*\(|\bset\w*\s*\()/ };
|
|
601
614
|
|
|
615
|
+
// Does `<path>:<line>` under the source root show the literal name beside a call matching `call` (two lines either side)? null when it does.
|
|
616
|
+
function anchorCallProblem(sourceRoot, name, anchor, call, what, alias = null) {
|
|
617
|
+
if (!sourceRoot) return "has no source root to read its anchor from";
|
|
618
|
+
const [rel, line] = [anchor.slice(0, anchor.lastIndexOf(":")), Number(anchor.slice(anchor.lastIndexOf(":") + 1))];
|
|
619
|
+
const base = path.resolve(sourceRoot);
|
|
620
|
+
const abs = path.resolve(base, rel);
|
|
621
|
+
if (!within(base, abs)) return `anchor ${anchor} escapes the app root`;
|
|
622
|
+
let lines;
|
|
623
|
+
try { lines = readFileSync(abs, "utf8").split(/\r?\n/); } catch { return `anchor ${anchor}: the file does not exist`; }
|
|
624
|
+
if (line > lines.length) return `anchor ${anchor}: the file has only ${lines.length} lines`;
|
|
625
|
+
const window = lines.slice(Math.max(0, line - 3), line + 2).join("\n");
|
|
626
|
+
const named = window.includes(`"${name}"`) || (alias && new RegExp(`\\b${alias}\\b`).test(window));
|
|
627
|
+
if (!named) return `anchor ${anchor} does not show the literal "${name}"${alias ? ` or its constant ${alias}` : ""} within two lines`;
|
|
628
|
+
if (!call.test(window)) return `anchor ${anchor} shows the name but no ${what} (${call.source})`;
|
|
629
|
+
return null;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
// The identifier a `<path>:<line>` line declares as a constant equal to "name" (`const X: &str = "name";`, `static`, `let`), or null.
|
|
633
|
+
function constantNamed(sourceRoot, anchor, name) {
|
|
634
|
+
if (!sourceRoot) return null;
|
|
635
|
+
const [rel, line] = [anchor.slice(0, anchor.lastIndexOf(":")), Number(anchor.slice(anchor.lastIndexOf(":") + 1))];
|
|
636
|
+
const base = path.resolve(sourceRoot);
|
|
637
|
+
const abs = path.resolve(base, rel);
|
|
638
|
+
if (!within(base, abs)) return null;
|
|
639
|
+
let text;
|
|
640
|
+
try { text = readFileSync(abs, "utf8").split(/\r?\n/)[line - 1] ?? ""; } catch { return null; }
|
|
641
|
+
const m = /\b(?:const|static|let)\s+([A-Za-z_][A-Za-z0-9_]*)\b[^=]*=\s*"([^"]*)"/.exec(text);
|
|
642
|
+
return m && m[2] === name ? m[1] : null;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
/**
|
|
646
|
+
* Class S7 (handoff): both ends of each entry are read from source. `handoff.setBy` must show the app setting the name on a child
|
|
647
|
+
* process, and `handoff.clearedAt` must show the name being removed from the environment (the reader clears it once read). An entry
|
|
648
|
+
* whose anchors do not show that is `inventory-invalid`: the name is then an ordinary runtime read with no class.
|
|
649
|
+
*/
|
|
650
|
+
export function handoffFindings(doc, sourceRoot, inventoryLabel = "switches.json") {
|
|
651
|
+
const findings = [];
|
|
652
|
+
for (const entry of doc?.switches ?? []) {
|
|
653
|
+
if (entry?.class !== "S7" || !ANCHOR.test(entry.handoff?.setBy ?? "") || !ANCHOR.test(entry.handoff?.clearedAt ?? "")) continue;
|
|
654
|
+
// `handoff.nameConst` (optional): the line declaring the constant the code uses for the name (`const X: &str = "NAME";`). When it
|
|
655
|
+
// is given and shows that, the two ends may name the constant instead of the literal.
|
|
656
|
+
let alias = null;
|
|
657
|
+
if (entry.handoff.nameConst !== undefined) {
|
|
658
|
+
const declared = ANCHOR.test(entry.handoff.nameConst ?? "") ? constantNamed(sourceRoot, entry.handoff.nameConst, entry.name) : null;
|
|
659
|
+
if (!declared) { findings.push({ layer: "inventory", rule: "inventory-invalid", file: inventoryLabel, reason: `inventory-invalid: switch \`${entry.name}\` (class S7 handoff): handoff.nameConst ${entry.handoff.nameConst} does not declare a constant equal to "${entry.name}"` }); continue; }
|
|
660
|
+
alias = declared;
|
|
661
|
+
}
|
|
662
|
+
for (const [anchor, call, what] of [[entry.handoff.setBy, HANDOFF_SET, "call that sets it on a child process"], [entry.handoff.clearedAt, HANDOFF_CLEAR, "call that removes it from the environment"]]) {
|
|
663
|
+
const problem = anchorCallProblem(sourceRoot, entry.name, anchor, call, what, alias);
|
|
664
|
+
if (problem) findings.push({ layer: "inventory", rule: "inventory-invalid", file: inventoryLabel, reason: `inventory-invalid: switch \`${entry.name}\` (class S7 handoff): ${problem}` });
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
return findings;
|
|
668
|
+
}
|
|
669
|
+
|
|
602
670
|
// Does the app anchor `<path>:<line>` show the name inside a call of the claimed mechanism (a window of two lines either side)?
|
|
603
671
|
function presenceAnchorProblem(sourceRoot, entry) {
|
|
604
672
|
const presence = entry.releasePresence;
|
package/rightkit-versions.json
CHANGED
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"@rightkit/qa": "0.7.0",
|
|
50
50
|
"@rightkit/qa-chrome": "0.1.12",
|
|
51
51
|
"@rightkit/react-shell": "0.7.9",
|
|
52
|
-
"@rightkit/release": "0.6.
|
|
52
|
+
"@rightkit/release": "0.6.87",
|
|
53
53
|
"@rightkit/send-ui": "0.1.0",
|
|
54
54
|
"@rightkit/settings-ui": "0.7.7",
|
|
55
55
|
"@rightkit/social-ui": "0.2.1",
|
|
@@ -451,7 +451,8 @@
|
|
|
451
451
|
"0.6.82",
|
|
452
452
|
"0.6.83",
|
|
453
453
|
"0.6.84",
|
|
454
|
-
"0.6.85"
|
|
454
|
+
"0.6.85",
|
|
455
|
+
"0.6.86"
|
|
455
456
|
],
|
|
456
457
|
"@rightkit/settings-ui": [
|
|
457
458
|
"0.1.0",
|
|
@@ -755,7 +756,7 @@
|
|
|
755
756
|
"rightkit-sysmem": "0.1.0",
|
|
756
757
|
"rightkit-system-monitor": "0.3.2",
|
|
757
758
|
"rightkit-tauri-shell": "0.8.10",
|
|
758
|
-
"rightkit-terminal-ui": "0.1.
|
|
759
|
+
"rightkit-terminal-ui": "0.1.8",
|
|
759
760
|
"rightkit-text-polish": "0.1.4",
|
|
760
761
|
"rightkit-theme": "0.1.1",
|
|
761
762
|
"rightkit-time": "0.1.5",
|
|
@@ -919,7 +920,7 @@
|
|
|
919
920
|
"@rightkit/qa": "0.7.0",
|
|
920
921
|
"@rightkit/qa-chrome": "0.1.12",
|
|
921
922
|
"@rightkit/react-shell": "0.7.7",
|
|
922
|
-
"@rightkit/release": "0.6.
|
|
923
|
+
"@rightkit/release": "0.6.86",
|
|
923
924
|
"@rightkit/settings-ui": "0.7.4",
|
|
924
925
|
"@rightkit/shell": "0.1.1",
|
|
925
926
|
"@rightkit/tauri": "0.4.3",
|
|
@@ -1887,7 +1888,10 @@
|
|
|
1887
1888
|
],
|
|
1888
1889
|
"rightkit-terminal-ui": [
|
|
1889
1890
|
"0.1.3",
|
|
1890
|
-
"0.1.4"
|
|
1891
|
+
"0.1.4",
|
|
1892
|
+
"0.1.5",
|
|
1893
|
+
"0.1.6",
|
|
1894
|
+
"0.1.7"
|
|
1891
1895
|
],
|
|
1892
1896
|
"rightkit-timeline": [
|
|
1893
1897
|
"0.1.1"
|