@adea-ai/app-framework-release-tools 0.8.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 +282 -175
- package/dist/index.js +257 -38
- package/dist/release-tools-source.json +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -35,6 +35,7 @@ __export(exports_src, {
|
|
|
35
35
|
expandedDesktopDailyProfile: () => expandedDesktopDailyProfile,
|
|
36
36
|
fileIdentity: () => fileIdentity2,
|
|
37
37
|
finalizeReleasePleaseDraft: () => finalizeReleasePleaseDraft,
|
|
38
|
+
inspectAptRepositoryPlan: () => inspectAptRepositoryPlan,
|
|
38
39
|
inspectDailyBatch: () => inspectDailyBatch,
|
|
39
40
|
inspectDailyPreSigning: () => inspectDailyPreSigning,
|
|
40
41
|
inspectStagedStep: () => inspectStagedStep,
|
|
@@ -3850,6 +3851,223 @@ function createDailyBatchR2Store(send) {
|
|
|
3850
3851
|
}
|
|
3851
3852
|
};
|
|
3852
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
|
+
}
|
|
3853
4071
|
// src/library/apt/apt-r2-store.ts
|
|
3854
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)$/;
|
|
3855
4073
|
var pointer2 = /^apt\/(?:adea|cortana)\/dists\/(?:daily|stable)\/InRelease$/;
|
|
@@ -3933,7 +4151,7 @@ function createAptR2Store(send) {
|
|
|
3933
4151
|
};
|
|
3934
4152
|
}
|
|
3935
4153
|
// src/library/apt/publish-apt-repository.ts
|
|
3936
|
-
import { createHash as
|
|
4154
|
+
import { createHash as createHash11 } from "crypto";
|
|
3937
4155
|
import { gunzipSync } from "zlib";
|
|
3938
4156
|
var ARCHES = ["amd64", "arm64"];
|
|
3939
4157
|
var version = /^(?:0|[1-9]\d{0,8})\.(?:0|[1-9]\d{0,8})\.(?:0|[1-9]\d{0,8})$/;
|
|
@@ -3941,7 +4159,7 @@ var hex3 = /^[0-9a-f]{64}$/;
|
|
|
3941
4159
|
var indexLimit = 256 * 1024;
|
|
3942
4160
|
var debLimit = 768 * 1024 ** 2;
|
|
3943
4161
|
var etag = /^"[0-9a-f]{32}(?:-[1-9]\d{0,6})?"$/i;
|
|
3944
|
-
var digest = (bytes) =>
|
|
4162
|
+
var digest = (bytes) => createHash11("sha256").update(bytes).digest("hex");
|
|
3945
4163
|
var decode = (bytes) => new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
3946
4164
|
var same2 = (a, b) => Buffer.from(a).equals(b);
|
|
3947
4165
|
function need(condition, message) {
|
|
@@ -4081,7 +4299,7 @@ async function publishAptRepository({ app, suite, tag, assets }, port, now = Dat
|
|
|
4081
4299
|
return { tag, changed: true };
|
|
4082
4300
|
}
|
|
4083
4301
|
// src/library/apt/verify-apt-signature.ts
|
|
4084
|
-
import { createHash as
|
|
4302
|
+
import { createHash as createHash12 } from "crypto";
|
|
4085
4303
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
4086
4304
|
import { mkdtemp as mkdtemp3, readFile as readFile5, rm as rm3, writeFile as writeFile3 } from "fs/promises";
|
|
4087
4305
|
import { tmpdir as tmpdir4 } from "os";
|
|
@@ -4089,7 +4307,7 @@ import { join as join8 } from "path";
|
|
|
4089
4307
|
function createAptSignatureVerifier(config) {
|
|
4090
4308
|
const { fingerprint } = config;
|
|
4091
4309
|
const keyring = Buffer.from(config.keyring);
|
|
4092
|
-
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)
|
|
4093
4311
|
throw Error("Untrusted APT signing keyring");
|
|
4094
4312
|
return async (bytes) => {
|
|
4095
4313
|
if (bytes.length < 1 || bytes.length > 256 * 1024)
|
|
@@ -4128,7 +4346,7 @@ import { join as join10 } from "path";
|
|
|
4128
4346
|
import { Effect as Effect17 } from "effect";
|
|
4129
4347
|
|
|
4130
4348
|
// src/library/daily-matrix.ts
|
|
4131
|
-
import { createHash as
|
|
4349
|
+
import { createHash as createHash13 } from "crypto";
|
|
4132
4350
|
import { join as join9 } from "path";
|
|
4133
4351
|
import { Effect as Effect16 } from "effect";
|
|
4134
4352
|
|
|
@@ -4426,7 +4644,7 @@ function readNativeReceipt(path, label) {
|
|
|
4426
4644
|
return {
|
|
4427
4645
|
value: JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(data)),
|
|
4428
4646
|
size: data.length,
|
|
4429
|
-
digest: "sha256:" +
|
|
4647
|
+
digest: "sha256:" + createHash13("sha256").update(data).digest("hex")
|
|
4430
4648
|
};
|
|
4431
4649
|
} catch {
|
|
4432
4650
|
throw new Error(`Invalid native receipt JSON: ${label}`);
|
|
@@ -4712,7 +4930,7 @@ function createDailyNativeReceipt(options) {
|
|
|
4712
4930
|
})));
|
|
4713
4931
|
}
|
|
4714
4932
|
// src/library/linux-reproducibility.ts
|
|
4715
|
-
import { createHash as
|
|
4933
|
+
import { createHash as createHash14 } from "crypto";
|
|
4716
4934
|
import { lstat as lstat6, readFile as readFile6, readdir as readdir5, realpath } from "fs/promises";
|
|
4717
4935
|
import { isAbsolute as isAbsolute2, join as join12, resolve as resolve6 } from "path";
|
|
4718
4936
|
|
|
@@ -4726,7 +4944,7 @@ function isLinuxPackageArchitecture(value) {
|
|
|
4726
4944
|
}
|
|
4727
4945
|
|
|
4728
4946
|
// src/library/linux-reproducibility.ts
|
|
4729
|
-
var
|
|
4947
|
+
var sha2563 = /^[a-f0-9]{64}$/;
|
|
4730
4948
|
var digest3 = /^sha256:[a-f0-9]{64}$/;
|
|
4731
4949
|
var circleciImage = /^ubuntu-2404:[0-9]{4}\.(?:0[1-9]|1[0-2])\.[0-9]+$/;
|
|
4732
4950
|
var identifier = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,199}$/;
|
|
@@ -4777,7 +4995,7 @@ async function compareLinuxReproducibility(rawInput) {
|
|
|
4777
4995
|
check2(isLinuxPackageArchitecture(architecture), "Invalid Linux comparison architecture");
|
|
4778
4996
|
const target = linuxPackageArchitectures[architecture];
|
|
4779
4997
|
assertDailyIdentity(input.identity);
|
|
4780
|
-
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");
|
|
4781
4999
|
check2(isRecord(input.config) && typeof input.config.appId === "string", "Invalid app identity");
|
|
4782
5000
|
const requirements = parseReleaseConfig(input.config).requirements(input.identity.tag);
|
|
4783
5001
|
const archiveName = requirements.platforms[target.platform]?.[1];
|
|
@@ -4842,7 +5060,7 @@ async function compareLinuxReproducibility(rawInput) {
|
|
|
4842
5060
|
observed.push({ path, file });
|
|
4843
5061
|
check2(file.size <= 65536, "Producer receipt is too large");
|
|
4844
5062
|
const bytes = await readFile6(path);
|
|
4845
|
-
check2(bytes.length === file.size &&
|
|
5063
|
+
check2(bytes.length === file.size && createHash14("sha256").update(bytes).digest("hex") === file.sha256, "Producer receipt changed");
|
|
4846
5064
|
let receipt;
|
|
4847
5065
|
try {
|
|
4848
5066
|
receipt = JSON.parse(bytes.toString("utf8"));
|
|
@@ -4988,7 +5206,7 @@ function createMacosDmg(options) {
|
|
|
4988
5206
|
import { Effect as Effect22 } from "effect";
|
|
4989
5207
|
|
|
4990
5208
|
// src/library/local-release.ts
|
|
4991
|
-
import { createHash as
|
|
5209
|
+
import { createHash as createHash16 } from "crypto";
|
|
4992
5210
|
import { constants as constants3 } from "fs";
|
|
4993
5211
|
import { dirname as dirname2, join as join15, resolve as resolve9 } from "path";
|
|
4994
5212
|
import { Cause as Cause2, Effect as Effect21, Exit as Exit3 } from "effect";
|
|
@@ -5158,7 +5376,7 @@ function createFeedReleaseCutProvider(options) {
|
|
|
5158
5376
|
}
|
|
5159
5377
|
|
|
5160
5378
|
// src/library/feed-state.ts
|
|
5161
|
-
import { createHash as
|
|
5379
|
+
import { createHash as createHash15 } from "crypto";
|
|
5162
5380
|
import { Effect as Effect20 } from "effect";
|
|
5163
5381
|
|
|
5164
5382
|
// ../../src/shared/discard-stream.ts
|
|
@@ -5406,7 +5624,7 @@ var verifyFeedReleaseEffect = (options) => Effect20.gen(function* () {
|
|
|
5406
5624
|
if (!listed)
|
|
5407
5625
|
return yield* fail(`Missing signed descriptor: ${policy.name}`);
|
|
5408
5626
|
const bytes = yield* feedObject(feed, `${tag}/${policy.name}`, 65536);
|
|
5409
|
-
if (!bytes || bytes.length !== listed.size ||
|
|
5627
|
+
if (!bytes || bytes.length !== listed.size || createHash15("sha256").update(bytes).digest("hex") !== listed.sha256)
|
|
5410
5628
|
return yield* fail(`Signed descriptor differs from its release: ${policy.name}`);
|
|
5411
5629
|
const verified = verifyReleaseDescriptor(json(bytes), {
|
|
5412
5630
|
appId: policy.appId,
|
|
@@ -5550,7 +5768,7 @@ var jsonBytes = (value) => Buffer.from(JSON.stringify(value, null, 2) + `
|
|
|
5550
5768
|
var describe = (key, bytes, cacheControl) => ({
|
|
5551
5769
|
key,
|
|
5552
5770
|
size: bytes.length,
|
|
5553
|
-
sha256:
|
|
5771
|
+
sha256: createHash16("sha256").update(bytes).digest("hex"),
|
|
5554
5772
|
contentType: "application/json",
|
|
5555
5773
|
cacheControl
|
|
5556
5774
|
});
|
|
@@ -5639,7 +5857,7 @@ var stageLocalReleaseEffect = (options) => Effect21.gen(function* () {
|
|
|
5639
5857
|
if (artifact.size > 65536)
|
|
5640
5858
|
return yield* fail("Signed descriptor is too large");
|
|
5641
5859
|
const bytes = yield* step(() => fs.readFile(join15(directory, policy.name)));
|
|
5642
|
-
if ("sha256:" +
|
|
5860
|
+
if ("sha256:" + createHash16("sha256").update(bytes).digest("hex") !== artifact.digest)
|
|
5643
5861
|
return yield* fail("Signed descriptor changed");
|
|
5644
5862
|
let parsed;
|
|
5645
5863
|
try {
|
|
@@ -5998,12 +6216,12 @@ var selectRetainedReleaseBuildEffect = (options) => Effect23.gen(function* () {
|
|
|
5998
6216
|
});
|
|
5999
6217
|
var selectRetainedReleaseBuild = (options) => runReleaseLibrary(provideLibraryPorts({ run: planGitHubRun(options.env, options.run) })(selectRetainedReleaseBuildEffect(options)));
|
|
6000
6218
|
// src/library/staging.ts
|
|
6001
|
-
import { createHash as
|
|
6219
|
+
import { createHash as createHash17 } from "crypto";
|
|
6002
6220
|
import { join as join16, resolve as resolve10 } from "path";
|
|
6003
6221
|
import { Effect as Effect24 } from "effect";
|
|
6004
6222
|
var copyHashed = (input, output, size) => Effect24.tryPromise({
|
|
6005
6223
|
try: async (signal) => {
|
|
6006
|
-
const hash =
|
|
6224
|
+
const hash = createHash17("sha256");
|
|
6007
6225
|
let copied = 0;
|
|
6008
6226
|
for await (const chunk of input.createReadStream({
|
|
6009
6227
|
autoClose: false
|
|
@@ -6073,7 +6291,7 @@ import { join as join36 } from "path";
|
|
|
6073
6291
|
import { Effect as Effect25 } from "effect";
|
|
6074
6292
|
|
|
6075
6293
|
// ../../src/installer/installer-archive-members.ts
|
|
6076
|
-
import { createHash as
|
|
6294
|
+
import { createHash as createHash18 } from "crypto";
|
|
6077
6295
|
import { lstat as lstat7, open as open5 } from "fs/promises";
|
|
6078
6296
|
import { isAbsolute as isAbsolute4, relative as relative4, sep as sep2 } from "path";
|
|
6079
6297
|
|
|
@@ -6180,7 +6398,7 @@ async function assertEmbeddedArchive(path, size, archive) {
|
|
|
6180
6398
|
const position = size - archive.size - marker.length, actual = Buffer.alloc(marker.length);
|
|
6181
6399
|
if ((await file.read(actual, 0, actual.length, position)).bytesRead !== actual.length || !actual.equals(marker))
|
|
6182
6400
|
throw new Error("Installer archive marker is missing");
|
|
6183
|
-
const hash =
|
|
6401
|
+
const hash = createHash18("sha256");
|
|
6184
6402
|
let read = 0;
|
|
6185
6403
|
for await (const chunk of file.createReadStream({
|
|
6186
6404
|
start: position + marker.length,
|
|
@@ -7067,7 +7285,7 @@ function assertInstallerRendererObservation(value, offline = false) {
|
|
|
7067
7285
|
}
|
|
7068
7286
|
|
|
7069
7287
|
// ../../src/installer/installed-payload.ts
|
|
7070
|
-
import { createHash as
|
|
7288
|
+
import { createHash as createHash19 } from "crypto";
|
|
7071
7289
|
import { lstat as lstat12, open as open6, realpath as realpath5, rm as rm7 } from "fs/promises";
|
|
7072
7290
|
import { once as once2 } from "events";
|
|
7073
7291
|
import { join as join21, resolve as resolve13 } from "path";
|
|
@@ -7093,7 +7311,7 @@ async function command2(args, env, limit, collect) {
|
|
|
7093
7311
|
const errors = (async () => {
|
|
7094
7312
|
for await (const _part of child.stderr) {}
|
|
7095
7313
|
})();
|
|
7096
|
-
const hash =
|
|
7314
|
+
const hash = createHash19("sha256"), chunks = [];
|
|
7097
7315
|
let size = 0;
|
|
7098
7316
|
try {
|
|
7099
7317
|
for await (const part of child.stdout) {
|
|
@@ -7147,7 +7365,7 @@ async function readMembers(archive, limits, collect) {
|
|
|
7147
7365
|
failure ??= new Error("Archive member missing or ambiguous");
|
|
7148
7366
|
return entry.resume();
|
|
7149
7367
|
}
|
|
7150
|
-
const hash =
|
|
7368
|
+
const hash = createHash19("sha256"), chunks = [];
|
|
7151
7369
|
const member = { digest: "", size: 0, bytes: Buffer.alloc(0), count: 1 };
|
|
7152
7370
|
members.set(entry.path, member);
|
|
7153
7371
|
entry.on("data", (chunk) => {
|
|
@@ -7289,7 +7507,7 @@ async function extractCandidateRuntime(options) {
|
|
|
7289
7507
|
const child = spawn(), errors = (async () => {
|
|
7290
7508
|
for await (const _part of child.stderr) {}
|
|
7291
7509
|
})();
|
|
7292
|
-
const hash =
|
|
7510
|
+
const hash = createHash19("sha256");
|
|
7293
7511
|
let size = 0;
|
|
7294
7512
|
try {
|
|
7295
7513
|
for await (const part of child.stdout) {
|
|
@@ -7523,7 +7741,7 @@ function planUpdateHandoff(options) {
|
|
|
7523
7741
|
}
|
|
7524
7742
|
|
|
7525
7743
|
// ../../src/updates/install/update-extraction.ts
|
|
7526
|
-
import { createHash as
|
|
7744
|
+
import { createHash as createHash20 } from "crypto";
|
|
7527
7745
|
import { constants as constants4 } from "fs";
|
|
7528
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";
|
|
7529
7747
|
import { isAbsolute as isAbsolute6, join as join22 } from "path";
|
|
@@ -7598,7 +7816,7 @@ async function extractBoundArchive(options, descriptor, verifyBeforeExtraction)
|
|
|
7598
7816
|
done(null, chunk);
|
|
7599
7817
|
}
|
|
7600
7818
|
});
|
|
7601
|
-
const hash =
|
|
7819
|
+
const hash = createHash20("sha256");
|
|
7602
7820
|
let compressedBytes = 0;
|
|
7603
7821
|
const verifyInput = new Transform({
|
|
7604
7822
|
transform(chunk, _encoding, done) {
|
|
@@ -7754,7 +7972,7 @@ async function extractBoundArchive(options, descriptor, verifyBeforeExtraction)
|
|
|
7754
7972
|
}
|
|
7755
7973
|
|
|
7756
7974
|
// ../../src/updates/install/update-swap.ts
|
|
7757
|
-
import { createHash as
|
|
7975
|
+
import { createHash as createHash21 } from "crypto";
|
|
7758
7976
|
import { constants as constants7 } from "fs";
|
|
7759
7977
|
import { lstat as lstat14, open as open10, readdir as readdir9, readFile as readFile9, readlink as readlink2 } from "fs/promises";
|
|
7760
7978
|
import { basename as basename8, dirname as dirname6, join as join25 } from "path";
|
|
@@ -8110,7 +8328,7 @@ async function readTreeFileBytes(file, buffer, length, position) {
|
|
|
8110
8328
|
}
|
|
8111
8329
|
async function readUpdateTreeDigest(tree, options = {}) {
|
|
8112
8330
|
const allowHardLinkedFiles = options.allowHardLinkedFiles === true;
|
|
8113
|
-
const hash =
|
|
8331
|
+
const hash = createHash21("sha256");
|
|
8114
8332
|
hash.update("adea-framework-update-tree\x00v1\x00", "utf8");
|
|
8115
8333
|
const root = await lstat14(tree, { bigint: true });
|
|
8116
8334
|
if (!root.isDirectory() || root.isSymbolicLink())
|
|
@@ -9128,7 +9346,7 @@ import { lstat as lstat20, mkdir as mkdir10, rename as rename2, writeFile as wri
|
|
|
9128
9346
|
import { join as join35, resolve as resolve16 } from "path";
|
|
9129
9347
|
|
|
9130
9348
|
// ../../src/installer/upgrade-asset-download.ts
|
|
9131
|
-
import { createHash as
|
|
9349
|
+
import { createHash as createHash22 } from "crypto";
|
|
9132
9350
|
import { open as open11, unlink as unlink3 } from "fs/promises";
|
|
9133
9351
|
|
|
9134
9352
|
// ../../src/installer/write-all.ts
|
|
@@ -9166,7 +9384,7 @@ async function downloadAsset(options) {
|
|
|
9166
9384
|
discardStream(response.body);
|
|
9167
9385
|
throw error;
|
|
9168
9386
|
}
|
|
9169
|
-
const hash =
|
|
9387
|
+
const hash = createHash22("sha256");
|
|
9170
9388
|
let completed = false;
|
|
9171
9389
|
try {
|
|
9172
9390
|
let size = 0;
|
|
@@ -9206,7 +9424,7 @@ async function downloadAsset(options) {
|
|
|
9206
9424
|
}
|
|
9207
9425
|
|
|
9208
9426
|
// ../../src/updates/feed/update-discovery.ts
|
|
9209
|
-
import { createHash as
|
|
9427
|
+
import { createHash as createHash23 } from "crypto";
|
|
9210
9428
|
var MAX_POINTER_BYTES = 262144;
|
|
9211
9429
|
var MAX_LEDGER_BYTES2 = 1024 * 1024;
|
|
9212
9430
|
async function discoverSignedRelease(options) {
|
|
@@ -9242,7 +9460,7 @@ async function discoverSignedRelease(options) {
|
|
|
9242
9460
|
throw new Error("No qualified channel descriptor is available");
|
|
9243
9461
|
const { tag } = selected;
|
|
9244
9462
|
const bytes = await readReleaseBytes(await get(`${tag}/${discoveryName}`), 65536);
|
|
9245
|
-
if (bytes.length !== listed.size ||
|
|
9463
|
+
if (bytes.length !== listed.size || createHash23("sha256").update(bytes).digest("hex") !== listed.sha256)
|
|
9246
9464
|
throw new Error("Channel descriptor differs from its release");
|
|
9247
9465
|
let signed;
|
|
9248
9466
|
try {
|
|
@@ -9794,7 +10012,7 @@ async function stageLinuxPackagePairWithInspection(options, inspect) {
|
|
|
9794
10012
|
}
|
|
9795
10013
|
var stageLinuxPackagePair = (options) => stageLinuxPackagePairWithInspection(options, inspectWithNativeTools);
|
|
9796
10014
|
// src/library/linux-format-producer.ts
|
|
9797
|
-
import { createHash as
|
|
10015
|
+
import { createHash as createHash24 } from "crypto";
|
|
9798
10016
|
import { createReadStream as createReadStream2, createWriteStream } from "fs";
|
|
9799
10017
|
import {
|
|
9800
10018
|
chmod as chmod4,
|
|
@@ -9817,9 +10035,9 @@ import { pipeline as pipeline2 } from "stream/promises";
|
|
|
9817
10035
|
var component = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
9818
10036
|
var commandName = /^[a-z0-9][a-z0-9@+._-]{0,63}$/;
|
|
9819
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}\))?$/;
|
|
9820
|
-
var
|
|
10038
|
+
var sha2564 = /^[a-f0-9]{64}$/;
|
|
9821
10039
|
var sum = async (path) => {
|
|
9822
|
-
const hash =
|
|
10040
|
+
const hash = createHash24("sha256");
|
|
9823
10041
|
for await (const chunk of createReadStream2(path))
|
|
9824
10042
|
hash.update(chunk);
|
|
9825
10043
|
return hash.digest("hex");
|
|
@@ -9831,7 +10049,7 @@ function check3(ok, message) {
|
|
|
9831
10049
|
throw new Error(message);
|
|
9832
10050
|
}
|
|
9833
10051
|
async function exactCopy(pin, to) {
|
|
9834
|
-
check3(
|
|
10052
|
+
check3(sha2564.test(pin.sha256), "Missing protected input digest");
|
|
9835
10053
|
const before = await lstat21(pin.path);
|
|
9836
10054
|
check3(before.isFile() && !before.isSymbolicLink() && before.size > 0, "Expected a regular pinned input");
|
|
9837
10055
|
const input = await open14(pin.path, "r");
|
|
@@ -9901,7 +10119,7 @@ async function write(root, path, value, mode = 420) {
|
|
|
9901
10119
|
function validatePolicy(policy) {
|
|
9902
10120
|
const executable = policy.executable ?? policy.packageName;
|
|
9903
10121
|
const links = policy.links ?? [];
|
|
9904
|
-
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");
|
|
9905
10123
|
check3(new URL(policy.homepage).protocol === "https:", "Expected HTTPS homepage");
|
|
9906
10124
|
}
|
|
9907
10125
|
async function buildLinuxFormats(input, host) {
|
|
@@ -10121,7 +10339,7 @@ exec "$root/${installed}/${policy.launcher}" "$@"
|
|
|
10121
10339
|
}
|
|
10122
10340
|
// src/library/windows-standalone.ts
|
|
10123
10341
|
import { execFile as execFile5 } from "child_process";
|
|
10124
|
-
import { createHash as
|
|
10342
|
+
import { createHash as createHash25 } from "crypto";
|
|
10125
10343
|
import { constants as constants8 } from "fs";
|
|
10126
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";
|
|
10127
10345
|
import { tmpdir as tmpdir6 } from "os";
|
|
@@ -10313,7 +10531,7 @@ async function assertStandaloneWindowsPayload(exe, members) {
|
|
|
10313
10531
|
throw new Error("Invalid Windows setup payload marker");
|
|
10314
10532
|
let cursor = offset + marker.length;
|
|
10315
10533
|
for (const member of members) {
|
|
10316
|
-
const hash =
|
|
10534
|
+
const hash = createHash25("sha256");
|
|
10317
10535
|
const end = cursor + member.size;
|
|
10318
10536
|
while (cursor < end) {
|
|
10319
10537
|
const bytes = await read(cursor, Math.min(end - cursor, 1048576));
|
|
@@ -10452,7 +10670,7 @@ function electrobunArtifacts(appName, platform) {
|
|
|
10452
10670
|
|
|
10453
10671
|
// src/library/daily-native-observer.ts
|
|
10454
10672
|
import { execFile as execFile6 } from "child_process";
|
|
10455
|
-
import { createHash as
|
|
10673
|
+
import { createHash as createHash26, randomBytes as randomBytes4 } from "crypto";
|
|
10456
10674
|
import { join as join40, resolve as resolve20 } from "path";
|
|
10457
10675
|
import { Effect as Effect26 } from "effect";
|
|
10458
10676
|
var runDailyNativeDriver = (script, input, env) => new Promise((finish, reject) => {
|
|
@@ -10530,7 +10748,7 @@ function driverPath(value) {
|
|
|
10530
10748
|
throw new Error("Invalid native observer path");
|
|
10531
10749
|
return value;
|
|
10532
10750
|
}
|
|
10533
|
-
var fixtureDigest = (nonce) => "sha256:" +
|
|
10751
|
+
var fixtureDigest = (nonce) => "sha256:" + createHash26("sha256").update(nonce).digest("hex");
|
|
10534
10752
|
var confirmFixture = (value, nonce) => isRecord(value) && hasExactOwnKeys(value, ["digest"]) && value.digest === fixtureDigest(nonce);
|
|
10535
10753
|
var observeDailyNativeEffect = (options, run) => Effect26.gen(function* () {
|
|
10536
10754
|
const { env, platform: os, arch, cwd } = yield* ReleaseConfig;
|
|
@@ -10820,7 +11038,7 @@ var provideLivePorts = (program) => program.pipe(Effect28.provideService(Release
|
|
|
10820
11038
|
}));
|
|
10821
11039
|
|
|
10822
11040
|
// src/commands/prepare-stable-catalog.ts
|
|
10823
|
-
import { createHash as
|
|
11041
|
+
import { createHash as createHash27 } from "crypto";
|
|
10824
11042
|
import { createReadStream as createReadStream3 } from "fs";
|
|
10825
11043
|
import { lstat as lstat23, mkdir as mkdir13, readFile as readFile14, readdir as readdir15, rm as rm14, writeFile as writeFile15 } from "fs/promises";
|
|
10826
11044
|
import { basename as basename18, dirname as dirname16, join as join42 } from "path";
|
|
@@ -11063,7 +11281,7 @@ var measure = async (path) => {
|
|
|
11063
11281
|
const st = await lstat23(path);
|
|
11064
11282
|
if (!st.isFile())
|
|
11065
11283
|
throw new Error("Expected ordinary installer file");
|
|
11066
|
-
const hash =
|
|
11284
|
+
const hash = createHash27("sha256");
|
|
11067
11285
|
for await (const chunk of createReadStream3(path))
|
|
11068
11286
|
hash.update(chunk);
|
|
11069
11287
|
return { name: basename18(path), size: st.size, sha256: hash.digest("hex") };
|
|
@@ -11125,14 +11343,14 @@ import { basename as basename19, dirname as dirname17, isAbsolute as isAbsolute9
|
|
|
11125
11343
|
import { Effect as Effect29 } from "effect";
|
|
11126
11344
|
|
|
11127
11345
|
// src/library/verified-git-source.ts
|
|
11128
|
-
import { createHash as
|
|
11346
|
+
import { createHash as createHash28 } from "crypto";
|
|
11129
11347
|
var id2 = /^[a-f0-9]{40}$/;
|
|
11130
11348
|
var pathPart = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
11131
11349
|
async function object2(git, type, oid, max) {
|
|
11132
11350
|
if (!id2.test(oid))
|
|
11133
11351
|
throw new Error("Invalid source object");
|
|
11134
11352
|
const bytes = await git(["cat-file", type, oid]);
|
|
11135
|
-
if (bytes.length > max ||
|
|
11353
|
+
if (bytes.length > max || createHash28("sha1").update(`${type} ${bytes.length}\x00`).update(bytes).digest("hex") !== oid)
|
|
11136
11354
|
throw new Error("Source object identity mismatch");
|
|
11137
11355
|
return bytes;
|
|
11138
11356
|
}
|
|
@@ -11185,12 +11403,12 @@ async function verifiedSourceFile(git, rootTree, path) {
|
|
|
11185
11403
|
}
|
|
11186
11404
|
|
|
11187
11405
|
// src/commands/build-linux-formats.ts
|
|
11188
|
-
var
|
|
11406
|
+
var sha2565 = /^[a-f0-9]{64}$/;
|
|
11189
11407
|
var sourcePath = (path) => path.length <= 512 && path.split("/").every((part) => /^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(part));
|
|
11190
11408
|
var exact2 = (value, required, optional = []) => required.every((key) => Object.hasOwn(value, key)) && Object.keys(value).every((key) => required.includes(key) || optional.includes(key));
|
|
11191
11409
|
var strings2 = (value, max) => Array.isArray(value) && value.length <= max && value.every((item) => typeof item === "string" && item.length <= 512);
|
|
11192
11410
|
function parseLinuxFormatBuildPolicy(value) {
|
|
11193
|
-
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))
|
|
11194
11412
|
throw new Error("Invalid Linux format build policy");
|
|
11195
11413
|
const p = value.policy;
|
|
11196
11414
|
const required = [
|
|
@@ -11226,7 +11444,7 @@ function parseLinuxFormatBuildPolicy(value) {
|
|
|
11226
11444
|
if (!exact2(p, required, ["executable", "links"]) || textFields.some((key) => typeof p[key] !== "string" || p[key].length > 512 || [...p[key]].some((character) => {
|
|
11227
11445
|
const code = character.charCodeAt(0);
|
|
11228
11446
|
return code < 32 || code === 127;
|
|
11229
|
-
})) || 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)))
|
|
11230
11448
|
throw new Error("Invalid Linux format build policy");
|
|
11231
11449
|
return {
|
|
11232
11450
|
renderer: value.renderer,
|
|
@@ -11425,117 +11643,6 @@ var buildWindowsStandaloneCommand = (args) => runCommand("Unable to build the st
|
|
|
11425
11643
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
11426
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";
|
|
11427
11645
|
import { dirname as dirname18, isAbsolute as isAbsolute10, join as join44 } from "path";
|
|
11428
|
-
|
|
11429
|
-
// src/library/apt/apt-metadata.ts
|
|
11430
|
-
import { createHash as createHash27 } from "crypto";
|
|
11431
|
-
import { gzipSync } from "zlib";
|
|
11432
|
-
var sha2564 = (data) => createHash27("sha256").update(data).digest("hex");
|
|
11433
|
-
function stageAptMetadata({ policy, tag, assets, deb, control, now }) {
|
|
11434
|
-
if (!/^v(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)$/.test(tag))
|
|
11435
|
-
throw new Error("Invalid release tag");
|
|
11436
|
-
const { packageName, architecture, assetName: name, suite, origin } = policy;
|
|
11437
|
-
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))
|
|
11438
|
-
throw new Error("Invalid Debian repository policy");
|
|
11439
|
-
const matching = assets.filter((asset) => asset.name === name);
|
|
11440
|
-
if (matching.length !== 1)
|
|
11441
|
-
throw new Error("Require one staged Debian artifact");
|
|
11442
|
-
const asset = matching[0];
|
|
11443
|
-
if (!deb.length || asset.size !== deb.length || asset.sha256 !== sha2564(deb))
|
|
11444
|
-
throw new Error("Staged Debian bytes do not match the verified release inventory");
|
|
11445
|
-
const fields = new Map;
|
|
11446
|
-
let lines = control.replaceAll(`\r
|
|
11447
|
-
`, `
|
|
11448
|
-
`).split(`
|
|
11449
|
-
`);
|
|
11450
|
-
if (lines.at(-1) === "")
|
|
11451
|
-
lines = lines.slice(0, -1);
|
|
11452
|
-
for (const [index, line] of lines.entries()) {
|
|
11453
|
-
if (/^[ \t]/.test(line) && index !== 0)
|
|
11454
|
-
continue;
|
|
11455
|
-
const field = /^([a-z][a-z0-9-]*):[ \t]*(.*)$/i.exec(line);
|
|
11456
|
-
if (!field || fields.has(field[1].toLowerCase()))
|
|
11457
|
-
throw new Error("Invalid or duplicate Debian control field");
|
|
11458
|
-
fields.set(field[1].toLowerCase(), field[2]);
|
|
11459
|
-
}
|
|
11460
|
-
for (const key of ["filename", "size", "md5sum", "sha1", "sha256", "sha512"])
|
|
11461
|
-
if (fields.has(key))
|
|
11462
|
-
throw new Error("Debian control includes repository-owned metadata");
|
|
11463
|
-
if (fields.get("package") !== packageName || fields.get("version") !== tag.slice(1) || fields.get("architecture") !== architecture || !fields.get("description"))
|
|
11464
|
-
throw new Error("Unexpected Debian package, version, architecture or description");
|
|
11465
|
-
if (!Number.isFinite(now.getTime()))
|
|
11466
|
-
throw new Error("Invalid release timestamp");
|
|
11467
|
-
const filename = `pool/main/${packageName[0]}/${packageName}/${name}`;
|
|
11468
|
-
const entries = `${lines.join(`
|
|
11469
|
-
`)}
|
|
11470
|
-
Filename: ${filename}
|
|
11471
|
-
Size: ${asset.size}
|
|
11472
|
-
SHA256: ${asset.sha256}
|
|
11473
|
-
|
|
11474
|
-
`;
|
|
11475
|
-
const plain = new TextEncoder().encode(entries);
|
|
11476
|
-
const compressed = gzipSync(plain);
|
|
11477
|
-
const directories = `main/binary-${architecture}`;
|
|
11478
|
-
const members = [
|
|
11479
|
-
[`${directories}/Packages`, plain],
|
|
11480
|
-
[`${directories}/Packages.gz`, compressed]
|
|
11481
|
-
];
|
|
11482
|
-
const release = renderRelease({ origin, suite, now, architectures: [architecture], members });
|
|
11483
|
-
return {
|
|
11484
|
-
packagePath: filename,
|
|
11485
|
-
release,
|
|
11486
|
-
files: new Map([
|
|
11487
|
-
...members,
|
|
11488
|
-
...members.map(([, bytes]) => [`${directories}/by-hash/SHA256/${sha2564(bytes)}`, bytes])
|
|
11489
|
-
])
|
|
11490
|
-
};
|
|
11491
|
-
}
|
|
11492
|
-
function renderRelease({
|
|
11493
|
-
origin,
|
|
11494
|
-
suite,
|
|
11495
|
-
now,
|
|
11496
|
-
architectures,
|
|
11497
|
-
members
|
|
11498
|
-
}) {
|
|
11499
|
-
return [
|
|
11500
|
-
`Origin: ${origin}`,
|
|
11501
|
-
`Label: ${origin} ${suite}`,
|
|
11502
|
-
`Suite: ${suite}`,
|
|
11503
|
-
`Codename: ${suite}`,
|
|
11504
|
-
`Date: ${now.toUTCString()}`,
|
|
11505
|
-
`Valid-Until: ${new Date(now.getTime() + 30 * 86400000).toUTCString()}`,
|
|
11506
|
-
`Architectures: ${architectures.join(" ")}`,
|
|
11507
|
-
"Components: main",
|
|
11508
|
-
"Acquire-By-Hash: yes",
|
|
11509
|
-
"SHA256:",
|
|
11510
|
-
...members.map(([path, bytes]) => ` ${sha2564(bytes)} ${bytes.length} ${path}`),
|
|
11511
|
-
""
|
|
11512
|
-
].join(`
|
|
11513
|
-
`);
|
|
11514
|
-
}
|
|
11515
|
-
function stageMultiarchAptMetadata(variants) {
|
|
11516
|
-
const [first, second] = variants;
|
|
11517
|
-
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())
|
|
11518
|
-
throw new Error("Require exactly one AMD64 and one ARM64 package for a single APT suite");
|
|
11519
|
-
const staged = variants.toSorted((a, b) => a.policy.architecture.localeCompare(b.policy.architecture, "en")).map((input) => ({
|
|
11520
|
-
...stageAptMetadata(input),
|
|
11521
|
-
architecture: input.policy.architecture,
|
|
11522
|
-
deb: input.deb
|
|
11523
|
-
}));
|
|
11524
|
-
const files = new Map(staged.flatMap((result) => [...result.files]));
|
|
11525
|
-
return {
|
|
11526
|
-
packages: staged.map(({ packagePath, deb }) => ({ packagePath, deb })),
|
|
11527
|
-
files,
|
|
11528
|
-
release: renderRelease({
|
|
11529
|
-
origin: first.policy.origin,
|
|
11530
|
-
suite: first.policy.suite,
|
|
11531
|
-
now: first.now,
|
|
11532
|
-
architectures: staged.map(({ architecture }) => architecture),
|
|
11533
|
-
members: [...files].filter(([path]) => !path.includes("/by-hash/"))
|
|
11534
|
-
})
|
|
11535
|
-
};
|
|
11536
|
-
}
|
|
11537
|
-
|
|
11538
|
-
// src/library/apt/stage-apt-repository.ts
|
|
11539
11646
|
function cmd(program, options, label) {
|
|
11540
11647
|
const run = spawnSync3(program, options, { encoding: "utf8", timeout: 60000 });
|
|
11541
11648
|
if (run.error || run.status !== 0)
|
|
@@ -11628,7 +11735,7 @@ import { open as open16 } from "fs/promises";
|
|
|
11628
11735
|
import { isAbsolute as isAbsolute11 } from "path";
|
|
11629
11736
|
|
|
11630
11737
|
// src/library/release-retention.ts
|
|
11631
|
-
import { createHash as
|
|
11738
|
+
import { createHash as createHash29 } from "crypto";
|
|
11632
11739
|
var day = 86400000;
|
|
11633
11740
|
var safeTag = /^v(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-dev\.(?:0|[1-9]\d*))?$/;
|
|
11634
11741
|
var safeAsset = /^[a-zA-Z0-9][a-zA-Z0-9._+-]{0,254}$/;
|
|
@@ -11656,7 +11763,7 @@ function unique(rows, key, caption) {
|
|
|
11656
11763
|
var byKey = (a, b) => a.key.localeCompare(b.key);
|
|
11657
11764
|
var ordered = (rows, key) => rows.toSorted((a, b) => key(a).localeCompare(key(b)));
|
|
11658
11765
|
var stable = (value) => JSON.stringify(value);
|
|
11659
|
-
var fingerprint = (value) =>
|
|
11766
|
+
var fingerprint = (value) => createHash29("sha256").update(stable(value)).digest("hex");
|
|
11660
11767
|
var latestFirst = (a, b) => date(b.publishedAt) - date(a.publishedAt) || a.tag.localeCompare(b.tag);
|
|
11661
11768
|
function planReleaseRetention(snapshot) {
|
|
11662
11769
|
const { app } = snapshot;
|
|
@@ -11830,7 +11937,7 @@ if (false) {}
|
|
|
11830
11937
|
|
|
11831
11938
|
// src/linux-channel-proof-cli.ts
|
|
11832
11939
|
import { spawnSync as spawnSync4 } from "child_process";
|
|
11833
|
-
import { createHash as
|
|
11940
|
+
import { createHash as createHash30 } from "crypto";
|
|
11834
11941
|
import { createReadStream as createReadStream4 } from "fs";
|
|
11835
11942
|
import { constants as constants10, createWriteStream as createWriteStream2 } from "fs";
|
|
11836
11943
|
import { lstat as lstat25, mkdtemp as mkdtemp15, open as open17, readFile as readFile16, realpath as realpath13, rm as rm17 } from "fs/promises";
|
|
@@ -11842,9 +11949,9 @@ function check4(ok, message) {
|
|
|
11842
11949
|
if (!ok)
|
|
11843
11950
|
throw new Error(message);
|
|
11844
11951
|
}
|
|
11845
|
-
async function
|
|
11952
|
+
async function hash3(path) {
|
|
11846
11953
|
check4((await lstat25(path)).isFile(), "artifact must be a regular file");
|
|
11847
|
-
const digest =
|
|
11954
|
+
const digest = createHash30("sha256");
|
|
11848
11955
|
for await (const chunk of createReadStream4(path))
|
|
11849
11956
|
digest.update(chunk);
|
|
11850
11957
|
return digest.digest("hex");
|
|
@@ -11878,7 +11985,7 @@ async function verifyRpmStage(stage) {
|
|
|
11878
11985
|
}
|
|
11879
11986
|
for (const artifact of [stage.payload, stage.rpm]) {
|
|
11880
11987
|
check4(/^[0-9a-f]{64}$/.test(artifact.sha256), "expected SHA-256");
|
|
11881
|
-
check4(await
|
|
11988
|
+
check4(await hash3(artifact.path) === artifact.sha256, "staged artifact digest mismatch");
|
|
11882
11989
|
}
|
|
11883
11990
|
const repo = await realpath13(stage.repository);
|
|
11884
11991
|
const keyUrl = pathToFileURL(await realpath13(stage.publicKey)).href;
|
|
@@ -11938,7 +12045,7 @@ async function verifySignedRpmStage(stage, fingerprint) {
|
|
|
11938
12045
|
await snapshot(stage.publicKey, key, 1024 * 1024);
|
|
11939
12046
|
await snapshot(originalMetadata, metadata, 8 * 1024 * 1024);
|
|
11940
12047
|
await snapshot(originalSignature, signature, 1024 * 1024);
|
|
11941
|
-
check4(await
|
|
12048
|
+
check4(await hash3(rpm) === stage.rpm.sha256, "RPM changed before signature verification");
|
|
11942
12049
|
const gpg = ["--no-options", "--batch", "--homedir", root, "--no-auto-key-retrieve"];
|
|
11943
12050
|
const list = command("gpg", [...gpg, "--with-colons", "--fingerprint", "--show-keys", key]);
|
|
11944
12051
|
const lines = list.split(`
|
|
@@ -11965,10 +12072,10 @@ async function verifySignedRpmStage(stage, fingerprint) {
|
|
|
11965
12072
|
]);
|
|
11966
12073
|
const rpmIdentity = identity.split("|");
|
|
11967
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");
|
|
11968
|
-
const rpmSha256 = await
|
|
11969
|
-
const metadataSha256 = await
|
|
11970
|
-
const signatureSha256 = await
|
|
11971
|
-
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");
|
|
11972
12079
|
return {
|
|
11973
12080
|
kind: "rpm-signature-proof",
|
|
11974
12081
|
sourceSha: stage.sourceSha,
|
|
@@ -12008,14 +12115,14 @@ function verifyFlatpakCapabilities(policy, result) {
|
|
|
12008
12115
|
|
|
12009
12116
|
// src/linux-rpm-metadata-proof.ts
|
|
12010
12117
|
import { spawnSync as spawnSync5 } from "child_process";
|
|
12011
|
-
import { createHash as
|
|
12118
|
+
import { createHash as createHash31 } from "crypto";
|
|
12012
12119
|
import { constants as constants11 } from "fs";
|
|
12013
12120
|
import { lstat as lstat26, open as open18, realpath as realpath14 } from "fs/promises";
|
|
12014
12121
|
import { isAbsolute as isAbsolute12, join as join46, relative as relative7, resolve as resolve23 } from "path";
|
|
12015
12122
|
import { gunzipSync as gunzipSync2 } from "zlib";
|
|
12016
12123
|
var maxCompressed = 16 * 1024 * 1024;
|
|
12017
12124
|
var maxOpen = 32 * 1024 * 1024;
|
|
12018
|
-
var digest5 = (bytes) =>
|
|
12125
|
+
var digest5 = (bytes) => createHash31("sha256").update(bytes).digest("hex");
|
|
12019
12126
|
function ensure(ok, reason) {
|
|
12020
12127
|
if (!ok)
|
|
12021
12128
|
throw new Error(reason);
|
|
@@ -12103,7 +12210,7 @@ async function digestRegular(path, expectedSize) {
|
|
|
12103
12210
|
try {
|
|
12104
12211
|
const stat = await file.stat();
|
|
12105
12212
|
ensure(stat.isFile() && stat.size === expectedSize && stat.size > 0 && stat.size <= 4 * 1024 * 1024 * 1024, "Invalid RPM file");
|
|
12106
|
-
const hash =
|
|
12213
|
+
const hash = createHash31("sha256");
|
|
12107
12214
|
let size = 0;
|
|
12108
12215
|
for await (const chunk of file.createReadStream({ autoClose: false })) {
|
|
12109
12216
|
size += chunk.length;
|
|
@@ -12177,7 +12284,7 @@ async function verifyRpmRepository(stage, fingerprint) {
|
|
|
12177
12284
|
}
|
|
12178
12285
|
|
|
12179
12286
|
// src/library/arch-publish.ts
|
|
12180
|
-
import { createHash as
|
|
12287
|
+
import { createHash as createHash32 } from "crypto";
|
|
12181
12288
|
import { join as join47 } from "path";
|
|
12182
12289
|
import { tmpdir as tmpdir9 } from "os";
|
|
12183
12290
|
import { Effect as Effect31 } from "effect";
|
|
@@ -12408,7 +12515,7 @@ var readLicense = (url) => Effect31.gen(function* () {
|
|
|
12408
12515
|
return yield* fail("Release license is unavailable");
|
|
12409
12516
|
}
|
|
12410
12517
|
const bytes = yield* step(() => readReleaseBytes(response, MAX_LICENSE_BYTES));
|
|
12411
|
-
const sha256 = yield* step(async () =>
|
|
12518
|
+
const sha256 = yield* step(async () => createHash32("sha256").update(bytes).digest("hex"));
|
|
12412
12519
|
return { url, sha256 };
|
|
12413
12520
|
});
|
|
12414
12521
|
var git2 = (args) => Effect31.gen(function* () {
|
|
@@ -12450,7 +12557,7 @@ var verifyArchRelease = (options) => Effect31.gen(function* () {
|
|
|
12450
12557
|
if (!listed)
|
|
12451
12558
|
return yield* fail(`Missing signed descriptor: ${descriptorPolicy.name}`);
|
|
12452
12559
|
const bytes = yield* feedBytes(options.feed, `${options.tag}/${descriptorPolicy.name}`, 65536);
|
|
12453
|
-
if (!bytes || bytes.length !== listed.size ||
|
|
12560
|
+
if (!bytes || bytes.length !== listed.size || createHash32("sha256").update(bytes).digest("hex") !== listed.sha256)
|
|
12454
12561
|
return yield* fail(`Signed descriptor differs from its release: ${descriptorPolicy.name}`);
|
|
12455
12562
|
const json = yield* step(async () => {
|
|
12456
12563
|
try {
|