Skip to content

Add package.json dependecis parsing#59

Open
SzymonDrosdzol wants to merge 3 commits into
mainfrom
package-json-deps
Open

Add package.json dependecis parsing#59
SzymonDrosdzol wants to merge 3 commits into
mainfrom
package-json-deps

Conversation

@SzymonDrosdzol

Copy link
Copy Markdown

Adds parsing dependencies from package.json files.

Opt-in, needs to be enabled in config. Full command:

go run ./binary/scalibr/scalibr.go 
    --root ~/Documents/projects/test-project \
    --plugins javascript/packagejson \
    --plugin-config='javascript_package_json:{include_dependencies:true include_dev_dependencies:true include_optional_dependencies:true include_peer_dependencies:true}' \
    -o cdx-json=./result.cdx.json

pkgs[key] = current
continue
}
pkgs[key] = mergeDependencyDetails(existing, current)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is there a reason why only using append here would be wrong?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I thought I understood the question, but the more Iook at it the less I see any ways that append could make it simpler while preserving the logic.
Can you give an example?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I guess a better questions would be:

  1. Can the code be refactored to directly modify pkgs[key].depGroups?
  2. Is using slices.Clone, slices.Sort(merged) and slices.Compact(merged) actually needed?

@SzymonDrosdzol SzymonDrosdzol Jul 7, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

  • refactored len(d.depGroups) == 0 to a separate function to better convey its purpose
  • Added some comments
  • Removed slices calls

Please verify @alessandro-Doyensec

Comment thread extractor/filesystem/language/javascript/packagejson/packagejson.go Outdated

@alessandro-Doyensec alessandro-Doyensec left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM 🚀

@v1ktor0t

v1ktor0t commented Jul 8, 2026

Copy link
Copy Markdown
Member

lgtm 🚀

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.

3 participants