Skip to content

Add support for authors in package.json. Fixes #2250 #4003

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 13, 2025

Conversation

popey
Copy link
Contributor

@popey popey commented Jun 13, 2025

Description

This PR adds support for parsing the authors field in package.json files. Previously, Syft only recognized the singular author field, but the npm ecosystem supports both formats. This change ensures that Syft properly parses both formats and combines them when both are present in a package.json file.

The implementation:

  1. Adds a new authors []author type to handle the plural form
  2. Implements UnmarshalJSON to handle parsing different formats (array of strings or objects)
  3. Adds AuthorsString() to convert authors array to a properly formatted string
  4. Updates newPackageJSONPackage to handle both fields appropriately

This change improves the accuracy of npm package metadata parsing in Syft.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

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

Signed-off-by: Alan Pope <alan.pope@anchore.com>
Signed-off-by: Alan Pope <alan.pope@anchore.com>
@popey popey force-pushed the package.json-authors-parsing branch from 2c9486a to 7c154ba Compare June 18, 2025 14:15
This change helps us cover maintainers and contributros if they exist.
These fields follow the same structured or stringified pattern that
authors does.

Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com>
@spiffcs
Copy link
Contributor

spiffcs commented Aug 13, 2025

Kicked the tires on this one and added support for maintainers and contributors as well

@spiffcs
Copy link
Contributor

spiffcs commented Aug 13, 2025

@popey huge 🥳 for this one. Sorry for the lag and glad this is making it's way forward. Will baby sit to get this in no more needed from other authors or maintainers.

@spiffcs spiffcs merged commit 87e1d8c into main Aug 13, 2025
12 checks passed
@spiffcs spiffcs deleted the package.json-authors-parsing branch August 13, 2025 21:55
hawkaii pushed a commit to hawkaii/syft that referenced this pull request Aug 14, 2025
…ge.json. (anchore#4003)

Fixes anchore#2250
---------
Signed-off-by: Alan Pope <alan.pope@anchore.com>
Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com>
Co-authored-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com>
Signed-off-by: Parthib Mukherjee <parthibmukherjee@gmail.com>
spiffcs added a commit that referenced this pull request Aug 18, 2025
* main:
  chore(deps): bump github.com/hashicorp/go-getter from 1.7.8 to 1.7.9 (#4144)
  chore(deps): bump anchore/sbom-action from 0.20.4 to 0.20.5 (#4141)
  chore(deps): update tools to latest versions (#4139)
  feat: add support for authors, maintainers, and contributors in package.json.  (#4003)
  chore(deps): bump zizmorcore/zizmor-action from 0.1.1 to 0.1.2 (#4135)
  feat: add package supplier flag (#4131)
  feat: update syft license construction to be able to look up by URL (#4132)
  chore(deps): bump github/codeql-action from 3.29.8 to 3.29.9 (#4134)
  fix: support multiple letters in openssl patch version (#4106)
  fix: closed reader during java binary detection (#4129)
  chore(deps): bump actions/checkout from 4.2.2 to 5.0.0 (#4130)
  chore: update GoReleaser configurations (#4128)
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.

package.json authors keyword parsing
3 participants