Skip to content

Conversation

bernardoamc
Copy link

Description

Allow pnpm v9 lockfiles to be parsed by Syft. This version has a different structure compared to previous lockfiles, nesting fields like dependencies and devDependencies within the concept of an importer. In order to keep backwards compatibility the code has been refactored to:

  1. Create a shared interface for parsing pnpm files while attempting to keep most of the functionality consolidated across common functions
  2. We have also optimize our logic to check for duplicated packages by utilizing a map rather than repeatedly iterating through a slice.

Fixes: #3927

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist:

  • I have added unit tests that cover changed behavior
  • I have tested my code in common scenarios and confirmed there are no regressions
  • I have added comments to my code, particularly in hard-to-understand sections

@bernardoamc
Copy link
Author

We are only parsing the packages key while leaving the option to parse the remaining fields. I think this covers the current functionality since packages should contain every package listed within every other field.

@bernardoamc bernardoamc force-pushed the bc-parse-v9-lockfiles branch from fc04d5f to b49e6f7 Compare October 6, 2025 15:12
@bernardoamc
Copy link
Author

Adjusted the code so newPnpmLockfileParser doesn't get exported.

@spiffcs spiffcs self-requested a review October 6, 2025 15:29
Signed-off-by: bernardoamc <bernardo.amc@gmail.com>
@bernardoamc bernardoamc force-pushed the bc-parse-v9-lockfiles branch from b49e6f7 to a2e777e Compare October 6, 2025 15:56
@bernardoamc
Copy link
Author

For some reason my local environment did no catch these exported warnings. I've also made the interface private it.

@bernardoamc
Copy link
Author

Thanks for the review @spiffcs, I appreciate it! Hopefully this build will be a green one. 😄

@bernardoamc
Copy link
Author

Glad the export-check was the only blocker. 😄

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.

PNPM latest lockfile (version 9.0)
2 participants