Skip to content

fix: parse dual-document pnpm v9 lockfiles (bootstrap + project sections) #669

@Ayush7614

Description

@Ayush7614

Summary

Some pnpm v9 lockfiles contain two YAML documents separated by ---: a bootstrap block (package-manager dependencies like pnpm@11.1.3) and the main project lockfile. CVE Lite currently calls YAML.parse() on pnpm-lock.yaml, which throws:

Error: Source contains multiple documents; please use YAML.parseAllDocuments()

Reproduction

  1. Clone apify/apify-mcp-server (or any repo with dual-document pnpm-lock.yaml)
  2. Run cve-lite /path/to/apify-mcp-server --json
  3. Scan fails before any findings are produced

Example upstream file: pnpm-lock.yaml — bootstrap document ends ~line 198, main project lockfile starts at second ---.

Expected behavior

CVE Lite should select the project lockfile document (the section with root importers[].dependencies / devDependencies and the large snapshots graph) and scan it normally.

Proposed fix

  • Try YAML.parse() first (single-document lockfiles unchanged)
  • On multi-document error, use YAML.parseAllDocuments() and pick the document with the highest score (dependency count + snapshot/package entries)
  • Add regression test with minimal dual-document fixture

Impact

Without this fix, lockfile-only scans fail entirely for affected pnpm projects — no findings, no fix commands, no case-study baseline possible.


Opened by @Ayush7614. Local fix + regression test prepared; happy to open PR if maintainers confirm approach.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions