Skip to content

fix: split checksums on any line ending so LF files parse on Windows#443

Merged
bdehamer merged 1 commit into
mainfrom
bdehamer-bdehamer-fix-checksums-lf-windows
Jul 9, 2026
Merged

fix: split checksums on any line ending so LF files parse on Windows#443
bdehamer merged 1 commit into
mainfrom
bdehamer-bdehamer-fix-checksums-lf-windows

Conversation

@bdehamer

@bdehamer bdehamer commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes a bug where an LF-only checksums file is not parsed correctly on Windows, causing all but the first listed artifact to be silently left unattested while the action still succeeds.

Bug

getSubjectFromChecksumsString in src/subject.ts split the checksums input using the platform-specific line ending:

const records: string[] = checksums.split(os.EOL).filter(Boolean)

Root cause

On Windows os.EOL is \r\n. An LF-only (\n) checksums file therefore never splits — the entire file becomes a single record. The first 64 hex characters are taken as the digest and everything after the first space (including all newlines and subsequent lines) becomes the subject name. Result: only the first artifact is attested and every other listed file is silently dropped, with the step still reporting success.

Fix

  • Split on /\r?\n/ so parsing is line-ending agnostic (handles LF, CRLF, and mixed inputs on any platform).
  • Removed the now-unused os import from src/subject.ts.

Defense in depth

After computing each subject name, reject any name containing a newline (\n or \r) by throwing a descriptive error. If input ever fails to split correctly again, this turns a silent partial attestation into a loud failure.

Tests

Added regression tests in __tests__/unit/subject.test.ts:

  • LF-only multi-line checksums produce a separate subject per record.
  • CRLF checksums split into separate subjects.
  • A subject name containing a newline throws.

npm run lint, npm test (112 passing, 100% coverage), and npm run bundle all pass; the regenerated dist/ is committed so the check-dist CI check stays green.

Workaround

Until this is released, affected users can switch from subject-checksums to subject-path.

Fixes #440

getSubjectFromChecksumsString split the checksums input on os.EOL. On
Windows os.EOL is "\r\n", so an LF-only checksums file never split: the
whole file collapsed into a single record, only the first artifact was
attested, and every other listed file was silently left unattested while
the step still succeeded.

Split on /\r?\n/ instead so the parser is line-ending agnostic, and add
a defense-in-depth guard that rejects any subject name containing a
newline so a malformed multi-line record fails loudly instead of
producing a partial attestation. Regenerated dist/ to match.

Fixes #440

Co-authored-by: Copilot App <[email protected]>
@bdehamer
bdehamer marked this pull request as ready for review July 8, 2026 23:01
@bdehamer
bdehamer requested a review from a team as a code owner July 8, 2026 23:01
Copilot AI review requested due to automatic review settings July 8, 2026 23:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes cross-platform parsing of subject-checksums input so checksum files with LF line endings are correctly parsed on Windows, preventing silent partial attestations.

Changes:

  • Parse checksums records using a line-ending agnostic split (/\r?\n/) and remove the unused os import.
  • Add a defense-in-depth validation to reject subject names containing newline characters.
  • Add regression tests for LF-only input on Windows, CRLF input, and newline-containing subject names; update bundled dist/.
Show a summary per file
File Description
src/subject.ts Makes checksums parsing line-ending agnostic and adds a guard against multiline subject names.
dist/index.js Updates the bundled output to reflect the src/subject.ts changes.
tests/unit/subject.test.ts Adds regression tests covering LF, CRLF, and newline-in-name failure behavior.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/3 changed files
  • Comments generated: 1
  • Review effort level: Low

Comment thread src/subject.ts
Comment on lines +209 to +211
if (/[\r\n]/.test(name)) {
throw new Error(`Invalid subject name (contains a newline): ${name}`)
}
@bdehamer
bdehamer merged commit 7b8fc06 into main Jul 9, 2026
6 checks passed
@bdehamer
bdehamer deleted the bdehamer-bdehamer-fix-checksums-lf-windows branch July 9, 2026 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

subject-checksums: LF-only checksums file on a Windows runner parses as ONE subject; remaining files silently unattested

3 participants