Skip to content

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

Closed
liangshuo-1 wants to merge 1 commit into
mainfrom
revert-checksum-fail-closed-1503
Closed

install: warn instead of failing when checksums.txt is missing#1711
liangshuo-1 wants to merge 1 commit into
mainfrom
revert-checksum-fail-closed-1503

Conversation

@liangshuo-1

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

Copy link
Copy Markdown
Collaborator

Reverts #1503 (commit ec6fdc9b).

What this reverts

PR #1503 made the npm install script fail closed when checksums.txt was missing: getExpectedChecksum threw [SECURITY] checksums.txt not found and verifyChecksum threw on a null/empty expected hash.

This restores the prior behavior:

  • getExpectedChecksum — logs [WARN] checksums.txt not found, skipping checksum verification and returns null.
  • verifyChecksum — skips verification when expectedHash === null.
  • Tests reverted to match.

Note

This re-opens the security 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
    • Improved install behavior when checksum metadata is unavailable: installation now continues with a warning instead of stopping with a security error.
    • Checksum verification is skipped when no expected checksum can be determined, avoiding failed installs in that case.

@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

📝 Walkthrough

Walkthrough

Checksum verification in the install script now fails open: when checksums.txt is missing, getExpectedChecksum logs a warning and returns null instead of throwing; verifyChecksum returns early when the expected hash is null. Corresponding tests are updated to match, removing the prior fail-closed security-error assertions.

Changes

Checksum verification behavior

Layer / File(s) Summary
Fail-open checksum logic
scripts/install.js
getExpectedChecksum() warns and returns null instead of throwing when checksums.txt is missing; verifyChecksum() returns early without error when expectedHash is null.
Updated test expectations
scripts/install.test.js
Tests now expect null return for missing checksums.txt rather than a thrown security error, and the fail-closed verifyChecksum test case is removed.

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

Possibly related PRs

  • larksuite/cli#592: Modifies the same getExpectedChecksum()/verifyChecksum() helpers in scripts/install.js that this PR changes.
  • larksuite/cli#1503: Introduced the fail-closed checksum behavior that this PR reverses, along with matching test changes.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
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 (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: warning instead of failing when checksums.txt is missing.
Description check ✅ Passed The description covers the revert, behavior changes, and test results, but it does not follow the required template sections.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch revert-checksum-fail-closed-1503

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.

@liangshuo-1 liangshuo-1 changed the title Revert "feat: fail closed when checksums.txt is missing during install (#1503)" install: warn instead of failing when checksums.txt is missing Jul 1, 2026
@liangshuo-1 liangshuo-1 closed this Jul 1, 2026
@liangshuo-1
liangshuo-1 deleted the revert-checksum-fail-closed-1503 branch July 1, 2026 14:39

@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: 1

🤖 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 267-272: The checksum fallback in verifyChecksum currently fails
open by returning null when checksums.txt is missing, which lets install proceed
without integrity validation. Update the logic around verifyChecksum and its
call site in install() so the default behavior remains fail-closed, and only
skip verification when an explicit opt-in env flag such as
LARK_CLI_SKIP_CHECKSUM is set. Also confirm the published package always
includes checksums.txt so this branch is limited to edge or dev scenarios.
🪄 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: 4d60cfe2-2575-4066-8273-dc6385bc39b7

📥 Commits

Reviewing files that changed from the base of the PR and between ad4d3cb and 7dbed50.

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

Comment thread scripts/install.js
Comment on lines 267 to 272
if (!fs.existsSync(checksumsPath)) {
throw new Error(
"[SECURITY] checksums.txt not found; refusing to install an unverified binary."
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 | 🏗️ Heavy lift

Fail-open checksum verification allows installing an unverified binary.

Returning null when checksums.txt is absent causes verifyChecksum (Line 289) to skip integrity checks entirely, so install() will download, extract, and chmod 0o755 a binary whose SHA-256 was never validated (Lines 241-256). This weakens the supply-chain integrity guarantee: any download source in downloadUrls (including the npmmirror fallback) is trusted implicitly when the checksum file is missing.

I recognize this is a deliberate revert of #1503 per the PR objectives. Flagging so the tradeoff is explicit: consider gating fail-open behind an opt-in env flag (e.g. LARK_CLI_SKIP_CHECKSUM=1) so the default remains fail-closed, and confirm checksums.txt is always shipped in the published npm package so this branch is only reachable in edge/dev cases.

🤖 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 267 - 272, The checksum fallback in
verifyChecksum currently fails open by returning null when checksums.txt is
missing, which lets install proceed without integrity validation. Update the
logic around verifyChecksum and its call site in install() so the default
behavior remains fail-closed, and only skip verification when an explicit opt-in
env flag such as LARK_CLI_SKIP_CHECKSUM is set. Also confirm the published
package always includes checksums.txt so this branch is limited to edge or dev
scenarios.

@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 (7dbed50).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1711   +/-   ##
=======================================
  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.

@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@7dbed50529a5ea315a065851a680b55a69f0c089

🧩 Skill update

npx skills add larksuite/cli#revert-checksum-fail-closed-1503 -y -g

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