@adea-ai/app-framework-release-tools 0.7.0 → 0.9.0
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/dist/cli.js +350 -185
- package/dist/index.js +326 -48
- package/dist/release-tools-source.json +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -35,7 +35,9 @@ __export(exports_src, {
|
|
|
35
35
|
expandedDesktopDailyProfile: () => expandedDesktopDailyProfile,
|
|
36
36
|
fileIdentity: () => fileIdentity2,
|
|
37
37
|
finalizeReleasePleaseDraft: () => finalizeReleasePleaseDraft,
|
|
38
|
+
inspectAptRepositoryPlan: () => inspectAptRepositoryPlan,
|
|
38
39
|
inspectDailyBatch: () => inspectDailyBatch,
|
|
40
|
+
inspectDailyPreSigning: () => inspectDailyPreSigning,
|
|
39
41
|
inspectStagedStep: () => inspectStagedStep,
|
|
40
42
|
planDailyReleaseMatrix: () => planDailyReleaseMatrix,
|
|
41
43
|
planQualificationRun: () => planQualificationRun2,
|
|
@@ -3849,6 +3851,223 @@ function createDailyBatchR2Store(send) {
|
|
|
3849
3851
|
}
|
|
3850
3852
|
};
|
|
3851
3853
|
}
|
|
3854
|
+
// src/library/apt/inspect-apt-repository-plan.ts
|
|
3855
|
+
import { createHash as createHash10 } from "crypto";
|
|
3856
|
+
|
|
3857
|
+
// src/library/apt/apt-metadata.ts
|
|
3858
|
+
import { createHash as createHash9 } from "crypto";
|
|
3859
|
+
import { gzipSync } from "zlib";
|
|
3860
|
+
var sha256 = (data) => createHash9("sha256").update(data).digest("hex");
|
|
3861
|
+
function stageAptMetadata({ policy, tag, assets, deb, control, now }) {
|
|
3862
|
+
if (!/^v(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)$/.test(tag))
|
|
3863
|
+
throw new Error("Invalid release tag");
|
|
3864
|
+
const { packageName, architecture, assetName: name, suite, origin } = policy;
|
|
3865
|
+
if (!/^[a-z][a-z0-9+.-]{1,62}$/.test(packageName) || architecture !== "amd64" && architecture !== "arm64" || !/^[A-Za-z0-9][A-Za-z0-9_.+-]*\.deb$/.test(name) || suite !== "daily" && suite !== "stable" || !/^[A-Za-z0-9][A-Za-z0-9 .+_-]{0,62}$/.test(origin))
|
|
3866
|
+
throw new Error("Invalid Debian repository policy");
|
|
3867
|
+
const matching = assets.filter((asset) => asset.name === name);
|
|
3868
|
+
if (matching.length !== 1)
|
|
3869
|
+
throw new Error("Require one staged Debian artifact");
|
|
3870
|
+
const asset = matching[0];
|
|
3871
|
+
if (!deb.length || asset.size !== deb.length || asset.sha256 !== sha256(deb))
|
|
3872
|
+
throw new Error("Staged Debian bytes do not match the verified release inventory");
|
|
3873
|
+
const fields = new Map;
|
|
3874
|
+
let lines = control.replaceAll(`\r
|
|
3875
|
+
`, `
|
|
3876
|
+
`).split(`
|
|
3877
|
+
`);
|
|
3878
|
+
if (lines.at(-1) === "")
|
|
3879
|
+
lines = lines.slice(0, -1);
|
|
3880
|
+
for (const [index, line] of lines.entries()) {
|
|
3881
|
+
if (/^[ \t]/.test(line) && index !== 0)
|
|
3882
|
+
continue;
|
|
3883
|
+
const field = /^([a-z][a-z0-9-]*):[ \t]*(.*)$/i.exec(line);
|
|
3884
|
+
if (!field || fields.has(field[1].toLowerCase()))
|
|
3885
|
+
throw new Error("Invalid or duplicate Debian control field");
|
|
3886
|
+
fields.set(field[1].toLowerCase(), field[2]);
|
|
3887
|
+
}
|
|
3888
|
+
for (const key of ["filename", "size", "md5sum", "sha1", "sha256", "sha512"])
|
|
3889
|
+
if (fields.has(key))
|
|
3890
|
+
throw new Error("Debian control includes repository-owned metadata");
|
|
3891
|
+
if (fields.get("package") !== packageName || fields.get("version") !== tag.slice(1) || fields.get("architecture") !== architecture || !fields.get("description"))
|
|
3892
|
+
throw new Error("Unexpected Debian package, version, architecture or description");
|
|
3893
|
+
if (!Number.isFinite(now.getTime()))
|
|
3894
|
+
throw new Error("Invalid release timestamp");
|
|
3895
|
+
const filename = `pool/main/${packageName[0]}/${packageName}/${name}`;
|
|
3896
|
+
const entries = `${lines.join(`
|
|
3897
|
+
`)}
|
|
3898
|
+
Filename: ${filename}
|
|
3899
|
+
Size: ${asset.size}
|
|
3900
|
+
SHA256: ${asset.sha256}
|
|
3901
|
+
|
|
3902
|
+
`;
|
|
3903
|
+
const plain = new TextEncoder().encode(entries);
|
|
3904
|
+
const compressed = gzipSync(plain);
|
|
3905
|
+
const directories = `main/binary-${architecture}`;
|
|
3906
|
+
const members = [
|
|
3907
|
+
[`${directories}/Packages`, plain],
|
|
3908
|
+
[`${directories}/Packages.gz`, compressed]
|
|
3909
|
+
];
|
|
3910
|
+
const release = renderRelease({ origin, suite, now, architectures: [architecture], members });
|
|
3911
|
+
return {
|
|
3912
|
+
packagePath: filename,
|
|
3913
|
+
release,
|
|
3914
|
+
files: new Map([
|
|
3915
|
+
...members,
|
|
3916
|
+
...members.map(([, bytes]) => [`${directories}/by-hash/SHA256/${sha256(bytes)}`, bytes])
|
|
3917
|
+
])
|
|
3918
|
+
};
|
|
3919
|
+
}
|
|
3920
|
+
function renderRelease({
|
|
3921
|
+
origin,
|
|
3922
|
+
suite,
|
|
3923
|
+
now,
|
|
3924
|
+
architectures,
|
|
3925
|
+
members
|
|
3926
|
+
}) {
|
|
3927
|
+
return [
|
|
3928
|
+
`Origin: ${origin}`,
|
|
3929
|
+
`Label: ${origin} ${suite}`,
|
|
3930
|
+
`Suite: ${suite}`,
|
|
3931
|
+
`Codename: ${suite}`,
|
|
3932
|
+
`Date: ${now.toUTCString()}`,
|
|
3933
|
+
`Valid-Until: ${new Date(now.getTime() + 30 * 86400000).toUTCString()}`,
|
|
3934
|
+
`Architectures: ${architectures.join(" ")}`,
|
|
3935
|
+
"Components: main",
|
|
3936
|
+
"Acquire-By-Hash: yes",
|
|
3937
|
+
"SHA256:",
|
|
3938
|
+
...members.map(([path, bytes]) => ` ${sha256(bytes)} ${bytes.length} ${path}`),
|
|
3939
|
+
""
|
|
3940
|
+
].join(`
|
|
3941
|
+
`);
|
|
3942
|
+
}
|
|
3943
|
+
function stageMultiarchAptMetadata(variants) {
|
|
3944
|
+
const [first, second] = variants;
|
|
3945
|
+
if (!first || !second || variants.length !== 2 || new Set(variants.map(({ policy }) => policy.architecture)).size !== 2 || first.policy.assetName === second.policy.assetName || first.policy.packageName !== second.policy.packageName || first.policy.suite !== second.policy.suite || first.policy.origin !== second.policy.origin || first.tag !== second.tag || first.now.getTime() !== second.now.getTime())
|
|
3946
|
+
throw new Error("Require exactly one AMD64 and one ARM64 package for a single APT suite");
|
|
3947
|
+
const staged = variants.toSorted((a, b) => a.policy.architecture.localeCompare(b.policy.architecture, "en")).map((input) => ({
|
|
3948
|
+
...stageAptMetadata(input),
|
|
3949
|
+
architecture: input.policy.architecture,
|
|
3950
|
+
deb: input.deb
|
|
3951
|
+
}));
|
|
3952
|
+
const files = new Map(staged.flatMap((result) => [...result.files]));
|
|
3953
|
+
return {
|
|
3954
|
+
packages: staged.map(({ packagePath, deb }) => ({ packagePath, deb })),
|
|
3955
|
+
files,
|
|
3956
|
+
release: renderRelease({
|
|
3957
|
+
origin: first.policy.origin,
|
|
3958
|
+
suite: first.policy.suite,
|
|
3959
|
+
now: first.now,
|
|
3960
|
+
architectures: staged.map(({ architecture }) => architecture),
|
|
3961
|
+
members: [...files].filter(([path]) => !path.includes("/by-hash/"))
|
|
3962
|
+
})
|
|
3963
|
+
};
|
|
3964
|
+
}
|
|
3965
|
+
|
|
3966
|
+
// src/library/apt/inspect-apt-repository-plan.ts
|
|
3967
|
+
var architectures = ["amd64", "arm64"];
|
|
3968
|
+
var tagPattern2 = /^v(?:0|[1-9]\d{0,8})\.(?:0|[1-9]\d{0,8})\.(?:0|[1-9]\d{0,8})$/;
|
|
3969
|
+
var gitSha2 = /^[a-f0-9]{40}$/;
|
|
3970
|
+
var sha2562 = /^[a-f0-9]{64}$/;
|
|
3971
|
+
var assetNamePattern = /^[A-Za-z0-9][A-Za-z0-9._+-]{0,199}$/;
|
|
3972
|
+
var maxDebBytes = 768 * 1024 ** 2;
|
|
3973
|
+
var maxControlBytes = 64 * 1024;
|
|
3974
|
+
var maxMetadataBytes = 256 * 1024;
|
|
3975
|
+
var hash2 = (bytes) => createHash10("sha256").update(bytes).digest("hex");
|
|
3976
|
+
var scalarIdentityFields = new Set(["package", "version", "architecture"]);
|
|
3977
|
+
function assertUnfoldedIdentity(control, architecture) {
|
|
3978
|
+
let field;
|
|
3979
|
+
for (const line of control.replaceAll(`\r
|
|
3980
|
+
`, `
|
|
3981
|
+
`).split(`
|
|
3982
|
+
`)) {
|
|
3983
|
+
if (/^[ \t]/.test(line)) {
|
|
3984
|
+
if (field && scalarIdentityFields.has(field))
|
|
3985
|
+
throw Error("Folded Debian identity field " + field + " for " + architecture);
|
|
3986
|
+
} else {
|
|
3987
|
+
field = /^([A-Za-z][A-Za-z0-9-]*):/.exec(line)?.[1]?.toLowerCase();
|
|
3988
|
+
}
|
|
3989
|
+
}
|
|
3990
|
+
}
|
|
3991
|
+
function inspectAptRepositoryPlan({
|
|
3992
|
+
expected,
|
|
3993
|
+
verifiedInventory,
|
|
3994
|
+
packages,
|
|
3995
|
+
now
|
|
3996
|
+
}) {
|
|
3997
|
+
const { app, suite, tag, sourceSha, workflowSha, manifestSha256 } = expected;
|
|
3998
|
+
if (app !== "adea" && app !== "cortana" || suite !== "daily" && suite !== "stable" || typeof tag !== "string" || !tagPattern2.test(tag) || typeof sourceSha !== "string" || !gitSha2.test(sourceSha) || /^0+$/.test(sourceSha) || typeof workflowSha !== "string" || !gitSha2.test(workflowSha) || /^0+$/.test(workflowSha) || typeof manifestSha256 !== "string" || !sha2562.test(manifestSha256) || /^0+$/.test(manifestSha256) || !(now instanceof Date) || !Number.isFinite(now.getTime()))
|
|
3999
|
+
throw Error("Invalid expected APT release identity");
|
|
4000
|
+
if (verifiedInventory.app !== app || verifiedInventory.suite !== suite || verifiedInventory.tag !== tag || verifiedInventory.sourceSha !== sourceSha || verifiedInventory.workflowSha !== workflowSha || verifiedInventory.manifestSha256 !== manifestSha256 || !Array.isArray(verifiedInventory.assets) || verifiedInventory.assets.length < 2 || verifiedInventory.assets.length > 256)
|
|
4001
|
+
throw Error("APT inventory bindings do not match the exact release");
|
|
4002
|
+
const inventory = new Map;
|
|
4003
|
+
for (const asset of verifiedInventory.assets) {
|
|
4004
|
+
if (!asset || typeof asset.name !== "string" || !assetNamePattern.test(asset.name) || typeof asset.sha256 !== "string" || !sha2562.test(asset.sha256) || !Number.isSafeInteger(asset.size) || asset.size < 1 || inventory.has(asset.name))
|
|
4005
|
+
throw Error("Invalid or duplicate APT inventory asset");
|
|
4006
|
+
inventory.set(asset.name, asset);
|
|
4007
|
+
}
|
|
4008
|
+
if (!Array.isArray(packages) || packages.length !== architectures.length)
|
|
4009
|
+
throw Error("APT plan needs exactly two ordinary packages");
|
|
4010
|
+
const origin = app === "adea" ? "Adea" : "Cortana";
|
|
4011
|
+
const packageName = app + "-desktop";
|
|
4012
|
+
const checkedInputs = architectures.map((architecture) => {
|
|
4013
|
+
const matches = packages.filter((entry) => entry?.architecture === architecture);
|
|
4014
|
+
if (matches.length !== 1)
|
|
4015
|
+
throw Error("APT plan needs exactly one package for " + architecture);
|
|
4016
|
+
const { bytes, control } = matches[0];
|
|
4017
|
+
const assetName = origin + "-" + tag + "-linux-" + (architecture === "amd64" ? "x64" : "arm64") + ".deb";
|
|
4018
|
+
const binding = inventory.get(assetName);
|
|
4019
|
+
if (!binding)
|
|
4020
|
+
throw Error("Missing independently bound APT package for " + architecture);
|
|
4021
|
+
if (!(bytes instanceof Uint8Array) || bytes.buffer instanceof SharedArrayBuffer || bytes.length !== binding.size || bytes.length > maxDebBytes || hash2(bytes) !== binding.sha256)
|
|
4022
|
+
throw Error("APT package bytes differ from verified inventory for " + architecture);
|
|
4023
|
+
if (typeof control !== "string" || !control || Buffer.byteLength(control) > maxControlBytes || containsAsciiControl(control.replaceAll(`\r
|
|
4024
|
+
`, `
|
|
4025
|
+
`).replaceAll(`
|
|
4026
|
+
`, "").replaceAll("\t", "")))
|
|
4027
|
+
throw Error("Invalid Debian control data for " + architecture);
|
|
4028
|
+
assertUnfoldedIdentity(control, architecture);
|
|
4029
|
+
return {
|
|
4030
|
+
policy: { packageName, assetName, architecture, suite, origin },
|
|
4031
|
+
tag,
|
|
4032
|
+
now,
|
|
4033
|
+
assets: [binding],
|
|
4034
|
+
deb: bytes,
|
|
4035
|
+
control
|
|
4036
|
+
};
|
|
4037
|
+
});
|
|
4038
|
+
const staged = stageMultiarchAptMetadata(checkedInputs);
|
|
4039
|
+
const documents = [
|
|
4040
|
+
{ path: "dists/" + suite + "/Release", bytes: new TextEncoder().encode(staged.release) },
|
|
4041
|
+
...Array.from(staged.files, ([path, bytes]) => ({
|
|
4042
|
+
path: "dists/" + suite + "/" + path,
|
|
4043
|
+
bytes
|
|
4044
|
+
})).filter(({ path }) => path.includes("/by-hash/"))
|
|
4045
|
+
].map(({ path, bytes }) => {
|
|
4046
|
+
if (bytes.length < 1 || bytes.length > maxMetadataBytes)
|
|
4047
|
+
throw Error("APT metadata size exceeded");
|
|
4048
|
+
return { path, bytes, size: bytes.length, sha256: hash2(bytes) };
|
|
4049
|
+
});
|
|
4050
|
+
const packagesToInspect = staged.packages.map(({ packagePath }, index) => {
|
|
4051
|
+
const { policy, assets } = checkedInputs[index];
|
|
4052
|
+
const binding = assets[0];
|
|
4053
|
+
return {
|
|
4054
|
+
path: packagePath,
|
|
4055
|
+
architecture: policy.architecture,
|
|
4056
|
+
name: binding.name,
|
|
4057
|
+
size: binding.size,
|
|
4058
|
+
sha256: binding.sha256
|
|
4059
|
+
};
|
|
4060
|
+
});
|
|
4061
|
+
return {
|
|
4062
|
+
schema: "framework/apt-inspection/v1",
|
|
4063
|
+
identity: { app, suite, tag, sourceSha, workflowSha, manifestSha256 },
|
|
4064
|
+
selectedPackages: packagesToInspect,
|
|
4065
|
+
unsignedMetadata: documents,
|
|
4066
|
+
inventoryAuthenticatedByPlanner: false,
|
|
4067
|
+
repositorySigningAuthorized: false,
|
|
4068
|
+
publicationAuthorized: false
|
|
4069
|
+
};
|
|
4070
|
+
}
|
|
3852
4071
|
// src/library/apt/apt-r2-store.ts
|
|
3853
4072
|
var key = /^apt\/(?:adea|cortana)\/(?:archive-keyring\.gpg|dists\/(?:daily|stable)\/(?:InRelease|main\/binary-(?:amd64|arm64)\/by-hash\/SHA256\/[0-9a-f]{64})|pool\/main\/(?:a\/adea-desktop\/Adea|c\/cortana-desktop\/Cortana)-v(?:0|[1-9]\d{0,8})\.(?:0|[1-9]\d{0,8})\.(?:0|[1-9]\d{0,8})-linux-(?:x64|arm64)\.deb)$/;
|
|
3854
4073
|
var pointer2 = /^apt\/(?:adea|cortana)\/dists\/(?:daily|stable)\/InRelease$/;
|
|
@@ -3932,7 +4151,7 @@ function createAptR2Store(send) {
|
|
|
3932
4151
|
};
|
|
3933
4152
|
}
|
|
3934
4153
|
// src/library/apt/publish-apt-repository.ts
|
|
3935
|
-
import { createHash as
|
|
4154
|
+
import { createHash as createHash11 } from "crypto";
|
|
3936
4155
|
import { gunzipSync } from "zlib";
|
|
3937
4156
|
var ARCHES = ["amd64", "arm64"];
|
|
3938
4157
|
var version = /^(?:0|[1-9]\d{0,8})\.(?:0|[1-9]\d{0,8})\.(?:0|[1-9]\d{0,8})$/;
|
|
@@ -3940,7 +4159,7 @@ var hex3 = /^[0-9a-f]{64}$/;
|
|
|
3940
4159
|
var indexLimit = 256 * 1024;
|
|
3941
4160
|
var debLimit = 768 * 1024 ** 2;
|
|
3942
4161
|
var etag = /^"[0-9a-f]{32}(?:-[1-9]\d{0,6})?"$/i;
|
|
3943
|
-
var digest = (bytes) =>
|
|
4162
|
+
var digest = (bytes) => createHash11("sha256").update(bytes).digest("hex");
|
|
3944
4163
|
var decode = (bytes) => new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
3945
4164
|
var same2 = (a, b) => Buffer.from(a).equals(b);
|
|
3946
4165
|
function need(condition, message) {
|
|
@@ -4080,7 +4299,7 @@ async function publishAptRepository({ app, suite, tag, assets }, port, now = Dat
|
|
|
4080
4299
|
return { tag, changed: true };
|
|
4081
4300
|
}
|
|
4082
4301
|
// src/library/apt/verify-apt-signature.ts
|
|
4083
|
-
import { createHash as
|
|
4302
|
+
import { createHash as createHash12 } from "crypto";
|
|
4084
4303
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
4085
4304
|
import { mkdtemp as mkdtemp3, readFile as readFile5, rm as rm3, writeFile as writeFile3 } from "fs/promises";
|
|
4086
4305
|
import { tmpdir as tmpdir4 } from "os";
|
|
@@ -4088,7 +4307,7 @@ import { join as join8 } from "path";
|
|
|
4088
4307
|
function createAptSignatureVerifier(config) {
|
|
4089
4308
|
const { fingerprint } = config;
|
|
4090
4309
|
const keyring = Buffer.from(config.keyring);
|
|
4091
|
-
if (keyring.length < 1 || keyring.length > 64 * 1024 || !/^[A-F0-9]{40}$/.test(fingerprint) || !/^[0-9a-f]{64}$/.test(config.sha256) ||
|
|
4310
|
+
if (keyring.length < 1 || keyring.length > 64 * 1024 || !/^[A-F0-9]{40}$/.test(fingerprint) || !/^[0-9a-f]{64}$/.test(config.sha256) || createHash12("sha256").update(keyring).digest("hex") !== config.sha256)
|
|
4092
4311
|
throw Error("Untrusted APT signing keyring");
|
|
4093
4312
|
return async (bytes) => {
|
|
4094
4313
|
if (bytes.length < 1 || bytes.length > 256 * 1024)
|
|
@@ -4127,6 +4346,7 @@ import { join as join10 } from "path";
|
|
|
4127
4346
|
import { Effect as Effect17 } from "effect";
|
|
4128
4347
|
|
|
4129
4348
|
// src/library/daily-matrix.ts
|
|
4349
|
+
import { createHash as createHash13 } from "crypto";
|
|
4130
4350
|
import { join as join9 } from "path";
|
|
4131
4351
|
import { Effect as Effect16 } from "effect";
|
|
4132
4352
|
|
|
@@ -4417,30 +4637,43 @@ function readNativeReceipt(path, label) {
|
|
|
4417
4637
|
const after = await file.stat();
|
|
4418
4638
|
if (!sameFile(before, after) || before.ctimeMs !== after.ctimeMs)
|
|
4419
4639
|
throw new Error("Native receipt changed during read");
|
|
4420
|
-
return bytes
|
|
4640
|
+
return bytes;
|
|
4421
4641
|
});
|
|
4422
4642
|
return yield* attempt(() => {
|
|
4423
4643
|
try {
|
|
4424
|
-
return
|
|
4644
|
+
return {
|
|
4645
|
+
value: JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(data)),
|
|
4646
|
+
size: data.length,
|
|
4647
|
+
digest: "sha256:" + createHash13("sha256").update(data).digest("hex")
|
|
4648
|
+
};
|
|
4425
4649
|
} catch {
|
|
4426
4650
|
throw new Error(`Invalid native receipt JSON: ${label}`);
|
|
4427
4651
|
}
|
|
4428
4652
|
});
|
|
4429
4653
|
}).pipe(Effect16.scoped);
|
|
4430
4654
|
}
|
|
4431
|
-
var
|
|
4655
|
+
var verifiedMatrix = (options, verifyPrior) => Effect16.gen(function* () {
|
|
4432
4656
|
const { config, identity, artifacts, receipts } = options;
|
|
4433
4657
|
const { tag } = identity;
|
|
4434
4658
|
yield* attempt(() => assertDailyIdentity(identity));
|
|
4435
4659
|
const matrix = yield* attempt(() => planDailyReleaseMatrix(config, tag));
|
|
4436
|
-
|
|
4437
|
-
|
|
4660
|
+
if (verifyPrior && matrix.profile !== expandedDesktopDailyProfile)
|
|
4661
|
+
return yield* fail("Pre-signing validation requires the expanded Daily profile");
|
|
4662
|
+
const payloadNames = new Set(matrix.checks.flatMap((check) => check.assets));
|
|
4663
|
+
const selected = verifyPrior ? matrix.assets.filter((name) => payloadNames.has(name)) : matrix.assets;
|
|
4664
|
+
const receiptNames = matrix.checks.map((check) => check.name + ".json");
|
|
4665
|
+
yield* exactDirectory(artifacts, selected);
|
|
4666
|
+
yield* exactDirectory(receipts, receiptNames);
|
|
4438
4667
|
const inventory = new Map;
|
|
4439
|
-
|
|
4668
|
+
const checkedReceipts = [];
|
|
4669
|
+
const claims = [];
|
|
4670
|
+
for (const name of selected)
|
|
4440
4671
|
inventory.set(name, yield* fileIdentityEffect(join9(artifacts, name), name));
|
|
4441
4672
|
for (const check of matrix.checks) {
|
|
4442
|
-
const
|
|
4443
|
-
yield*
|
|
4673
|
+
const filename = check.name + ".json";
|
|
4674
|
+
const raw = yield* readNativeReceipt(join9(receipts, filename), check.name);
|
|
4675
|
+
checkedReceipts.push({ name: filename, size: raw.size, digest: raw.digest });
|
|
4676
|
+
const valid = yield* attempt(() => validateDailyNativeEvidence(raw.value, "framework/daily-native-receipt/v2", {
|
|
4444
4677
|
appId: matrix.appId,
|
|
4445
4678
|
profile: matrix.profile,
|
|
4446
4679
|
signing: requiresDailyInstallerSigning(matrix.profile, check) ? installerSigningPolicy(config, check) : undefined,
|
|
@@ -4449,14 +4682,57 @@ var verifyDailyReleaseMatrixEffect = (options) => Effect16.gen(function* () {
|
|
|
4449
4682
|
assets: check.assets.map((name) => inventory.get(name)),
|
|
4450
4683
|
baselineNames: (priorTag) => priorDailyInstallerNames(config, priorTag, check)
|
|
4451
4684
|
}));
|
|
4685
|
+
if (verifyPrior && "upgrade" in valid.observations) {
|
|
4686
|
+
const claim = {
|
|
4687
|
+
appId: matrix.appId,
|
|
4688
|
+
check: check.name,
|
|
4689
|
+
platform: check.platform,
|
|
4690
|
+
upgrade: valid.observations.upgrade,
|
|
4691
|
+
...valid.installerSigning ? { installerSigning: valid.installerSigning } : {}
|
|
4692
|
+
};
|
|
4693
|
+
claims.push(claim);
|
|
4694
|
+
}
|
|
4695
|
+
}
|
|
4696
|
+
const assets = [...inventory.values()];
|
|
4697
|
+
if (verifyPrior) {
|
|
4698
|
+
for (const claim of claims)
|
|
4699
|
+
if ((yield* step(() => verifyPrior(claim))) !== true)
|
|
4700
|
+
return yield* fail("Prior Daily installer or payload is not independently authorized");
|
|
4701
|
+
yield* exactDirectory(artifacts, selected);
|
|
4702
|
+
yield* exactDirectory(receipts, receiptNames);
|
|
4703
|
+
for (const [root, files] of [
|
|
4704
|
+
[artifacts, assets],
|
|
4705
|
+
[receipts, checkedReceipts]
|
|
4706
|
+
]) {
|
|
4707
|
+
for (const expected of files) {
|
|
4708
|
+
const actual = yield* fileIdentityEffect(join9(root, expected.name), expected.name);
|
|
4709
|
+
if (actual.digest !== expected.digest || actual.size !== expected.size)
|
|
4710
|
+
return yield* fail("Daily pre-signing input changed during validation");
|
|
4711
|
+
}
|
|
4712
|
+
}
|
|
4452
4713
|
}
|
|
4714
|
+
return { profile: matrix.profile, appId: matrix.appId, identity, assets, checkedReceipts };
|
|
4715
|
+
});
|
|
4716
|
+
var verifyDailyReleaseMatrixEffect = (options) => Effect16.map(verifiedMatrix(options), ({ profile, appId, identity, assets }) => ({
|
|
4717
|
+
profile,
|
|
4718
|
+
appId,
|
|
4719
|
+
identity,
|
|
4720
|
+
assets
|
|
4721
|
+
}));
|
|
4722
|
+
var inspectDailyPreSigningEffect = (options, verifyPrior) => Effect16.gen(function* () {
|
|
4723
|
+
if (typeof verifyPrior !== "function")
|
|
4724
|
+
return yield* fail("Expected an independent prior verifier");
|
|
4725
|
+
const { checkedReceipts, ...payloads } = yield* verifiedMatrix(options, verifyPrior);
|
|
4453
4726
|
return {
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4727
|
+
...payloads,
|
|
4728
|
+
receipts: checkedReceipts,
|
|
4729
|
+
descriptorSigningAuthorized: false,
|
|
4730
|
+
promotionAuthorized: false
|
|
4458
4731
|
};
|
|
4459
4732
|
});
|
|
4733
|
+
function inspectDailyPreSigning(options, verifyPrior) {
|
|
4734
|
+
return runReleaseLibrary(provideLibraryPorts()(inspectDailyPreSigningEffect(options, verifyPrior)));
|
|
4735
|
+
}
|
|
4460
4736
|
function verifyDailyReleaseMatrix(options) {
|
|
4461
4737
|
return runReleaseLibrary(provideLibraryPorts()(verifyDailyReleaseMatrixEffect(options)));
|
|
4462
4738
|
}
|
|
@@ -4654,7 +4930,7 @@ function createDailyNativeReceipt(options) {
|
|
|
4654
4930
|
})));
|
|
4655
4931
|
}
|
|
4656
4932
|
// src/library/linux-reproducibility.ts
|
|
4657
|
-
import { createHash as
|
|
4933
|
+
import { createHash as createHash14 } from "crypto";
|
|
4658
4934
|
import { lstat as lstat6, readFile as readFile6, readdir as readdir5, realpath } from "fs/promises";
|
|
4659
4935
|
import { isAbsolute as isAbsolute2, join as join12, resolve as resolve6 } from "path";
|
|
4660
4936
|
|
|
@@ -4668,7 +4944,7 @@ function isLinuxPackageArchitecture(value) {
|
|
|
4668
4944
|
}
|
|
4669
4945
|
|
|
4670
4946
|
// src/library/linux-reproducibility.ts
|
|
4671
|
-
var
|
|
4947
|
+
var sha2563 = /^[a-f0-9]{64}$/;
|
|
4672
4948
|
var digest3 = /^sha256:[a-f0-9]{64}$/;
|
|
4673
4949
|
var circleciImage = /^ubuntu-2404:[0-9]{4}\.(?:0[1-9]|1[0-2])\.[0-9]+$/;
|
|
4674
4950
|
var identifier = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,199}$/;
|
|
@@ -4719,7 +4995,7 @@ async function compareLinuxReproducibility(rawInput) {
|
|
|
4719
4995
|
check2(isLinuxPackageArchitecture(architecture), "Invalid Linux comparison architecture");
|
|
4720
4996
|
const target = linuxPackageArchitectures[architecture];
|
|
4721
4997
|
assertDailyIdentity(input.identity);
|
|
4722
|
-
check2(Number.isSafeInteger(input.sourceDateEpoch) && input.sourceDateEpoch > 0 && input.sourceDateEpoch <= 4294967295 && Number.isSafeInteger(input.archive?.size) && input.archive.size > 0 &&
|
|
4998
|
+
check2(Number.isSafeInteger(input.sourceDateEpoch) && input.sourceDateEpoch > 0 && input.sourceDateEpoch <= 4294967295 && Number.isSafeInteger(input.archive?.size) && input.archive.size > 0 && sha2563.test(input.archive.sha256) && circleciImage.test(input.imageReference) && digest3.test(input.toolchainDigest), "Invalid protected Linux build identity");
|
|
4723
4999
|
check2(isRecord(input.config) && typeof input.config.appId === "string", "Invalid app identity");
|
|
4724
5000
|
const requirements = parseReleaseConfig(input.config).requirements(input.identity.tag);
|
|
4725
5001
|
const archiveName = requirements.platforms[target.platform]?.[1];
|
|
@@ -4784,7 +5060,7 @@ async function compareLinuxReproducibility(rawInput) {
|
|
|
4784
5060
|
observed.push({ path, file });
|
|
4785
5061
|
check2(file.size <= 65536, "Producer receipt is too large");
|
|
4786
5062
|
const bytes = await readFile6(path);
|
|
4787
|
-
check2(bytes.length === file.size &&
|
|
5063
|
+
check2(bytes.length === file.size && createHash14("sha256").update(bytes).digest("hex") === file.sha256, "Producer receipt changed");
|
|
4788
5064
|
let receipt;
|
|
4789
5065
|
try {
|
|
4790
5066
|
receipt = JSON.parse(bytes.toString("utf8"));
|
|
@@ -4930,7 +5206,7 @@ function createMacosDmg(options) {
|
|
|
4930
5206
|
import { Effect as Effect22 } from "effect";
|
|
4931
5207
|
|
|
4932
5208
|
// src/library/local-release.ts
|
|
4933
|
-
import { createHash as
|
|
5209
|
+
import { createHash as createHash16 } from "crypto";
|
|
4934
5210
|
import { constants as constants3 } from "fs";
|
|
4935
5211
|
import { dirname as dirname2, join as join15, resolve as resolve9 } from "path";
|
|
4936
5212
|
import { Cause as Cause2, Effect as Effect21, Exit as Exit3 } from "effect";
|
|
@@ -5100,7 +5376,7 @@ function createFeedReleaseCutProvider(options) {
|
|
|
5100
5376
|
}
|
|
5101
5377
|
|
|
5102
5378
|
// src/library/feed-state.ts
|
|
5103
|
-
import { createHash as
|
|
5379
|
+
import { createHash as createHash15 } from "crypto";
|
|
5104
5380
|
import { Effect as Effect20 } from "effect";
|
|
5105
5381
|
|
|
5106
5382
|
// ../../src/shared/discard-stream.ts
|
|
@@ -5348,7 +5624,7 @@ var verifyFeedReleaseEffect = (options) => Effect20.gen(function* () {
|
|
|
5348
5624
|
if (!listed)
|
|
5349
5625
|
return yield* fail(`Missing signed descriptor: ${policy.name}`);
|
|
5350
5626
|
const bytes = yield* feedObject(feed, `${tag}/${policy.name}`, 65536);
|
|
5351
|
-
if (!bytes || bytes.length !== listed.size ||
|
|
5627
|
+
if (!bytes || bytes.length !== listed.size || createHash15("sha256").update(bytes).digest("hex") !== listed.sha256)
|
|
5352
5628
|
return yield* fail(`Signed descriptor differs from its release: ${policy.name}`);
|
|
5353
5629
|
const verified = verifyReleaseDescriptor(json(bytes), {
|
|
5354
5630
|
appId: policy.appId,
|
|
@@ -5492,7 +5768,7 @@ var jsonBytes = (value) => Buffer.from(JSON.stringify(value, null, 2) + `
|
|
|
5492
5768
|
var describe = (key, bytes, cacheControl) => ({
|
|
5493
5769
|
key,
|
|
5494
5770
|
size: bytes.length,
|
|
5495
|
-
sha256:
|
|
5771
|
+
sha256: createHash16("sha256").update(bytes).digest("hex"),
|
|
5496
5772
|
contentType: "application/json",
|
|
5497
5773
|
cacheControl
|
|
5498
5774
|
});
|
|
@@ -5581,7 +5857,7 @@ var stageLocalReleaseEffect = (options) => Effect21.gen(function* () {
|
|
|
5581
5857
|
if (artifact.size > 65536)
|
|
5582
5858
|
return yield* fail("Signed descriptor is too large");
|
|
5583
5859
|
const bytes = yield* step(() => fs.readFile(join15(directory, policy.name)));
|
|
5584
|
-
if ("sha256:" +
|
|
5860
|
+
if ("sha256:" + createHash16("sha256").update(bytes).digest("hex") !== artifact.digest)
|
|
5585
5861
|
return yield* fail("Signed descriptor changed");
|
|
5586
5862
|
let parsed;
|
|
5587
5863
|
try {
|
|
@@ -5940,12 +6216,12 @@ var selectRetainedReleaseBuildEffect = (options) => Effect23.gen(function* () {
|
|
|
5940
6216
|
});
|
|
5941
6217
|
var selectRetainedReleaseBuild = (options) => runReleaseLibrary(provideLibraryPorts({ run: planGitHubRun(options.env, options.run) })(selectRetainedReleaseBuildEffect(options)));
|
|
5942
6218
|
// src/library/staging.ts
|
|
5943
|
-
import { createHash as
|
|
6219
|
+
import { createHash as createHash17 } from "crypto";
|
|
5944
6220
|
import { join as join16, resolve as resolve10 } from "path";
|
|
5945
6221
|
import { Effect as Effect24 } from "effect";
|
|
5946
6222
|
var copyHashed = (input, output, size) => Effect24.tryPromise({
|
|
5947
6223
|
try: async (signal) => {
|
|
5948
|
-
const hash =
|
|
6224
|
+
const hash = createHash17("sha256");
|
|
5949
6225
|
let copied = 0;
|
|
5950
6226
|
for await (const chunk of input.createReadStream({
|
|
5951
6227
|
autoClose: false
|
|
@@ -6015,7 +6291,7 @@ import { join as join36 } from "path";
|
|
|
6015
6291
|
import { Effect as Effect25 } from "effect";
|
|
6016
6292
|
|
|
6017
6293
|
// ../../src/installer/installer-archive-members.ts
|
|
6018
|
-
import { createHash as
|
|
6294
|
+
import { createHash as createHash18 } from "crypto";
|
|
6019
6295
|
import { lstat as lstat7, open as open5 } from "fs/promises";
|
|
6020
6296
|
import { isAbsolute as isAbsolute4, relative as relative4, sep as sep2 } from "path";
|
|
6021
6297
|
|
|
@@ -6122,7 +6398,7 @@ async function assertEmbeddedArchive(path, size, archive) {
|
|
|
6122
6398
|
const position = size - archive.size - marker.length, actual = Buffer.alloc(marker.length);
|
|
6123
6399
|
if ((await file.read(actual, 0, actual.length, position)).bytesRead !== actual.length || !actual.equals(marker))
|
|
6124
6400
|
throw new Error("Installer archive marker is missing");
|
|
6125
|
-
const hash =
|
|
6401
|
+
const hash = createHash18("sha256");
|
|
6126
6402
|
let read = 0;
|
|
6127
6403
|
for await (const chunk of file.createReadStream({
|
|
6128
6404
|
start: position + marker.length,
|
|
@@ -7009,7 +7285,7 @@ function assertInstallerRendererObservation(value, offline = false) {
|
|
|
7009
7285
|
}
|
|
7010
7286
|
|
|
7011
7287
|
// ../../src/installer/installed-payload.ts
|
|
7012
|
-
import { createHash as
|
|
7288
|
+
import { createHash as createHash19 } from "crypto";
|
|
7013
7289
|
import { lstat as lstat12, open as open6, realpath as realpath5, rm as rm7 } from "fs/promises";
|
|
7014
7290
|
import { once as once2 } from "events";
|
|
7015
7291
|
import { join as join21, resolve as resolve13 } from "path";
|
|
@@ -7035,7 +7311,7 @@ async function command2(args, env, limit, collect) {
|
|
|
7035
7311
|
const errors = (async () => {
|
|
7036
7312
|
for await (const _part of child.stderr) {}
|
|
7037
7313
|
})();
|
|
7038
|
-
const hash =
|
|
7314
|
+
const hash = createHash19("sha256"), chunks = [];
|
|
7039
7315
|
let size = 0;
|
|
7040
7316
|
try {
|
|
7041
7317
|
for await (const part of child.stdout) {
|
|
@@ -7089,7 +7365,7 @@ async function readMembers(archive, limits, collect) {
|
|
|
7089
7365
|
failure ??= new Error("Archive member missing or ambiguous");
|
|
7090
7366
|
return entry.resume();
|
|
7091
7367
|
}
|
|
7092
|
-
const hash =
|
|
7368
|
+
const hash = createHash19("sha256"), chunks = [];
|
|
7093
7369
|
const member = { digest: "", size: 0, bytes: Buffer.alloc(0), count: 1 };
|
|
7094
7370
|
members.set(entry.path, member);
|
|
7095
7371
|
entry.on("data", (chunk) => {
|
|
@@ -7231,7 +7507,7 @@ async function extractCandidateRuntime(options) {
|
|
|
7231
7507
|
const child = spawn(), errors = (async () => {
|
|
7232
7508
|
for await (const _part of child.stderr) {}
|
|
7233
7509
|
})();
|
|
7234
|
-
const hash =
|
|
7510
|
+
const hash = createHash19("sha256");
|
|
7235
7511
|
let size = 0;
|
|
7236
7512
|
try {
|
|
7237
7513
|
for await (const part of child.stdout) {
|
|
@@ -7465,7 +7741,7 @@ function planUpdateHandoff(options) {
|
|
|
7465
7741
|
}
|
|
7466
7742
|
|
|
7467
7743
|
// ../../src/updates/install/update-extraction.ts
|
|
7468
|
-
import { createHash as
|
|
7744
|
+
import { createHash as createHash20 } from "crypto";
|
|
7469
7745
|
import { constants as constants4 } from "fs";
|
|
7470
7746
|
import { lstat as lstat13, mkdir as mkdir7, mkdtemp as mkdtemp8, open as open7, readFile as readFile8, realpath as realpath7, rm as rm8, symlink } from "fs/promises";
|
|
7471
7747
|
import { isAbsolute as isAbsolute6, join as join22 } from "path";
|
|
@@ -7540,7 +7816,7 @@ async function extractBoundArchive(options, descriptor, verifyBeforeExtraction)
|
|
|
7540
7816
|
done(null, chunk);
|
|
7541
7817
|
}
|
|
7542
7818
|
});
|
|
7543
|
-
const hash =
|
|
7819
|
+
const hash = createHash20("sha256");
|
|
7544
7820
|
let compressedBytes = 0;
|
|
7545
7821
|
const verifyInput = new Transform({
|
|
7546
7822
|
transform(chunk, _encoding, done) {
|
|
@@ -7696,7 +7972,7 @@ async function extractBoundArchive(options, descriptor, verifyBeforeExtraction)
|
|
|
7696
7972
|
}
|
|
7697
7973
|
|
|
7698
7974
|
// ../../src/updates/install/update-swap.ts
|
|
7699
|
-
import { createHash as
|
|
7975
|
+
import { createHash as createHash21 } from "crypto";
|
|
7700
7976
|
import { constants as constants7 } from "fs";
|
|
7701
7977
|
import { lstat as lstat14, open as open10, readdir as readdir9, readFile as readFile9, readlink as readlink2 } from "fs/promises";
|
|
7702
7978
|
import { basename as basename8, dirname as dirname6, join as join25 } from "path";
|
|
@@ -8052,7 +8328,7 @@ async function readTreeFileBytes(file, buffer, length, position) {
|
|
|
8052
8328
|
}
|
|
8053
8329
|
async function readUpdateTreeDigest(tree, options = {}) {
|
|
8054
8330
|
const allowHardLinkedFiles = options.allowHardLinkedFiles === true;
|
|
8055
|
-
const hash =
|
|
8331
|
+
const hash = createHash21("sha256");
|
|
8056
8332
|
hash.update("adea-framework-update-tree\x00v1\x00", "utf8");
|
|
8057
8333
|
const root = await lstat14(tree, { bigint: true });
|
|
8058
8334
|
if (!root.isDirectory() || root.isSymbolicLink())
|
|
@@ -9070,7 +9346,7 @@ import { lstat as lstat20, mkdir as mkdir10, rename as rename2, writeFile as wri
|
|
|
9070
9346
|
import { join as join35, resolve as resolve16 } from "path";
|
|
9071
9347
|
|
|
9072
9348
|
// ../../src/installer/upgrade-asset-download.ts
|
|
9073
|
-
import { createHash as
|
|
9349
|
+
import { createHash as createHash22 } from "crypto";
|
|
9074
9350
|
import { open as open11, unlink as unlink3 } from "fs/promises";
|
|
9075
9351
|
|
|
9076
9352
|
// ../../src/installer/write-all.ts
|
|
@@ -9108,7 +9384,7 @@ async function downloadAsset(options) {
|
|
|
9108
9384
|
discardStream(response.body);
|
|
9109
9385
|
throw error;
|
|
9110
9386
|
}
|
|
9111
|
-
const hash =
|
|
9387
|
+
const hash = createHash22("sha256");
|
|
9112
9388
|
let completed = false;
|
|
9113
9389
|
try {
|
|
9114
9390
|
let size = 0;
|
|
@@ -9148,7 +9424,7 @@ async function downloadAsset(options) {
|
|
|
9148
9424
|
}
|
|
9149
9425
|
|
|
9150
9426
|
// ../../src/updates/feed/update-discovery.ts
|
|
9151
|
-
import { createHash as
|
|
9427
|
+
import { createHash as createHash23 } from "crypto";
|
|
9152
9428
|
var MAX_POINTER_BYTES = 262144;
|
|
9153
9429
|
var MAX_LEDGER_BYTES2 = 1024 * 1024;
|
|
9154
9430
|
async function discoverSignedRelease(options) {
|
|
@@ -9184,7 +9460,7 @@ async function discoverSignedRelease(options) {
|
|
|
9184
9460
|
throw new Error("No qualified channel descriptor is available");
|
|
9185
9461
|
const { tag } = selected;
|
|
9186
9462
|
const bytes = await readReleaseBytes(await get(`${tag}/${discoveryName}`), 65536);
|
|
9187
|
-
if (bytes.length !== listed.size ||
|
|
9463
|
+
if (bytes.length !== listed.size || createHash23("sha256").update(bytes).digest("hex") !== listed.sha256)
|
|
9188
9464
|
throw new Error("Channel descriptor differs from its release");
|
|
9189
9465
|
let signed;
|
|
9190
9466
|
try {
|
|
@@ -9736,7 +10012,7 @@ async function stageLinuxPackagePairWithInspection(options, inspect) {
|
|
|
9736
10012
|
}
|
|
9737
10013
|
var stageLinuxPackagePair = (options) => stageLinuxPackagePairWithInspection(options, inspectWithNativeTools);
|
|
9738
10014
|
// src/library/linux-format-producer.ts
|
|
9739
|
-
import { createHash as
|
|
10015
|
+
import { createHash as createHash24 } from "crypto";
|
|
9740
10016
|
import { createReadStream as createReadStream2, createWriteStream } from "fs";
|
|
9741
10017
|
import {
|
|
9742
10018
|
chmod as chmod4,
|
|
@@ -9759,9 +10035,9 @@ import { pipeline as pipeline2 } from "stream/promises";
|
|
|
9759
10035
|
var component = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
9760
10036
|
var commandName = /^[a-z0-9][a-z0-9@+._-]{0,63}$/;
|
|
9761
10037
|
var debDependencyAtom = /^[a-z0-9][a-z0-9+.-]{0,63}(?: \(>= (?:0|[1-9]\d{0,8})(?:\.(?:0|[1-9]\d{0,8})){1,3}\))?$/;
|
|
9762
|
-
var
|
|
10038
|
+
var sha2564 = /^[a-f0-9]{64}$/;
|
|
9763
10039
|
var sum = async (path) => {
|
|
9764
|
-
const hash =
|
|
10040
|
+
const hash = createHash24("sha256");
|
|
9765
10041
|
for await (const chunk of createReadStream2(path))
|
|
9766
10042
|
hash.update(chunk);
|
|
9767
10043
|
return hash.digest("hex");
|
|
@@ -9773,7 +10049,7 @@ function check3(ok, message) {
|
|
|
9773
10049
|
throw new Error(message);
|
|
9774
10050
|
}
|
|
9775
10051
|
async function exactCopy(pin, to) {
|
|
9776
|
-
check3(
|
|
10052
|
+
check3(sha2564.test(pin.sha256), "Missing protected input digest");
|
|
9777
10053
|
const before = await lstat21(pin.path);
|
|
9778
10054
|
check3(before.isFile() && !before.isSymbolicLink() && before.size > 0, "Expected a regular pinned input");
|
|
9779
10055
|
const input = await open14(pin.path, "r");
|
|
@@ -9843,7 +10119,7 @@ async function write(root, path, value, mode = 420) {
|
|
|
9843
10119
|
function validatePolicy(policy) {
|
|
9844
10120
|
const executable = policy.executable ?? policy.packageName;
|
|
9845
10121
|
const links = policy.links ?? [];
|
|
9846
|
-
check3([policy.bundleRoot, policy.artifactStem, policy.desktopId].every((n) => component.test(n)) && /^[a-z0-9][a-z0-9+.-]+$/.test(policy.packageName) && typeof executable === "string" && commandName.test(executable) && Array.isArray(links) && links.every((link) => link && typeof link.name === "string" && commandName.test(link.name) && typeof link.target === "string" && relativeFiles(link.target) && link.name !== executable) && new Set(links.map((link) => link.name)).size === links.length && [policy.launcher, policy.icon, ...policy.debSetuid.map((item) => item.path)].every(relativeFiles) && policy.debSetuid.every((item) =>
|
|
10122
|
+
check3([policy.bundleRoot, policy.artifactStem, policy.desktopId].every((n) => component.test(n)) && /^[a-z0-9][a-z0-9+.-]+$/.test(policy.packageName) && typeof executable === "string" && commandName.test(executable) && Array.isArray(links) && links.every((link) => link && typeof link.name === "string" && commandName.test(link.name) && typeof link.target === "string" && relativeFiles(link.target) && link.name !== executable) && new Set(links.map((link) => link.name)).size === links.length && [policy.launcher, policy.icon, ...policy.debSetuid.map((item) => item.path)].every(relativeFiles) && policy.debSetuid.every((item) => sha2564.test(item.sha256)) && new Set(policy.debSetuid.map((item) => item.path)).size === policy.debSetuid.length && /^[A-Z][A-Z0-9_]*_LINUX_PACKAGE_FORMAT$/.test(policy.formatEnvironment) && policy.mimeTypes.every((x) => /^x-scheme-handler\/[a-z][a-z0-9+.-]*$/.test(x)) && [policy.name, policy.description, policy.maintainer, policy.homepage].every(text2) && policy.categories.every((x) => /^[A-Za-z0-9]+$/.test(x)) && policy.dependencies.every((x) => x.length <= 256 && x === x.trim() && x.split(" | ").every((atom) => debDependencyAtom.test(atom))), "Invalid app Linux packaging policy");
|
|
9847
10123
|
check3(new URL(policy.homepage).protocol === "https:", "Expected HTTPS homepage");
|
|
9848
10124
|
}
|
|
9849
10125
|
async function buildLinuxFormats(input, host) {
|
|
@@ -10063,7 +10339,7 @@ exec "$root/${installed}/${policy.launcher}" "$@"
|
|
|
10063
10339
|
}
|
|
10064
10340
|
// src/library/windows-standalone.ts
|
|
10065
10341
|
import { execFile as execFile5 } from "child_process";
|
|
10066
|
-
import { createHash as
|
|
10342
|
+
import { createHash as createHash25 } from "crypto";
|
|
10067
10343
|
import { constants as constants8 } from "fs";
|
|
10068
10344
|
import { copyFile as copyFile2, lstat as lstat22, mkdtemp as mkdtemp13, open as open15, readFile as readFile13, readdir as readdir14, rm as rm13, writeFile as writeFile14 } from "fs/promises";
|
|
10069
10345
|
import { tmpdir as tmpdir6 } from "os";
|
|
@@ -10255,7 +10531,7 @@ async function assertStandaloneWindowsPayload(exe, members) {
|
|
|
10255
10531
|
throw new Error("Invalid Windows setup payload marker");
|
|
10256
10532
|
let cursor = offset + marker.length;
|
|
10257
10533
|
for (const member of members) {
|
|
10258
|
-
const hash =
|
|
10534
|
+
const hash = createHash25("sha256");
|
|
10259
10535
|
const end = cursor + member.size;
|
|
10260
10536
|
while (cursor < end) {
|
|
10261
10537
|
const bytes = await read(cursor, Math.min(end - cursor, 1048576));
|
|
@@ -10394,7 +10670,7 @@ function electrobunArtifacts(appName, platform) {
|
|
|
10394
10670
|
|
|
10395
10671
|
// src/library/daily-native-observer.ts
|
|
10396
10672
|
import { execFile as execFile6 } from "child_process";
|
|
10397
|
-
import { createHash as
|
|
10673
|
+
import { createHash as createHash26, randomBytes as randomBytes4 } from "crypto";
|
|
10398
10674
|
import { join as join40, resolve as resolve20 } from "path";
|
|
10399
10675
|
import { Effect as Effect26 } from "effect";
|
|
10400
10676
|
var runDailyNativeDriver = (script, input, env) => new Promise((finish, reject) => {
|
|
@@ -10472,7 +10748,7 @@ function driverPath(value) {
|
|
|
10472
10748
|
throw new Error("Invalid native observer path");
|
|
10473
10749
|
return value;
|
|
10474
10750
|
}
|
|
10475
|
-
var fixtureDigest = (nonce) => "sha256:" +
|
|
10751
|
+
var fixtureDigest = (nonce) => "sha256:" + createHash26("sha256").update(nonce).digest("hex");
|
|
10476
10752
|
var confirmFixture = (value, nonce) => isRecord(value) && hasExactOwnKeys(value, ["digest"]) && value.digest === fixtureDigest(nonce);
|
|
10477
10753
|
var observeDailyNativeEffect = (options, run) => Effect26.gen(function* () {
|
|
10478
10754
|
const { env, platform: os, arch, cwd } = yield* ReleaseConfig;
|
|
@@ -10762,7 +11038,7 @@ var provideLivePorts = (program) => program.pipe(Effect28.provideService(Release
|
|
|
10762
11038
|
}));
|
|
10763
11039
|
|
|
10764
11040
|
// src/commands/prepare-stable-catalog.ts
|
|
10765
|
-
import { createHash as
|
|
11041
|
+
import { createHash as createHash27 } from "crypto";
|
|
10766
11042
|
import { createReadStream as createReadStream3 } from "fs";
|
|
10767
11043
|
import { lstat as lstat23, mkdir as mkdir13, readFile as readFile14, readdir as readdir15, rm as rm14, writeFile as writeFile15 } from "fs/promises";
|
|
10768
11044
|
import { basename as basename18, dirname as dirname16, join as join42 } from "path";
|
|
@@ -11005,7 +11281,7 @@ var measure = async (path) => {
|
|
|
11005
11281
|
const st = await lstat23(path);
|
|
11006
11282
|
if (!st.isFile())
|
|
11007
11283
|
throw new Error("Expected ordinary installer file");
|
|
11008
|
-
const hash =
|
|
11284
|
+
const hash = createHash27("sha256");
|
|
11009
11285
|
for await (const chunk of createReadStream3(path))
|
|
11010
11286
|
hash.update(chunk);
|
|
11011
11287
|
return { name: basename18(path), size: st.size, sha256: hash.digest("hex") };
|
|
@@ -11067,14 +11343,14 @@ import { basename as basename19, dirname as dirname17, isAbsolute as isAbsolute9
|
|
|
11067
11343
|
import { Effect as Effect29 } from "effect";
|
|
11068
11344
|
|
|
11069
11345
|
// src/library/verified-git-source.ts
|
|
11070
|
-
import { createHash as
|
|
11346
|
+
import { createHash as createHash28 } from "crypto";
|
|
11071
11347
|
var id2 = /^[a-f0-9]{40}$/;
|
|
11072
11348
|
var pathPart = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
11073
11349
|
async function object2(git, type, oid, max) {
|
|
11074
11350
|
if (!id2.test(oid))
|
|
11075
11351
|
throw new Error("Invalid source object");
|
|
11076
11352
|
const bytes = await git(["cat-file", type, oid]);
|
|
11077
|
-
if (bytes.length > max ||
|
|
11353
|
+
if (bytes.length > max || createHash28("sha1").update(`${type} ${bytes.length}\x00`).update(bytes).digest("hex") !== oid)
|
|
11078
11354
|
throw new Error("Source object identity mismatch");
|
|
11079
11355
|
return bytes;
|
|
11080
11356
|
}
|
|
@@ -11127,12 +11403,12 @@ async function verifiedSourceFile(git, rootTree, path) {
|
|
|
11127
11403
|
}
|
|
11128
11404
|
|
|
11129
11405
|
// src/commands/build-linux-formats.ts
|
|
11130
|
-
var
|
|
11406
|
+
var sha2565 = /^[a-f0-9]{64}$/;
|
|
11131
11407
|
var sourcePath = (path) => path.length <= 512 && path.split("/").every((part) => /^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(part));
|
|
11132
11408
|
var exact2 = (value, required, optional = []) => required.every((key) => Object.hasOwn(value, key)) && Object.keys(value).every((key) => required.includes(key) || optional.includes(key));
|
|
11133
11409
|
var strings2 = (value, max) => Array.isArray(value) && value.length <= max && value.every((item) => typeof item === "string" && item.length <= 512);
|
|
11134
11410
|
function parseLinuxFormatBuildPolicy(value) {
|
|
11135
|
-
if (!isRecord(value) || !exact2(value, ["schema", "renderer", "appimagetoolSha256", "runtimeSha256", "policy"]) || value.schema !== "linux-format-build-policy/v1" || value.renderer !== "native" && value.renderer !== "cef" || typeof value.appimagetoolSha256 !== "string" || !
|
|
11411
|
+
if (!isRecord(value) || !exact2(value, ["schema", "renderer", "appimagetoolSha256", "runtimeSha256", "policy"]) || value.schema !== "linux-format-build-policy/v1" || value.renderer !== "native" && value.renderer !== "cef" || typeof value.appimagetoolSha256 !== "string" || !sha2565.test(value.appimagetoolSha256) || typeof value.runtimeSha256 !== "string" || !sha2565.test(value.runtimeSha256) || !isRecord(value.policy))
|
|
11136
11412
|
throw new Error("Invalid Linux format build policy");
|
|
11137
11413
|
const p = value.policy;
|
|
11138
11414
|
const required = [
|
|
@@ -11168,7 +11444,7 @@ function parseLinuxFormatBuildPolicy(value) {
|
|
|
11168
11444
|
if (!exact2(p, required, ["executable", "links"]) || textFields.some((key) => typeof p[key] !== "string" || p[key].length > 512 || [...p[key]].some((character) => {
|
|
11169
11445
|
const code = character.charCodeAt(0);
|
|
11170
11446
|
return code < 32 || code === 127;
|
|
11171
|
-
})) || p.executable !== undefined && (typeof p.executable !== "string" || p.executable.length > 64) || !strings2(p.dependencies, 128) || !strings2(p.categories, 32) || !strings2(p.mimeTypes, 32) || !Array.isArray(p.debSetuid) || p.debSetuid.length > 32 || p.debSetuid.some((pin) => !isRecord(pin) || !exact2(pin, ["path", "sha256"]) || typeof pin.path !== "string" || pin.path.length > 512 || typeof pin.sha256 !== "string" || !
|
|
11447
|
+
})) || p.executable !== undefined && (typeof p.executable !== "string" || p.executable.length > 64) || !strings2(p.dependencies, 128) || !strings2(p.categories, 32) || !strings2(p.mimeTypes, 32) || !Array.isArray(p.debSetuid) || p.debSetuid.length > 32 || p.debSetuid.some((pin) => !isRecord(pin) || !exact2(pin, ["path", "sha256"]) || typeof pin.path !== "string" || pin.path.length > 512 || typeof pin.sha256 !== "string" || !sha2565.test(pin.sha256)) || p.links !== undefined && (!Array.isArray(p.links) || p.links.length > 32 || p.links.some((link) => !isRecord(link) || !exact2(link, ["name", "target"]) || typeof link.name !== "string" || link.name.length > 64 || typeof link.target !== "string" || link.target.length > 512)))
|
|
11172
11448
|
throw new Error("Invalid Linux format build policy");
|
|
11173
11449
|
return {
|
|
11174
11450
|
renderer: value.renderer,
|
|
@@ -11367,117 +11643,6 @@ var buildWindowsStandaloneCommand = (args) => runCommand("Unable to build the st
|
|
|
11367
11643
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
11368
11644
|
import { lstat as lstat24, mkdir as mkdir14, readFile as readFile15, readdir as readdir16, rm as rm16, unlink as unlink4, writeFile as writeFile16 } from "fs/promises";
|
|
11369
11645
|
import { dirname as dirname18, isAbsolute as isAbsolute10, join as join44 } from "path";
|
|
11370
|
-
|
|
11371
|
-
// src/library/apt/apt-metadata.ts
|
|
11372
|
-
import { createHash as createHash26 } from "crypto";
|
|
11373
|
-
import { gzipSync } from "zlib";
|
|
11374
|
-
var sha2564 = (data) => createHash26("sha256").update(data).digest("hex");
|
|
11375
|
-
function stageAptMetadata({ policy, tag, assets, deb, control, now }) {
|
|
11376
|
-
if (!/^v(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)$/.test(tag))
|
|
11377
|
-
throw new Error("Invalid release tag");
|
|
11378
|
-
const { packageName, architecture, assetName: name, suite, origin } = policy;
|
|
11379
|
-
if (!/^[a-z][a-z0-9+.-]{1,62}$/.test(packageName) || architecture !== "amd64" && architecture !== "arm64" || !/^[A-Za-z0-9][A-Za-z0-9_.+-]*\.deb$/.test(name) || suite !== "daily" && suite !== "stable" || !/^[A-Za-z0-9][A-Za-z0-9 .+_-]{0,62}$/.test(origin))
|
|
11380
|
-
throw new Error("Invalid Debian repository policy");
|
|
11381
|
-
const matching = assets.filter((asset) => asset.name === name);
|
|
11382
|
-
if (matching.length !== 1)
|
|
11383
|
-
throw new Error("Require one staged Debian artifact");
|
|
11384
|
-
const asset = matching[0];
|
|
11385
|
-
if (!deb.length || asset.size !== deb.length || asset.sha256 !== sha2564(deb))
|
|
11386
|
-
throw new Error("Staged Debian bytes do not match the verified release inventory");
|
|
11387
|
-
const fields = new Map;
|
|
11388
|
-
let lines = control.replaceAll(`\r
|
|
11389
|
-
`, `
|
|
11390
|
-
`).split(`
|
|
11391
|
-
`);
|
|
11392
|
-
if (lines.at(-1) === "")
|
|
11393
|
-
lines = lines.slice(0, -1);
|
|
11394
|
-
for (const [index, line] of lines.entries()) {
|
|
11395
|
-
if (/^[ \t]/.test(line) && index !== 0)
|
|
11396
|
-
continue;
|
|
11397
|
-
const field = /^([a-z][a-z0-9-]*):[ \t]*(.*)$/i.exec(line);
|
|
11398
|
-
if (!field || fields.has(field[1].toLowerCase()))
|
|
11399
|
-
throw new Error("Invalid or duplicate Debian control field");
|
|
11400
|
-
fields.set(field[1].toLowerCase(), field[2]);
|
|
11401
|
-
}
|
|
11402
|
-
for (const key of ["filename", "size", "md5sum", "sha1", "sha256", "sha512"])
|
|
11403
|
-
if (fields.has(key))
|
|
11404
|
-
throw new Error("Debian control includes repository-owned metadata");
|
|
11405
|
-
if (fields.get("package") !== packageName || fields.get("version") !== tag.slice(1) || fields.get("architecture") !== architecture || !fields.get("description"))
|
|
11406
|
-
throw new Error("Unexpected Debian package, version, architecture or description");
|
|
11407
|
-
if (!Number.isFinite(now.getTime()))
|
|
11408
|
-
throw new Error("Invalid release timestamp");
|
|
11409
|
-
const filename = `pool/main/${packageName[0]}/${packageName}/${name}`;
|
|
11410
|
-
const entries = `${lines.join(`
|
|
11411
|
-
`)}
|
|
11412
|
-
Filename: ${filename}
|
|
11413
|
-
Size: ${asset.size}
|
|
11414
|
-
SHA256: ${asset.sha256}
|
|
11415
|
-
|
|
11416
|
-
`;
|
|
11417
|
-
const plain = new TextEncoder().encode(entries);
|
|
11418
|
-
const compressed = gzipSync(plain);
|
|
11419
|
-
const directories = `main/binary-${architecture}`;
|
|
11420
|
-
const members = [
|
|
11421
|
-
[`${directories}/Packages`, plain],
|
|
11422
|
-
[`${directories}/Packages.gz`, compressed]
|
|
11423
|
-
];
|
|
11424
|
-
const release = renderRelease({ origin, suite, now, architectures: [architecture], members });
|
|
11425
|
-
return {
|
|
11426
|
-
packagePath: filename,
|
|
11427
|
-
release,
|
|
11428
|
-
files: new Map([
|
|
11429
|
-
...members,
|
|
11430
|
-
...members.map(([, bytes]) => [`${directories}/by-hash/SHA256/${sha2564(bytes)}`, bytes])
|
|
11431
|
-
])
|
|
11432
|
-
};
|
|
11433
|
-
}
|
|
11434
|
-
function renderRelease({
|
|
11435
|
-
origin,
|
|
11436
|
-
suite,
|
|
11437
|
-
now,
|
|
11438
|
-
architectures,
|
|
11439
|
-
members
|
|
11440
|
-
}) {
|
|
11441
|
-
return [
|
|
11442
|
-
`Origin: ${origin}`,
|
|
11443
|
-
`Label: ${origin} ${suite}`,
|
|
11444
|
-
`Suite: ${suite}`,
|
|
11445
|
-
`Codename: ${suite}`,
|
|
11446
|
-
`Date: ${now.toUTCString()}`,
|
|
11447
|
-
`Valid-Until: ${new Date(now.getTime() + 30 * 86400000).toUTCString()}`,
|
|
11448
|
-
`Architectures: ${architectures.join(" ")}`,
|
|
11449
|
-
"Components: main",
|
|
11450
|
-
"Acquire-By-Hash: yes",
|
|
11451
|
-
"SHA256:",
|
|
11452
|
-
...members.map(([path, bytes]) => ` ${sha2564(bytes)} ${bytes.length} ${path}`),
|
|
11453
|
-
""
|
|
11454
|
-
].join(`
|
|
11455
|
-
`);
|
|
11456
|
-
}
|
|
11457
|
-
function stageMultiarchAptMetadata(variants) {
|
|
11458
|
-
const [first, second] = variants;
|
|
11459
|
-
if (!first || !second || variants.length !== 2 || new Set(variants.map(({ policy }) => policy.architecture)).size !== 2 || first.policy.assetName === second.policy.assetName || first.policy.packageName !== second.policy.packageName || first.policy.suite !== second.policy.suite || first.policy.origin !== second.policy.origin || first.tag !== second.tag || first.now.getTime() !== second.now.getTime())
|
|
11460
|
-
throw new Error("Require exactly one AMD64 and one ARM64 package for a single APT suite");
|
|
11461
|
-
const staged = variants.toSorted((a, b) => a.policy.architecture.localeCompare(b.policy.architecture, "en")).map((input) => ({
|
|
11462
|
-
...stageAptMetadata(input),
|
|
11463
|
-
architecture: input.policy.architecture,
|
|
11464
|
-
deb: input.deb
|
|
11465
|
-
}));
|
|
11466
|
-
const files = new Map(staged.flatMap((result) => [...result.files]));
|
|
11467
|
-
return {
|
|
11468
|
-
packages: staged.map(({ packagePath, deb }) => ({ packagePath, deb })),
|
|
11469
|
-
files,
|
|
11470
|
-
release: renderRelease({
|
|
11471
|
-
origin: first.policy.origin,
|
|
11472
|
-
suite: first.policy.suite,
|
|
11473
|
-
now: first.now,
|
|
11474
|
-
architectures: staged.map(({ architecture }) => architecture),
|
|
11475
|
-
members: [...files].filter(([path]) => !path.includes("/by-hash/"))
|
|
11476
|
-
})
|
|
11477
|
-
};
|
|
11478
|
-
}
|
|
11479
|
-
|
|
11480
|
-
// src/library/apt/stage-apt-repository.ts
|
|
11481
11646
|
function cmd(program, options, label) {
|
|
11482
11647
|
const run = spawnSync3(program, options, { encoding: "utf8", timeout: 60000 });
|
|
11483
11648
|
if (run.error || run.status !== 0)
|
|
@@ -11570,7 +11735,7 @@ import { open as open16 } from "fs/promises";
|
|
|
11570
11735
|
import { isAbsolute as isAbsolute11 } from "path";
|
|
11571
11736
|
|
|
11572
11737
|
// src/library/release-retention.ts
|
|
11573
|
-
import { createHash as
|
|
11738
|
+
import { createHash as createHash29 } from "crypto";
|
|
11574
11739
|
var day = 86400000;
|
|
11575
11740
|
var safeTag = /^v(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-dev\.(?:0|[1-9]\d*))?$/;
|
|
11576
11741
|
var safeAsset = /^[a-zA-Z0-9][a-zA-Z0-9._+-]{0,254}$/;
|
|
@@ -11598,7 +11763,7 @@ function unique(rows, key, caption) {
|
|
|
11598
11763
|
var byKey = (a, b) => a.key.localeCompare(b.key);
|
|
11599
11764
|
var ordered = (rows, key) => rows.toSorted((a, b) => key(a).localeCompare(key(b)));
|
|
11600
11765
|
var stable = (value) => JSON.stringify(value);
|
|
11601
|
-
var fingerprint = (value) =>
|
|
11766
|
+
var fingerprint = (value) => createHash29("sha256").update(stable(value)).digest("hex");
|
|
11602
11767
|
var latestFirst = (a, b) => date(b.publishedAt) - date(a.publishedAt) || a.tag.localeCompare(b.tag);
|
|
11603
11768
|
function planReleaseRetention(snapshot) {
|
|
11604
11769
|
const { app } = snapshot;
|
|
@@ -11772,7 +11937,7 @@ if (false) {}
|
|
|
11772
11937
|
|
|
11773
11938
|
// src/linux-channel-proof-cli.ts
|
|
11774
11939
|
import { spawnSync as spawnSync4 } from "child_process";
|
|
11775
|
-
import { createHash as
|
|
11940
|
+
import { createHash as createHash30 } from "crypto";
|
|
11776
11941
|
import { createReadStream as createReadStream4 } from "fs";
|
|
11777
11942
|
import { constants as constants10, createWriteStream as createWriteStream2 } from "fs";
|
|
11778
11943
|
import { lstat as lstat25, mkdtemp as mkdtemp15, open as open17, readFile as readFile16, realpath as realpath13, rm as rm17 } from "fs/promises";
|
|
@@ -11784,9 +11949,9 @@ function check4(ok, message) {
|
|
|
11784
11949
|
if (!ok)
|
|
11785
11950
|
throw new Error(message);
|
|
11786
11951
|
}
|
|
11787
|
-
async function
|
|
11952
|
+
async function hash3(path) {
|
|
11788
11953
|
check4((await lstat25(path)).isFile(), "artifact must be a regular file");
|
|
11789
|
-
const digest =
|
|
11954
|
+
const digest = createHash30("sha256");
|
|
11790
11955
|
for await (const chunk of createReadStream4(path))
|
|
11791
11956
|
digest.update(chunk);
|
|
11792
11957
|
return digest.digest("hex");
|
|
@@ -11820,7 +11985,7 @@ async function verifyRpmStage(stage) {
|
|
|
11820
11985
|
}
|
|
11821
11986
|
for (const artifact of [stage.payload, stage.rpm]) {
|
|
11822
11987
|
check4(/^[0-9a-f]{64}$/.test(artifact.sha256), "expected SHA-256");
|
|
11823
|
-
check4(await
|
|
11988
|
+
check4(await hash3(artifact.path) === artifact.sha256, "staged artifact digest mismatch");
|
|
11824
11989
|
}
|
|
11825
11990
|
const repo = await realpath13(stage.repository);
|
|
11826
11991
|
const keyUrl = pathToFileURL(await realpath13(stage.publicKey)).href;
|
|
@@ -11880,7 +12045,7 @@ async function verifySignedRpmStage(stage, fingerprint) {
|
|
|
11880
12045
|
await snapshot(stage.publicKey, key, 1024 * 1024);
|
|
11881
12046
|
await snapshot(originalMetadata, metadata, 8 * 1024 * 1024);
|
|
11882
12047
|
await snapshot(originalSignature, signature, 1024 * 1024);
|
|
11883
|
-
check4(await
|
|
12048
|
+
check4(await hash3(rpm) === stage.rpm.sha256, "RPM changed before signature verification");
|
|
11884
12049
|
const gpg = ["--no-options", "--batch", "--homedir", root, "--no-auto-key-retrieve"];
|
|
11885
12050
|
const list = command("gpg", [...gpg, "--with-colons", "--fingerprint", "--show-keys", key]);
|
|
11886
12051
|
const lines = list.split(`
|
|
@@ -11907,10 +12072,10 @@ async function verifySignedRpmStage(stage, fingerprint) {
|
|
|
11907
12072
|
]);
|
|
11908
12073
|
const rpmIdentity = identity.split("|");
|
|
11909
12074
|
check4(rpmIdentity.length === 5 && rpmIdentity[0] === stage.packageName && /^[0-9]+$/.test(rpmIdentity[1]) && rpmIdentity[2] === stage.version && /^[A-Za-z0-9][A-Za-z0-9._+~^]*$/.test(rpmIdentity[3]) && rpmIdentity[4] === stage.architecture, "signed RPM header does not match the requested package");
|
|
11910
|
-
const rpmSha256 = await
|
|
11911
|
-
const metadataSha256 = await
|
|
11912
|
-
const signatureSha256 = await
|
|
11913
|
-
check4(await
|
|
12075
|
+
const rpmSha256 = await hash3(rpm);
|
|
12076
|
+
const metadataSha256 = await hash3(metadata);
|
|
12077
|
+
const signatureSha256 = await hash3(signature);
|
|
12078
|
+
check4(await hash3(stage.rpm.path) === rpmSha256 && await hash3(originalMetadata) === metadataSha256 && await hash3(originalSignature) === signatureSha256, "signed inputs changed during verification");
|
|
11914
12079
|
return {
|
|
11915
12080
|
kind: "rpm-signature-proof",
|
|
11916
12081
|
sourceSha: stage.sourceSha,
|
|
@@ -11950,14 +12115,14 @@ function verifyFlatpakCapabilities(policy, result) {
|
|
|
11950
12115
|
|
|
11951
12116
|
// src/linux-rpm-metadata-proof.ts
|
|
11952
12117
|
import { spawnSync as spawnSync5 } from "child_process";
|
|
11953
|
-
import { createHash as
|
|
12118
|
+
import { createHash as createHash31 } from "crypto";
|
|
11954
12119
|
import { constants as constants11 } from "fs";
|
|
11955
12120
|
import { lstat as lstat26, open as open18, realpath as realpath14 } from "fs/promises";
|
|
11956
12121
|
import { isAbsolute as isAbsolute12, join as join46, relative as relative7, resolve as resolve23 } from "path";
|
|
11957
12122
|
import { gunzipSync as gunzipSync2 } from "zlib";
|
|
11958
12123
|
var maxCompressed = 16 * 1024 * 1024;
|
|
11959
12124
|
var maxOpen = 32 * 1024 * 1024;
|
|
11960
|
-
var digest5 = (bytes) =>
|
|
12125
|
+
var digest5 = (bytes) => createHash31("sha256").update(bytes).digest("hex");
|
|
11961
12126
|
function ensure(ok, reason) {
|
|
11962
12127
|
if (!ok)
|
|
11963
12128
|
throw new Error(reason);
|
|
@@ -12045,7 +12210,7 @@ async function digestRegular(path, expectedSize) {
|
|
|
12045
12210
|
try {
|
|
12046
12211
|
const stat = await file.stat();
|
|
12047
12212
|
ensure(stat.isFile() && stat.size === expectedSize && stat.size > 0 && stat.size <= 4 * 1024 * 1024 * 1024, "Invalid RPM file");
|
|
12048
|
-
const hash =
|
|
12213
|
+
const hash = createHash31("sha256");
|
|
12049
12214
|
let size = 0;
|
|
12050
12215
|
for await (const chunk of file.createReadStream({ autoClose: false })) {
|
|
12051
12216
|
size += chunk.length;
|
|
@@ -12119,7 +12284,7 @@ async function verifyRpmRepository(stage, fingerprint) {
|
|
|
12119
12284
|
}
|
|
12120
12285
|
|
|
12121
12286
|
// src/library/arch-publish.ts
|
|
12122
|
-
import { createHash as
|
|
12287
|
+
import { createHash as createHash32 } from "crypto";
|
|
12123
12288
|
import { join as join47 } from "path";
|
|
12124
12289
|
import { tmpdir as tmpdir9 } from "os";
|
|
12125
12290
|
import { Effect as Effect31 } from "effect";
|
|
@@ -12350,7 +12515,7 @@ var readLicense = (url) => Effect31.gen(function* () {
|
|
|
12350
12515
|
return yield* fail("Release license is unavailable");
|
|
12351
12516
|
}
|
|
12352
12517
|
const bytes = yield* step(() => readReleaseBytes(response, MAX_LICENSE_BYTES));
|
|
12353
|
-
const sha256 = yield* step(async () =>
|
|
12518
|
+
const sha256 = yield* step(async () => createHash32("sha256").update(bytes).digest("hex"));
|
|
12354
12519
|
return { url, sha256 };
|
|
12355
12520
|
});
|
|
12356
12521
|
var git2 = (args) => Effect31.gen(function* () {
|
|
@@ -12392,7 +12557,7 @@ var verifyArchRelease = (options) => Effect31.gen(function* () {
|
|
|
12392
12557
|
if (!listed)
|
|
12393
12558
|
return yield* fail(`Missing signed descriptor: ${descriptorPolicy.name}`);
|
|
12394
12559
|
const bytes = yield* feedBytes(options.feed, `${options.tag}/${descriptorPolicy.name}`, 65536);
|
|
12395
|
-
if (!bytes || bytes.length !== listed.size ||
|
|
12560
|
+
if (!bytes || bytes.length !== listed.size || createHash32("sha256").update(bytes).digest("hex") !== listed.sha256)
|
|
12396
12561
|
return yield* fail(`Signed descriptor differs from its release: ${descriptorPolicy.name}`);
|
|
12397
12562
|
const json = yield* step(async () => {
|
|
12398
12563
|
try {
|