Repository navigation
chore: verify the engine download and pin CI actions and base images #1461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7f308c9
feat(cli): verify the iii engine download against pinned SHA-256 hashes
rohitg00 9f6bd54
ci: pin actions to commit SHAs and set read-only permissions
rohitg00 94c43ec
chore(deploy): pin base images by digest
rohitg00 05063b1
fix(cli): pass engine installer paths to the shell as arguments
rohitg00 d318a06
chore(ci,deploy): use version tags for actions and base images
rohitg00 aa44961
chore(scripts): add engine:hashes to refresh the pinned engine checksums
rohitg00 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| import { createHash } from "node:crypto"; | ||
| import { readFileSync, writeFileSync } from "node:fs"; | ||
|
|
||
| const versionFile = new URL("../src/version.ts", import.meta.url); | ||
| const installFile = new URL("../src/cli/engine-install.ts", import.meta.url); | ||
|
|
||
| const pinned = readFileSync(versionFile, "utf8").match(/III_PINNED_VERSION = "([^"]+)"/)?.[1]; | ||
| const version = process.argv[2] ?? pinned; | ||
| if (!version) { | ||
| console.error("usage: npm run engine:hashes [version]"); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| const assets = [ | ||
| "iii-aarch64-apple-darwin.tar.gz", | ||
| "iii-x86_64-apple-darwin.tar.gz", | ||
| "iii-x86_64-unknown-linux-gnu.tar.gz", | ||
| "iii-aarch64-unknown-linux-gnu.tar.gz", | ||
| "iii-armv7-unknown-linux-gnueabihf.tar.gz", | ||
| "iii-x86_64-pc-windows-msvc.zip", | ||
| "iii-aarch64-pc-windows-msvc.zip", | ||
| ]; | ||
|
|
||
| async function fetchOk(url) { | ||
| const res = await fetch(url); | ||
| if (!res.ok) throw new Error(`${url}: HTTP ${res.status}`); | ||
| return res; | ||
| } | ||
|
|
||
| const base = `https://github.com/iii-hq/iii/releases/download/iii/v${version}`; | ||
| const lines = []; | ||
| for (const asset of assets) { | ||
| const archive = Buffer.from(await (await fetchOk(`${base}/${asset}`)).arrayBuffer()); | ||
| const actual = createHash("sha256").update(archive).digest("hex"); | ||
| const published = (await (await fetchOk(`${base}/${asset.replace(/\.(tar\.gz|zip)$/, "")}.sha256`)).text()).trim().split(/\s+/)[0]; | ||
| if (published !== actual) { | ||
| console.error(`${asset}: archive hashes to ${actual} but the release lists ${published}`); | ||
| process.exit(1); | ||
| } | ||
| console.log(`${asset} ${actual}`); | ||
| lines.push(` "${asset}": "${actual}",`); | ||
| } | ||
|
|
||
| const source = readFileSync(installFile, "utf8"); | ||
| const table = /export const III_RELEASE_SHA256: ChecksumTable = \{\n[\s\S]*?\n\};\n/; | ||
| if (!table.test(source)) { | ||
| console.error("III_RELEASE_SHA256 table not found in src/cli/engine-install.ts"); | ||
| process.exit(1); | ||
| } | ||
| const block = `export const III_RELEASE_SHA256: ChecksumTable = {\n "${version}": {\n${lines.join("\n")}\n },\n};\n`; | ||
| writeFileSync(installFile, source.replace(table, block)); | ||
| console.log(`wrote hashes for iii v${version} to src/cli/engine-install.ts`); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Preserve checksum entries for other versions.
When a maintainer supplies a different version, this replacement deletes the
0.22.1entries whileIII_PINNED_VERSIONremains0.22.1. The installer then returnsno-checksumand refuses automatic installation for the default version.Update only the selected version's entry. Preserve the other entries.
🤖 Prompt for AI Agents