@rightkit/release 0.6.56 → 0.6.61
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 +4 -0
- package/acceptance-admission.mjs +104 -0
- package/acceptance-launch.mjs +234 -0
- package/acceptance-lines.mjs +1254 -0
- package/acceptance-result.mjs +77 -0
- package/acceptance-rows.mjs +47 -0
- package/admission-files.mjs +2 -0
- package/affected-units.mjs +17 -0
- package/app-check.mjs +6 -2
- package/app-closure.mjs +3 -1
- package/bin/rightkit-gate.mjs +546 -121
- package/broker-admission.mjs +45 -2
- package/broker-pins.mjs +11 -1
- package/broker-toolchain.mjs +113 -0
- package/cargo-profile-contract.mjs +7 -2
- package/class-a-cache-history.mjs +135 -0
- package/cli/right-release.mjs +0 -0
- package/code-closure.mjs +24 -0
- package/config-inspect.mjs +6 -0
- package/consumer-contracts.mjs +3 -1
- package/contract-nn.json +166 -0
- package/deterministic-scans.mjs +835 -112
- package/feature-coverage.mjs +109 -82
- package/feature-partition.mjs +76 -0
- package/forbidden-literals.mjs +78 -0
- package/gate/calls.mjs +121 -0
- package/gate/compile.mjs +190 -0
- package/gate/crate-results.mjs +127 -0
- package/gate/run-calls.mjs +241 -0
- package/gate/tests.mjs +234 -0
- package/gate-coverage.mjs +12 -3
- package/gate-release-admission.mjs +200 -0
- package/gate-seam.mjs +100 -4
- package/gate-serve.mjs +178 -32
- package/gate-stages.mjs +59 -0
- package/legacy-contract-receipt.mjs +809 -0
- package/local-publish.mjs +7 -5
- package/local-runtime.mjs +2 -2
- package/nsis-payload.mjs +4 -3
- package/ownership-applicability.mjs +5 -0
- package/ownership-class-rules.mjs +19 -8
- package/ownership-mandatory-set.json +15 -21
- package/ownership-mandatory-set.mjs +19 -4
- package/package.json +14 -8
- package/probe-memo.mjs +252 -0
- package/publication-artifacts.mjs +56 -2
- package/publish-local-npm.mjs +3 -0
- package/publish-update.mjs +2 -2
- package/receipt-signature.mjs +40 -0
- package/release.mjs +47 -29
- package/resident-answers.mjs +66 -0
- package/rightkit-ownership.json +20 -11
- package/rightkit-versions.json +349 -183
- package/runtime-bundle-stage.mjs +146 -0
- package/scan-digest.mjs +28 -4
- package/seam-broker.mjs +8 -1
- package/shell-contract.mjs +23 -2
- package/snapshot-changes.mjs +106 -0
- package/snapshot-check.mjs +17 -13
- package/snapshot-dependency-reuse.mjs +186 -14
- package/snapshot-git.mjs +17 -1
- package/snapshot-metadata.mjs +155 -3
- package/snapshot.mjs +90 -12
- package/spawn-ledger.mjs +21 -2
- package/stage-sidecar.mjs +231 -19
- package/suite-trust-roots.mjs +2 -2
- package/test-env.mjs +26 -0
- package/tool-version-memo.mjs +46 -0
- package/win-package-recipe.mjs +11 -0
- package/bin/darwin/rightkit-swap +0 -0
- package/gate-acceptance.mjs +0 -3362
|
@@ -3,7 +3,8 @@ import { readFileSync, statSync, openSync, fstatSync, readSync, closeSync } from
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { verifySealedRelease } from "./release-state.mjs";
|
|
5
5
|
import { verifyOwnershipEvidence } from "./ownership-evidence.mjs";
|
|
6
|
-
import { validateMediaSidecarReceipt } from "./media-sidecar.mjs";
|
|
6
|
+
import { bundledFileName, stagedFileName, validateMediaSidecarReceipt } from "./media-sidecar.mjs";
|
|
7
|
+
import { validateExternalBinConfig } from "./external-bin.mjs";
|
|
7
8
|
|
|
8
9
|
export class PublicationError extends Error {
|
|
9
10
|
constructor(code, message) { super(`[${code}] ${message}`); this.name = "PublicationError"; this.code = code; }
|
|
@@ -43,7 +44,7 @@ export function assertArtifactUnchanged(artifact) {
|
|
|
43
44
|
|
|
44
45
|
// `streamRoles`: sealed entries of these roles are hash-verified by a streamed read and returned WITHOUT their bytes (the caller reads
|
|
45
46
|
// byte ranges of `file`), so a large IPA is never held in memory.
|
|
46
|
-
export function verifyPublicationRelease({ sealedDir, repoRoot, appRoot, commit, app, version, platform, configPath, releaseId, streamRoles = [], ownershipScope = null }, deps = {}) {
|
|
47
|
+
export function verifyPublicationRelease({ sealedDir, repoRoot, appRoot, commit, app, version, platform, configPath, releaseId, streamRoles = [], ownershipScope = null, target }, deps = {}) {
|
|
47
48
|
let sealed;
|
|
48
49
|
try { sealed = verifySealedRelease(sealedDir); }
|
|
49
50
|
catch (error) {
|
|
@@ -68,6 +69,8 @@ export function verifyPublicationRelease({ sealedDir, repoRoot, appRoot, commit,
|
|
|
68
69
|
let signed = false;
|
|
69
70
|
let androidVerified = false;
|
|
70
71
|
let iosVerified = false;
|
|
72
|
+
const windowsSignatures = [];
|
|
73
|
+
const windowsEmbedding = [];
|
|
71
74
|
for (const receipt of receipts) {
|
|
72
75
|
const artifact = readVerifiedArtifact(path.resolve(appRoot, receipt.file), receipt);
|
|
73
76
|
let value;
|
|
@@ -82,10 +85,12 @@ export function verifyPublicationRelease({ sealedDir, repoRoot, appRoot, commit,
|
|
|
82
85
|
if (Array.isArray(value.files)) {
|
|
83
86
|
if (!value.files.length || value.files.some((item) => !/^[a-f0-9]{64}$/.test(item.after?.sha256 ?? "") || item.timestampPresent !== true
|
|
84
87
|
|| (platform === "win" ? item.authenticode !== "Valid" || item.subject !== "CN=Damned Ventures LLC" : item.codesign !== "strict-valid" || item.identity !== value.identity))) throw new PublicationError("PUBLICATION_SIGNATURE_INVALID", "sealed signature verification evidence rejected");
|
|
88
|
+
if (platform === "win") windowsSignatures.push(value.files);
|
|
85
89
|
signed = true;
|
|
86
90
|
} else if (Array.isArray(value.embedded)) {
|
|
87
91
|
if (!value.embedded.length || !/^[a-f0-9]{64}$/.test(value.rawExe?.signedSha256 ?? "") || value.rawExe.signedSha256 !== value.rawExe.verifiedSha256
|
|
88
92
|
|| value.embedded.some((item) => item.sha256 !== value.rawExe.signedSha256)) throw new PublicationError("PUBLICATION_SIGNATURE_INVALID", "sealed installer embedding evidence rejected");
|
|
93
|
+
if (platform === "win") windowsEmbedding.push(value);
|
|
89
94
|
} else if (!value.notarization) throw new PublicationError("PUBLICATION_SIGNATURE_INVALID", "unrecognized sealed signing receipt");
|
|
90
95
|
if (value.notarization) {
|
|
91
96
|
if (value.notarization.status !== "Accepted" || !value.stapling?.length || value.stapling.some((item) => item.validated !== true)) throw new PublicationError("PUBLICATION_NOTARIZATION_INVALID", "notarization/stapling evidence rejected");
|
|
@@ -95,6 +100,9 @@ export function verifyPublicationRelease({ sealedDir, repoRoot, appRoot, commit,
|
|
|
95
100
|
}
|
|
96
101
|
}
|
|
97
102
|
if (!signed) throw new PublicationError("PUBLICATION_SIGNATURE_MISSING", "sealed native signing evidence is required");
|
|
103
|
+
if (platform === "win" && (target?.winPackage || target?.signingContract === "windows-raw-exe-authenticode-before-nsis-v1") && target.externalBin !== undefined) {
|
|
104
|
+
verifySidecarEmbedding(windowsEmbedding, windowsSignatures, manifest.files, target);
|
|
105
|
+
}
|
|
98
106
|
if (platform === "mac" && !notarized) throw new PublicationError("PUBLICATION_NOTARIZATION_MISSING", "sealed notarization evidence is required");
|
|
99
107
|
if (platform === "android" && !androidVerified) throw new PublicationError("PUBLICATION_SIGNATURE_MISSING", "sealed android AAB upload-key receipt is required");
|
|
100
108
|
if (platform === "ios" && !iosVerified) throw new PublicationError("PUBLICATION_SIGNATURE_MISSING", "sealed iOS IPA build receipt is required");
|
|
@@ -107,6 +115,52 @@ export function verifyPublicationRelease({ sealedDir, repoRoot, appRoot, commit,
|
|
|
107
115
|
return { ...sealed, artifacts };
|
|
108
116
|
}
|
|
109
117
|
|
|
118
|
+
function verifySidecarEmbedding(receipts, signatures, files, target) {
|
|
119
|
+
const fail = () => { throw new PublicationError("PUBLICATION_SIGNATURE_INVALID", "sealed installer sidecar embedding evidence rejected"); };
|
|
120
|
+
// Build seals these Authenticode receipts in phase order: raw executables, then installers.
|
|
121
|
+
if (receipts.length !== 1 || signatures.length !== 2) fail();
|
|
122
|
+
const [rawSignatures, installerSignatures] = signatures;
|
|
123
|
+
const { embedded, sidecars, rawExe, externalBinArch } = receipts[0];
|
|
124
|
+
if (typeof externalBinArch !== "string") fail();
|
|
125
|
+
let expected;
|
|
126
|
+
try {
|
|
127
|
+
const config = validateExternalBinConfig(target.externalBin, { platform: "win", hostArch: externalBinArch });
|
|
128
|
+
if (config.arch !== externalBinArch) fail();
|
|
129
|
+
expected = new Map(config.names.map((name) => [
|
|
130
|
+
bundledFileName(name, config.os).toLowerCase(),
|
|
131
|
+
path.win32.join(config.stageDir, stagedFileName(name, config.os, config.arch)).toLowerCase(),
|
|
132
|
+
]));
|
|
133
|
+
if (expected.size !== config.names.length) fail();
|
|
134
|
+
} catch { fail(); }
|
|
135
|
+
if (!Array.isArray(sidecars) || sidecars.length !== expected.size) fail();
|
|
136
|
+
const signedFile = ({ file, signedSha256 }) => typeof file === "string" && rawSignatures.some((item) => item.file === file && item.after.sha256 === signedSha256);
|
|
137
|
+
if (!signedFile(rawExe)) fail();
|
|
138
|
+
const installers = new Map();
|
|
139
|
+
for (const copy of embedded) {
|
|
140
|
+
const signer = installerSignatures.find((item) => item.file === copy.installer && item.before?.sha256 === copy.installerSha256);
|
|
141
|
+
if (!signer || installers.has(copy.installer) || !/^[a-f0-9]{64}$/.test(copy.installerSha256 ?? "")) fail();
|
|
142
|
+
installers.set(copy.installer, signer);
|
|
143
|
+
}
|
|
144
|
+
const sealedInstallers = files.filter(({ role, name }) => /\.exe$/i.test(name) && role.split("+").some((label) => label === "installer" || label === "updater"));
|
|
145
|
+
if (!sealedInstallers.length || sealedInstallers.some(({ sha256 }) => ![...installers.values()].some(({ after }) => after.sha256 === sha256))) fail();
|
|
146
|
+
for (const sidecar of sidecars) {
|
|
147
|
+
const { entry, signedSha256, verifiedSha256, embedded: copies } = sidecar ?? {};
|
|
148
|
+
const key = typeof entry === "string" ? entry.toLowerCase() : null;
|
|
149
|
+
const stagedPath = expected.get(key);
|
|
150
|
+
if (!stagedPath || !signedFile(sidecar) || sidecar.file === rawExe.file
|
|
151
|
+
|| !path.win32.normalize(sidecar.file).toLowerCase().endsWith(`\\${stagedPath}`)
|
|
152
|
+
|| signedSha256 !== verifiedSha256 || !Array.isArray(copies) || copies.length !== installers.size) fail();
|
|
153
|
+
expected.delete(key);
|
|
154
|
+
const seen = new Set();
|
|
155
|
+
for (const copy of copies) {
|
|
156
|
+
const signer = installers.get(copy?.installer);
|
|
157
|
+
if (!signer || seen.has(copy.installer) || copy.installerSha256 !== signer.before.sha256
|
|
158
|
+
|| copy.entry !== entry || copy.sha256 !== signedSha256) fail();
|
|
159
|
+
seen.add(copy.installer);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
110
164
|
// Android AAB receipt (android-release.mjs: contract "android-aab-upload-key-v1"). The receipt was already read from the
|
|
111
165
|
// manifest's signing.receipts and hash-verified by the caller; here it must describe exactly the sealed "aab" file and be
|
|
112
166
|
// signed by the pinned upload certificate. Fails closed with a specific message on any mismatch.
|
package/publish-local-npm.mjs
CHANGED
|
@@ -20,6 +20,7 @@ import os from "node:os";
|
|
|
20
20
|
import path from "node:path";
|
|
21
21
|
import { fileURLToPath } from "node:url";
|
|
22
22
|
import { NPM_KEYCHAIN_SERVICE, readKeychainToken } from "./publication-gate.mjs";
|
|
23
|
+
import { gateReleaseGuard } from "./gate-release-admission.mjs";
|
|
23
24
|
|
|
24
25
|
const REGISTRY = "https://registry.npmjs.org/";
|
|
25
26
|
const GATE = fileURLToPath(new URL("./bin/rightkit-gate.mjs", import.meta.url));
|
|
@@ -116,6 +117,8 @@ export function publishLocalNpm(argv, { run = spawnSync, log = console.log, plat
|
|
|
116
117
|
const sha1 = crypto.createHash("sha1").update(bytes).digest("hex");
|
|
117
118
|
log(`publish-local: packed ${tgz} sha1 ${sha1}`);
|
|
118
119
|
|
|
120
|
+
// GATE-CONTRACT NN31: the gate package is published only with a passing contract-test receipt for this exact file. Before the token is read.
|
|
121
|
+
try { gateReleaseGuard({ name: o.pkg, archiveFile: path.join(work, tgz), commit }); } catch (error) { fail(error.message); }
|
|
119
122
|
const token = readToken();
|
|
120
123
|
const userconfig = path.join(work, "npmrc");
|
|
121
124
|
fs.writeFileSync(userconfig, "//registry.npmjs.org/:_authToken=${RIGHTKIT_NPM_TOKEN}\n", { mode: 0o600 });
|
package/publish-update.mjs
CHANGED
|
@@ -73,7 +73,7 @@ if (!dryRun || releaseId) {
|
|
|
73
73
|
assertPrimaryReleaseCheckout(repoRoot);
|
|
74
74
|
const commit = git(["rev-parse", "HEAD"]);
|
|
75
75
|
assertCleanSource({ status: git(["status", "--porcelain=v1", "-z", "--untracked-files=all"]), commandId: "right-release publish-update" });
|
|
76
|
-
sealed = verifyPublicationRelease({ sealedDir: path.join(repoRoot, ".right-release", "sealed", releaseId, platformDirOf(platform)), repoRoot, appRoot: root, commit, app: config.app, version: versionForStorage, platform, configPath, releaseId });
|
|
76
|
+
sealed = verifyPublicationRelease({ sealedDir: path.join(repoRoot, ".right-release", "sealed", releaseId, platformDirOf(platform)), repoRoot, appRoot: root, commit, app: config.app, version: versionForStorage, platform, configPath, releaseId, target });
|
|
77
77
|
const routes = sealed.manifest.routes?.[githubLane ? "update" : tier] ?? [];
|
|
78
78
|
const configured = githubLane
|
|
79
79
|
? artifacts.map((item) => ({ ...item, key: githubKey(item), role: "updater" }))
|
|
@@ -260,7 +260,7 @@ if (tier === "patch") {
|
|
|
260
260
|
dryRun,
|
|
261
261
|
keep: {
|
|
262
262
|
public: installerKeepKeys(),
|
|
263
|
-
private:
|
|
263
|
+
private: artifacts.map((artifact) => artifact.key),
|
|
264
264
|
},
|
|
265
265
|
retainPreviousVersions: installers.some((artifact) => artifact.versionedKey) ? 1 : 0,
|
|
266
266
|
});
|
package/receipt-signature.mjs
CHANGED
|
@@ -102,3 +102,43 @@ export function verifyProvenanceSignature(receipt, pins, jobId) {
|
|
|
102
102
|
if (typeof jobId !== "string" || payload.jobId !== jobId || receipt.id !== jobId) refuse("job", "the receipt is for another job");
|
|
103
103
|
return payload;
|
|
104
104
|
}
|
|
105
|
+
|
|
106
|
+
// ---- the publication claim (rustright GB-104; loop matrix G27) ---------------------------------------------------------------------------------
|
|
107
|
+
// Beside the full envelope the broker signs a second, small payload made to leave the host: nothing in it names a path or an environment variable.
|
|
108
|
+
// It is signed with the same key over its own first line, so a claim can never be passed off as a full envelope or the reverse.
|
|
109
|
+
export const PUBLICATION_CLAIM_SCHEMA = "rustright.publication-claim.v1";
|
|
110
|
+
export const PUBLICATION_CLAIM_DOMAIN = "rustright-publication-claim-v1";
|
|
111
|
+
/** The exact bytes the broker signs for a publication claim's payload. */
|
|
112
|
+
export function claimSignedBytes(payload) {
|
|
113
|
+
return Buffer.from(`${PUBLICATION_CLAIM_DOMAIN}\n${canonicalJson(payload)}`, "utf8");
|
|
114
|
+
}
|
|
115
|
+
const CLAIM_KEYS = ["broker", "command", "gate", "host", "jobId", "keyId", "nonce", "payloadSha256", "result", "schema"];
|
|
116
|
+
/**
|
|
117
|
+
* Verifies `doc.publication` ({ schema, payload, signature }) against the pins the caller holds and the job it expects; `doc` is { id, publication }.
|
|
118
|
+
* Fails closed with a ProvenanceError and returns the signed payload. The payload may carry exactly the agreed fields and nothing else: a claim
|
|
119
|
+
* with any other key is refused, so nothing private can ride along under a valid signature.
|
|
120
|
+
*/
|
|
121
|
+
export function verifyPublicationClaim(doc, pins, jobId) {
|
|
122
|
+
const claim = doc?.publication;
|
|
123
|
+
if (!isRecord(claim)) refuse("legacy", "the job has no publication claim (its broker makes none)");
|
|
124
|
+
if (claim.schema !== PUBLICATION_CLAIM_SCHEMA) refuse("schema", "unknown publication claim schema");
|
|
125
|
+
const payload = claim.payload; const signature = claim.signature;
|
|
126
|
+
if (!isRecord(payload)) refuse("malformed", "payload is missing");
|
|
127
|
+
if (!isRecord(signature)) refuse("malformed", "signature is missing");
|
|
128
|
+
if (payload.schema !== PUBLICATION_CLAIM_SCHEMA) refuse("schema", "the signed payload is not a publication claim");
|
|
129
|
+
const extra = Object.keys(payload).filter((k) => !CLAIM_KEYS.includes(k));
|
|
130
|
+
if (extra.length) refuse("malformed", `the claim carries fields it may not: ${extra.slice(0, 6).join(", ")}`);
|
|
131
|
+
if (signature.alg !== "ES256") refuse("alg", "signature algorithm must be ES256");
|
|
132
|
+
if (!isRecord(pins) || typeof pins.publicKey !== "string" || !HEX.test(pins.publicKey)) refuse("pin", "pinned public key is not hex");
|
|
133
|
+
if (sha256Hex(Buffer.from(pins.publicKey, "hex")) !== pins.keyId) refuse("pin", "pinned key id does not match the pinned public key");
|
|
134
|
+
if (signature.keyId !== pins.keyId || payload.keyId !== pins.keyId) refuse("key", "the claim was not signed by the pinned key");
|
|
135
|
+
const key = keyFromSec1(pins.publicKey);
|
|
136
|
+
if (typeof signature.value !== "string" || !/^[0-9a-fA-F]+$/.test(signature.value) || signature.value.length !== 128) refuse("signature", "signature is not 64 bytes r||s in hex");
|
|
137
|
+
let good = false;
|
|
138
|
+
try { good = verify("sha256", claimSignedBytes(payload), { key, dsaEncoding: "ieee-p1363" }, Buffer.from(signature.value, "hex")); } catch (error) { if (error instanceof ProvenanceError) throw error; }
|
|
139
|
+
if (!good) refuse("signature", "signature does not verify");
|
|
140
|
+
if (payload.host !== pins.host) refuse("host", "signed for another host");
|
|
141
|
+
if (payload.broker?.brokerDigest !== pins.brokerDigest) refuse("runtime", "signed by another broker runtime");
|
|
142
|
+
if (typeof jobId !== "string" || payload.jobId !== jobId || doc.id !== jobId) refuse("job", "the claim is for another job");
|
|
143
|
+
return payload;
|
|
144
|
+
}
|
package/release.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { expandPackageRecipeTarget } from "./package-recipe-targets.mjs";
|
|
3
|
+
import { winPackageUpdaterDisabled } from "./win-package-recipe.mjs";
|
|
3
4
|
import { access, readFile, readdir } from "node:fs/promises";
|
|
4
5
|
import { createHash } from "node:crypto";
|
|
5
6
|
import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, unlinkSync, writeFileSync } from "node:fs";
|
|
@@ -683,6 +684,7 @@ await runConfiguredChecks({
|
|
|
683
684
|
|
|
684
685
|
let nativeFinalization = null;
|
|
685
686
|
let bundleMarkerReceipts = [];
|
|
687
|
+
let windowsExternalBins = null;
|
|
686
688
|
if (opts.platform === "win" && target.signingContract === MSIX_SIGNING_CONTRACT) {
|
|
687
689
|
// MSIX order: prePackage builds + stages the payload; buildMsix signs inner PE files (DLLs, EXEs),
|
|
688
690
|
// packs the exact signed bytes, signs the package through sign-windows, verifies signer == Publisher,
|
|
@@ -732,6 +734,7 @@ if (opts.platform === "win" && target.signingContract === MSIX_SIGNING_CONTRACT)
|
|
|
732
734
|
if (externalPlan && !opts.dryRun) {
|
|
733
735
|
const signed = Object.fromEntries(externalPre.map((file) => [file.tool, sidecarFileEvidence(file.stagedPath)]));
|
|
734
736
|
writeExternalBinReceipt(root, buildExternalBinReceipt(externalPlan, externalPre, signed));
|
|
737
|
+
windowsExternalBins = { arch: externalPlan.config.arch, files: externalPre };
|
|
735
738
|
}
|
|
736
739
|
if (nativeAssembly?.packageHook && !hasNativeTargetSpecificPrePackage(target, nativeAssembly.packageHook)) {
|
|
737
740
|
await runCommand(nativeAssembly.packageHook, root);
|
|
@@ -856,13 +859,14 @@ if (opts.platform === "win" && target.signingContract === WINDOWS_NSIS_SIGNING_C
|
|
|
856
859
|
// Before the installer earns its own signature, prove it carries the bytes we
|
|
857
860
|
// signed. An installer-only signature on a mutated payload verifies perfectly
|
|
858
861
|
// and still installs a binary Windows rejects.
|
|
859
|
-
await verifyWindowsEmbedding({ root, target, files, markers: bundleMarkerReceipts });
|
|
862
|
+
await verifyWindowsEmbedding({ root, target, files, markers: bundleMarkerReceipts, externalBins: windowsExternalBins });
|
|
860
863
|
await signWindows(files, "installer", root);
|
|
861
864
|
if (target.postSign) await runCommands(target.postSign, root);
|
|
862
865
|
const updaterFiles = [...new Set((target.updater?.artifacts ?? []).map((artifact) => resolveReleaseArtifactPath(root, artifact.file)))];
|
|
863
|
-
|
|
866
|
+
const updaterDisabled = winPackageUpdaterDisabled(config.targets?.win, target);
|
|
867
|
+
if (!updaterFiles.length && !updaterDisabled) fail(`${config.app} win must declare updater.artifacts for post-code-signing minisign`);
|
|
864
868
|
// The key comes from the OS credential provider inside sign-updater; targets.win.updater.keyFile is refused at config validation and never forwarded.
|
|
865
|
-
await run("node", [SIGN_UPDATER, ...(opts.dryRun ? ["--dry-run"] : []), ...updaterFiles.flatMap((file) => ["--file", file])], root);
|
|
869
|
+
if (updaterFiles.length) await run("node", [SIGN_UPDATER, ...(opts.dryRun ? ["--dry-run"] : []), ...updaterFiles.flatMap((file) => ["--file", file])], root);
|
|
866
870
|
}
|
|
867
871
|
|
|
868
872
|
if (target.postSign && opts.platform !== "win" && (opts.platform !== "mac" || runMacPhase("post-sign"))) {
|
|
@@ -2005,47 +2009,61 @@ function verifyMacosNotarizationReceipt(receipt, archive) {
|
|
|
2005
2009
|
* Only the third is proof the shipped artifact is correct; the first two name
|
|
2006
2010
|
* the cause when it is not.
|
|
2007
2011
|
*/
|
|
2008
|
-
async function verifyWindowsEmbedding({ root, target, files, markers }) {
|
|
2012
|
+
async function verifyWindowsEmbedding({ root, target, files, markers, externalBins }) {
|
|
2009
2013
|
if (opts.dryRun) {
|
|
2010
|
-
console.log("dry-run: verify installer embeds the signed raw EXE");
|
|
2014
|
+
console.log("dry-run: verify installer embeds the signed raw EXE and external binaries");
|
|
2011
2015
|
return;
|
|
2012
2016
|
}
|
|
2013
2017
|
const rawFile = resolveDeclaredPath(root, target.sign.prePackageFiles[0]);
|
|
2018
|
+
const payload = [
|
|
2019
|
+
{ file: rawFile, entry: path.basename(rawFile) },
|
|
2020
|
+
...(externalBins?.files ?? []).map(({ stagedPath, bundledName }) => ({ file: stagedPath, entry: bundledName, exactMember: true })),
|
|
2021
|
+
];
|
|
2022
|
+
if (new Set(payload.map(({ entry }) => entry.toLowerCase())).size !== payload.length) {
|
|
2023
|
+
fail("NSIS signed payload entries must have distinct bundled names");
|
|
2024
|
+
}
|
|
2014
2025
|
const rawReceiptPath = windowsReceiptPath(root, "raw-exe");
|
|
2015
2026
|
let rawReceipt;
|
|
2016
2027
|
try { rawReceipt = JSON.parse(readFileSync(rawReceiptPath, "utf8")); } catch { fail(`missing raw EXE signing receipt: ${rawReceiptPath}`); }
|
|
2017
|
-
const signed = rawReceipt.files?.find((item) => path.resolve(item.file) === rawFile);
|
|
2018
|
-
const signedSha256 = signed?.after?.sha256;
|
|
2019
|
-
if (!signedSha256) fail(`raw EXE signing receipt does not record a signed digest for ${rawFile}`);
|
|
2020
|
-
|
|
2021
|
-
await mustExist(rawFile, `signed raw EXE disappeared before packaging completed: ${rawFile}`);
|
|
2022
|
-
const currentSha256 = createHash("sha256").update(readFileSync(rawFile)).digest("hex");
|
|
2023
|
-
if (currentSha256 !== signedSha256) {
|
|
2024
|
-
fail(
|
|
2025
|
-
`packaging rewrote the signed raw EXE: signed sha256 ${signedSha256}, on-disk sha256 ${currentSha256}. `
|
|
2026
|
-
+ "Its Authenticode signature is now invalid. Apply every deterministic byte patch before signing, never after.",
|
|
2027
|
-
);
|
|
2028
|
-
}
|
|
2029
|
-
// signtool, not inference: a hash match proves the bytes, this proves the chain.
|
|
2030
|
-
await run("node", [SIGN_WINDOWS, "--verify-only", rawFile], root);
|
|
2031
2028
|
|
|
2032
|
-
const
|
|
2033
|
-
for (const
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2029
|
+
const signedPayload = [];
|
|
2030
|
+
for (const { file, entry, exactMember } of payload) {
|
|
2031
|
+
const signedSha256 = rawReceipt.files?.find((item) => path.resolve(item.file) === file)?.after?.sha256;
|
|
2032
|
+
if (!signedSha256) fail(`raw EXE signing receipt does not record a signed digest for ${file}`);
|
|
2033
|
+
await mustExist(file, `signed executable disappeared before packaging completed: ${file}`);
|
|
2034
|
+
const verifiedSha256 = createHash("sha256").update(readFileSync(file)).digest("hex");
|
|
2035
|
+
if (verifiedSha256 !== signedSha256) {
|
|
2036
|
+
fail(
|
|
2037
|
+
`packaging rewrote the signed executable ${file}: signed sha256 ${signedSha256}, on-disk sha256 ${verifiedSha256}. `
|
|
2038
|
+
+ "Its Authenticode signature is now invalid. Apply every deterministic byte patch before signing, never after.",
|
|
2039
|
+
);
|
|
2040
|
+
}
|
|
2041
|
+
signedPayload.push({ file, entry, exactMember, signedSha256, verifiedSha256 });
|
|
2042
|
+
}
|
|
2043
|
+
await run("node", [SIGN_WINDOWS, "--verify-only", ...signedPayload.map(({ file }) => file)], root);
|
|
2044
|
+
const verified = [];
|
|
2045
|
+
for (const { file, entry, exactMember, signedSha256, verifiedSha256 } of signedPayload) {
|
|
2046
|
+
const embedded = [];
|
|
2047
|
+
for (const installer of files) {
|
|
2048
|
+
let receipt;
|
|
2049
|
+
try {
|
|
2050
|
+
receipt = verifyNsisEmbeddedBinary({ installer, entryName: entry, expectedSha256: signedSha256, exactMember });
|
|
2051
|
+
} catch (error) {
|
|
2052
|
+
fail(error.message);
|
|
2053
|
+
}
|
|
2054
|
+
console.log(`right-release: ${path.basename(installer)} embeds the signed ${receipt.entry} (sha256 ${receipt.sha256.slice(0, 16)}…)`);
|
|
2055
|
+
embedded.push(receipt);
|
|
2039
2056
|
}
|
|
2040
|
-
|
|
2041
|
-
embedded.push(receipt);
|
|
2057
|
+
verified.push({ file, entry, signedSha256, verifiedSha256, embedded });
|
|
2042
2058
|
}
|
|
2043
2059
|
|
|
2060
|
+
const [{ embedded, entry: _rawEntry, ...rawExe }, ...sidecars] = verified;
|
|
2044
2061
|
const receiptPath = windowsReceiptPath(root, "embedding");
|
|
2045
2062
|
mkdirSync(path.dirname(receiptPath), { recursive: true });
|
|
2046
2063
|
writeFileSync(receiptPath, `${JSON.stringify({
|
|
2047
2064
|
schema: 1,
|
|
2048
|
-
rawExe
|
|
2065
|
+
rawExe,
|
|
2066
|
+
...(sidecars.length ? { sidecars, externalBinArch: externalBins.arch } : {}),
|
|
2049
2067
|
bundleMarkers: markers ?? [],
|
|
2050
2068
|
embedded,
|
|
2051
2069
|
verifiedAt: new Date().toISOString(),
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// Answers the one open gate process keeps for the runs that come after (GATE-CONTRACT NN25, NN26; Adrian: one open process, everything through it).
|
|
2
|
+
//
|
|
3
|
+
// A gate run used to start a child process for every question it had, the same ones on every run of an unchanged commit (witness fixture, Dell,
|
|
4
|
+
// 2026-11-19: 54 child processes on a warm check, three of them `pnpm config ...`). The resident gate (gate-serve.mjs) is the process that stays
|
|
5
|
+
// open, so it holds the answer; a run asks it over its socket, in process (serveRequest), and starts the tool only when it has none.
|
|
6
|
+
//
|
|
7
|
+
// An answer is never trusted on its key alone. It is stored with the files it depends on, each with a mark of what the file was BEFORE the tool
|
|
8
|
+
// was asked (the sha256 of its bytes, or "absent"; for a file over LARGE_FILE_BYTES its size and modification time), and it is given back only
|
|
9
|
+
// when every one of those files still has that mark. The key names the rest: the question, the directory, the environment. So an edited config
|
|
10
|
+
// file, a tool that was updated, another directory or another environment asks again. The store is the resident process's memory: it ends
|
|
11
|
+
// with that process and with any change of the gate's own code (gate-serve.mjs IDENTITY).
|
|
12
|
+
import fs from "node:fs";
|
|
13
|
+
import { createHash } from "node:crypto";
|
|
14
|
+
import { serveRequest } from "./gate-serve.mjs";
|
|
15
|
+
|
|
16
|
+
const sha256 = (value) => createHash("sha256").update(value).digest("hex");
|
|
17
|
+
/** A program file larger than this is marked by its size and modification time: hashing a 100 MB executable on every recall costs more than the child it saves. */
|
|
18
|
+
export const LARGE_FILE_BYTES = 4 * 1024 * 1024;
|
|
19
|
+
|
|
20
|
+
/** `[path, <mark>]`: what a dependency file is right now. The mark is `sha256:<hex>`, `stat:<size>:<mtimeMs>`, `absent` or `unreadable:<code>`. */
|
|
21
|
+
export function fileMark(file, { read = (f) => fs.readFileSync(f), stat = (f) => fs.statSync(f) } = {}) {
|
|
22
|
+
try {
|
|
23
|
+
const st = stat(file);
|
|
24
|
+
if (!st.isFile()) return [file, `unreadable:not-a-file`];
|
|
25
|
+
if (st.size > LARGE_FILE_BYTES) return [file, `stat:${st.size}:${Math.trunc(st.mtimeMs)}`];
|
|
26
|
+
return [file, `sha256:${sha256(read(file))}`];
|
|
27
|
+
} catch (error) { return [file, error?.code === "ENOENT" || error?.code === "ENOTDIR" ? "absent" : `unreadable:${error?.code ?? "unknown"}`]; }
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** The marks of `files` (distinct, in order). Taken BEFORE the tool is asked, so a file that changes while the tool runs cannot be stored as the answer's state. */
|
|
31
|
+
export function fileMarks(files, io = {}) {
|
|
32
|
+
return [...new Set(files.filter((f) => typeof f === "string" && f))].map((f) => fileMark(f, io));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** The key of one question: a sha256 over its parts (any JSON value). */
|
|
36
|
+
export const answerKey = (parts) => sha256(JSON.stringify(parts));
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The kept answer of `key`, or null: when the resident gate has none, cannot be reached, or any file the answer depends on no longer has the
|
|
40
|
+
* mark it had when the answer was stored. `ask` is the transport (tests); the default asks the resident gate in process.
|
|
41
|
+
*/
|
|
42
|
+
export function recallAnswer(key, { env = process.env, ask = serveRequest, read, stat } = {}) {
|
|
43
|
+
let reply = null;
|
|
44
|
+
try { reply = ask({ op: "answer-get", key }, { env }); } catch { reply = null; }
|
|
45
|
+
if (!reply || typeof reply.value !== "string") return null;
|
|
46
|
+
let doc;
|
|
47
|
+
try { doc = JSON.parse(reply.value); } catch { return null; }
|
|
48
|
+
if (!doc || typeof doc.answer !== "string" || !Array.isArray(doc.files)) return null;
|
|
49
|
+
const io = { ...(read ? { read } : {}), ...(stat ? { stat } : {}) };
|
|
50
|
+
for (const mark of doc.files) {
|
|
51
|
+
if (!Array.isArray(mark) || typeof mark[0] !== "string" || typeof mark[1] !== "string") return null;
|
|
52
|
+
if (mark[1].startsWith("unreadable:")) return null; // a file that could not be read proves nothing either way
|
|
53
|
+
if (fileMark(mark[0], io)[1] !== mark[1]) return null;
|
|
54
|
+
}
|
|
55
|
+
return doc.answer;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Stores `answer` under `key` with `marks` (fileMarks taken before the tool was asked). Nothing is stored when a mark is unreadable. A store
|
|
60
|
+
* that cannot be reached is not an error: the next run asks again.
|
|
61
|
+
*/
|
|
62
|
+
export function rememberAnswer(key, answer, marks, { env = process.env, ask = serveRequest } = {}) {
|
|
63
|
+
if (typeof answer !== "string" || !Array.isArray(marks)) return;
|
|
64
|
+
if (marks.some((m) => !Array.isArray(m) || typeof m[1] !== "string" || m[1].startsWith("unreadable:"))) return;
|
|
65
|
+
try { ask({ op: "answer-put", key, value: JSON.stringify({ answer, files: marks }) }, { env }); } catch { /* not kept */ }
|
|
66
|
+
}
|
package/rightkit-ownership.json
CHANGED
|
@@ -375,6 +375,16 @@
|
|
|
375
375
|
"No precise implementation fingerprint; declaration-only inventory, never enforced ownership or verified integration."
|
|
376
376
|
]
|
|
377
377
|
},
|
|
378
|
+
{
|
|
379
|
+
"package": "rightkit-app-icon",
|
|
380
|
+
"capability": "application-icon-extraction",
|
|
381
|
+
"summary": "Resolve bounded application icon PNG bytes or data URLs from executable paths, process names, and macOS bundles, with memory and persistent caches.",
|
|
382
|
+
"fingerprints": [],
|
|
383
|
+
"detection": "declaration-only",
|
|
384
|
+
"policyNotes": [
|
|
385
|
+
"A package declaration does not establish host integration or installed icon behavior."
|
|
386
|
+
]
|
|
387
|
+
},
|
|
378
388
|
{
|
|
379
389
|
"package": "rightkit-app-manager",
|
|
380
390
|
"capability": "app-manager",
|
|
@@ -2703,6 +2713,16 @@
|
|
|
2703
2713
|
"Fingerprints identify review candidates; published two-host replacement qualification is not recorded."
|
|
2704
2714
|
]
|
|
2705
2715
|
},
|
|
2716
|
+
{
|
|
2717
|
+
"package": "rightkit-media-control",
|
|
2718
|
+
"capability": "media-session-control",
|
|
2719
|
+
"summary": "Session-owned pause and restore of external media playback, with Windows GSMTC and a host backend interface.",
|
|
2720
|
+
"fingerprints": [],
|
|
2721
|
+
"detection": "declaration-only",
|
|
2722
|
+
"policyNotes": [
|
|
2723
|
+
"A dependency declaration alone does not establish installed pause and restore behavior."
|
|
2724
|
+
]
|
|
2725
|
+
},
|
|
2706
2726
|
{
|
|
2707
2727
|
"package": "rightkit-media-fetch",
|
|
2708
2728
|
"capability": "media-fetch",
|
|
@@ -4701,17 +4721,6 @@
|
|
|
4701
4721
|
"No precise implementation fingerprint; declaration-only inventory, never enforced ownership or verified integration."
|
|
4702
4722
|
]
|
|
4703
4723
|
},
|
|
4704
|
-
{
|
|
4705
|
-
"package": "@rightkit/dictation-ui",
|
|
4706
|
-
"capability": "dictation-ui",
|
|
4707
|
-
"summary": "Dictation UI: recording pill, microphone and hotkey hooks, voice conversation and dictation pages.",
|
|
4708
|
-
"fingerprints": [],
|
|
4709
|
-
"detection": "declaration-only",
|
|
4710
|
-
"policyNotes": [
|
|
4711
|
-
"Package contract retained; dependency declarations do not verify integration.",
|
|
4712
|
-
"No precise implementation fingerprint; declaration-only inventory, never enforced ownership or verified integration."
|
|
4713
|
-
]
|
|
4714
|
-
},
|
|
4715
4724
|
{
|
|
4716
4725
|
"package": "@rightkit/doc-render",
|
|
4717
4726
|
"capability": "document-rendering",
|