Skip to content

install: warn instead of failing when checksums.txt is missing#1712

Merged
liangshuo-1 merged 2 commits into
mainfrom
install-checksum-missing-warn
Jul 1, 2026
Merged

install: warn instead of failing when checksums.txt is missing#1712
liangshuo-1 merged 2 commits into
mainfrom
install-checksum-missing-warn

Conversation

@liangshuo-1

@liangshuo-1 liangshuo-1 commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

Restores the prior warn-and-skip behavior for a missing checksums.txt during npm install.

Change

  • getExpectedChecksum — logs [WARN] checksums.txt not found, skipping checksum verification and returns null (instead of throwing [SECURITY]).
  • verifyChecksum — skips verification when there is no expected hash (instead of throwing).
  • Tests updated to match.

Reverts commit ec6fdc9b (#1503).

Note

This re-opens the posture #1503 closed: installs will proceed with an unverified binary when checksums.txt is absent.

All 32 tests in scripts/install.test.js pass.

Summary by CodeRabbit

  • Bug Fixes
    • Installations now continue when the checksum file is missing, instead of failing with an error.
    • If checksum data can’t be found, the installer skips checksum verification and logs a warning.
    • Existing checksum mismatch handling remains unchanged.
  • Chores
    • Bumped package version to 1.0.63.

Restores the prior warn-and-skip behavior when checksums.txt is absent:
getExpectedChecksum logs a warning and returns null, and verifyChecksum
skips when there is no expected hash.

Reverts commit ec6fdc9 (#1503).
@github-actions github-actions Bot added the size/M Single-domain feat or fix with limited business impact label Jul 1, 2026
@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a6dfdea7-8ed7-463c-a784-8064280a2902

📥 Commits

Reviewing files that changed from the base of the PR and between 0ae00ab and 85eb70a.

📒 Files selected for processing (1)
  • package.json

📝 Walkthrough

Walkthrough

The install script now skips checksum verification when checksums.txt is missing, and the tests and package version were updated to match the new behavior.

Changes

Checksum Verification Behavior

Layer / File(s) Summary
Fail-open checksum verification logic
scripts/install.js
getExpectedChecksum now logs a warning and returns null when checksums.txt is missing; verifyChecksum returns early when expectedHash is null.
Updated checksum tests and version bump
scripts/install.test.js, package.json
Tests now expect null for missing checksums.txt and no longer assert [SECURITY] failures for null or empty expectedHash; the package version is bumped to 1.0.63.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • larksuite/cli#592: Also changes checksum verification behavior around missing checksums.txt in scripts/install.js and its tests.
  • larksuite/cli#1503: Touches the same missing-checksum path in getExpectedChecksum/verifyChecksum, but with the opposite fail-closed behavior.
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers summary, change details, and tests, but it does not follow the required template and omits a Related Issues section. Add the required ## Summary, ## Changes, ## Test Plan, and ## Related Issues headings, and format the test plan as checklist items.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main behavior change: warn and skip checksum verification when checksums.txt is missing.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch install-checksum-missing-warn

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between ad4d3cb and 0ae00ab.

📒 Files selected for processing (2)
  • scripts/install.js
  • scripts/install.test.js

Comment thread scripts/install.js
Comment on lines +268 to +271
console.error(
"[WARN] checksums.txt not found, skipping checksum verification"
);
return null;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 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.

Comment thread scripts/install.test.js
Comment on lines +55 to +59
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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 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.

Suggested change
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.

@liangshuo-1
liangshuo-1 force-pushed the install-checksum-missing-warn branch from 5807810 to 85eb70a Compare July 1, 2026 14:43
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

npm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@85eb70a9aa714d6275f509ff87b466d8218deed2

🧩 Skill update

npx skills add larksuite/cli#install-checksum-missing-warn -y -g

@liangshuo-1
liangshuo-1 merged commit 462358a into main Jul 1, 2026
27 checks passed
@liangshuo-1
liangshuo-1 deleted the install-checksum-missing-warn branch July 1, 2026 14:50
@codecov

codecov Bot commented Jul 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.52%. Comparing base (ad4d3cb) to head (85eb70a).
⚠️ Report is 1 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai coderabbitai Bot mentioned this pull request Jul 16, 2026
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Single-domain feat or fix with limited business impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant