install: warn instead of failing when checksums.txt is missing#1712
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe install script now skips checksum verification when ChangesChecksum Verification Behavior
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@scripts/install.js`:
- Around line 268-271: The checksum fallback in the install flow currently
allows a downloaded binary to be installed unverified when checksums.txt is
missing. Update the install logic in the checksum verification path and the
binary install flow to fail closed by default, and require an explicit opt-in
escape hatch to continue without verification. Use the existing checksum
handling in the install script (the checksums.txt branch and the later install
call site) to gate the unverified path, keeping the old behavior only behind a
clearly named opt-in flag or environment variable.
In `@scripts/install.test.js`:
- Around line 55-59: The checksum fallback test in getExpectedChecksum should
also assert the user-visible warning before accepting the null fail-open result,
so the behavior cannot silently regress. Update the test around
getExpectedChecksum in scripts/install.test.js to capture the warning output and
verify it is emitted when checksums.txt is missing, while still asserting the
null sentinel.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 0e7dafa4-eef4-4586-91a8-edc17adcaa4f
📒 Files selected for processing (2)
scripts/install.jsscripts/install.test.js
| console.error( | ||
| "[WARN] checksums.txt not found, skipping checksum verification" | ||
| ); | ||
| return null; |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
Gate unverified installs behind an explicit opt-in.
This path now installs a downloaded binary with no checksum verification whenever checksums.txt is missing. A warning is easy to miss during npm install; consider failing closed by default and allowing the old behavior only via an explicit escape hatch.
Suggested direction
if (!fs.existsSync(checksumsPath)) {
- console.error(
- "[WARN] checksums.txt not found, skipping checksum verification"
- );
- return null;
+ const message = "checksums.txt not found";
+ if (process.env.LARK_CLI_ALLOW_UNVERIFIED_INSTALL === "1") {
+ console.error(
+ `[WARN] ${message}, skipping checksum verification`
+ );
+ return null;
+ }
+ throw new Error(
+ `[SECURITY] ${message}; refusing to install an unverified binary. Set LARK_CLI_ALLOW_UNVERIFIED_INSTALL=1 to proceed.`
+ );
}Also applies to: 289-289
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@scripts/install.js` around lines 268 - 271, The checksum fallback in the
install flow currently allows a downloaded binary to be installed unverified
when checksums.txt is missing. Update the install logic in the checksum
verification path and the binary install flow to fail closed by default, and
require an explicit opt-in escape hatch to continue without verification. Use
the existing checksum handling in the install script (the checksums.txt branch
and the later install call site) to gate the unverified path, keeping the old
behavior only behind a clearly named opt-in flag or environment variable.
| it("returns null when checksums.txt does not exist", () => { | ||
| const dir = fs.mkdtempSync(path.join(os.tmpdir(), "checksum-test-")); | ||
| // No checksums.txt in dir | ||
| assert.throws( | ||
| () => getExpectedChecksum("anything.tar.gz", dir), | ||
| (err) => { | ||
| assert.match(err.message, /^\[SECURITY\]/); | ||
| assert.match(err.message, /checksums\.txt not found/); | ||
| return true; | ||
| } | ||
| ); | ||
| const result = getExpectedChecksum("anything.tar.gz", dir); | ||
| assert.equal(result, null); |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Assert the warning before accepting the fail-open result.
This test now verifies the null sentinel but not the user-visible security warning, so a future change could silently skip checksum verification and still pass.
Suggested test hardening
- it("returns null when checksums.txt does not exist", () => {
+ it("returns null and warns when checksums.txt does not exist", () => {
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "checksum-test-"));
// No checksums.txt in dir
- const result = getExpectedChecksum("anything.tar.gz", dir);
- assert.equal(result, null);
+ const originalError = console.error;
+ const messages = [];
+ console.error = (...args) => messages.push(args.join(" "));
+ try {
+ const result = getExpectedChecksum("anything.tar.gz", dir);
+ assert.equal(result, null);
+ assert.match(
+ messages.join("\n"),
+ /\[WARN\] checksums\.txt not found, skipping checksum verification/
+ );
+ } finally {
+ console.error = originalError;
+ }📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| it("returns null when checksums.txt does not exist", () => { | |
| const dir = fs.mkdtempSync(path.join(os.tmpdir(), "checksum-test-")); | |
| // No checksums.txt in dir | |
| assert.throws( | |
| () => getExpectedChecksum("anything.tar.gz", dir), | |
| (err) => { | |
| assert.match(err.message, /^\[SECURITY\]/); | |
| assert.match(err.message, /checksums\.txt not found/); | |
| return true; | |
| } | |
| ); | |
| const result = getExpectedChecksum("anything.tar.gz", dir); | |
| assert.equal(result, null); | |
| it("returns null and warns when checksums.txt does not exist", () => { | |
| const dir = fs.mkdtempSync(path.join(os.tmpdir(), "checksum-test-")); | |
| // No checksums.txt in dir | |
| const originalError = console.error; | |
| const messages = []; | |
| console.error = (...args) => messages.push(args.join(" ")); | |
| try { | |
| const result = getExpectedChecksum("anything.tar.gz", dir); | |
| assert.equal(result, null); | |
| assert.match( | |
| messages.join("\n"), | |
| /\[WARN\] checksums\.txt not found, skipping checksum verification/ | |
| ); | |
| } finally { | |
| console.error = originalError; | |
| } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@scripts/install.test.js` around lines 55 - 59, The checksum fallback test in
getExpectedChecksum should also assert the user-visible warning before accepting
the null fail-open result, so the behavior cannot silently regress. Update the
test around getExpectedChecksum in scripts/install.test.js to capture the
warning output and verify it is emitted when checksums.txt is missing, while
still asserting the null sentinel.
5807810 to
85eb70a
Compare
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@85eb70a9aa714d6275f509ff87b466d8218deed2🧩 Skill updatenpx skills add larksuite/cli#install-checksum-missing-warn -y -g |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1712 +/- ##
=======================================
Coverage 74.52% 74.52%
=======================================
Files 851 851
Lines 87155 87155
=======================================
Hits 64952 64952
Misses 17231 17231
Partials 4972 4972 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Restores the prior warn-and-skip behavior for a missing
checksums.txtduring npm install.Change
getExpectedChecksum— logs[WARN] checksums.txt not found, skipping checksum verificationand returnsnull(instead of throwing[SECURITY]).verifyChecksum— skips verification when there is no expected hash (instead of throwing).Reverts commit
ec6fdc9b(#1503).Note
This re-opens the posture #1503 closed: installs will proceed with an unverified binary when
checksums.txtis absent.All 32 tests in
scripts/install.test.jspass.Summary by CodeRabbit