Skip to content
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

fix(npm): Introduce installation for cyclone-node-npm in another folder and fallback to cyclonedx/bom to help users generate BOM #4390

Merged
merged 13 commits into from
Jul 11, 2023

Conversation

ashlymat
Copy link
Member

@ashlymat ashlymat commented Jun 5, 2023

  • Install cyclonedx-npm module in a separate (to avoid extraneous errors ) and try to generate BOM as this is the recommended and generates a more detailed BOM

  • Lots of users are still facing issues , this is mostly due to how cyclonedx-node-npm module relies on npm ls command internally, which is used internally to generate a a dependency tree of infinite depth. For some users with special settings, there are hiccups on how this command works and hence BOM generation is affected. More details can be found here and here.

  • Hence ,we use cyclonedx/bom as a fallback to generate BOM - to facilitate BOM generation when new module throws errors.

  • To avoid publishing this new folder and packages , an entry to npmignore was added

@ashlymat ashlymat force-pushed the tryCyclone branch 5 times, most recently from bf6f30c to c3e5abb Compare June 12, 2023 05:31
@ashlymat ashlymat changed the title fix(npm): Add ignore-npm-errors cli flag for npm BOM generation fix(npm): Introduce global installation for cyclone-node-npm and fallback to cyclonedx/bom to help users generate BOM Jun 15, 2023
@ashlymat ashlymat force-pushed the tryCyclone branch 4 times, most recently from 20dd026 to 5ac4d66 Compare June 20, 2023 11:27
@ashlymat
Copy link
Member Author

/it-go

@ashlymat ashlymat marked this pull request as ready for review June 21, 2023 08:51
@ashlymat ashlymat requested a review from a team as a code owner June 21, 2023 08:51
jliempt
jliempt previously approved these changes Jun 23, 2023
@ashlymat ashlymat force-pushed the tryCyclone branch 2 times, most recently from 9e2a72a to da895bb Compare June 26, 2023 14:38
@ashlymat ashlymat changed the title fix(npm): Introduce global installation for cyclone-node-npm and fallback to cyclonedx/bom to help users generate BOM fix(npm): Introduce installation for cyclone-node-npm in another folder and fallback to cyclonedx/bom to help users generate BOM Jun 27, 2023
@ashlymat ashlymat dismissed jliempt’s stale review June 27, 2023 08:51

Significant change in code since last review, will be helpful to look again

Copy link
Member

@jliempt jliempt left a comment

Choose a reason for hiding this comment

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

I now see in the logs that with the publish flag set to true, it finds an additional package.json and publishes that:

info  npmExecuteScripts - Discovered package.json file bomFolder/package.json
info  npmExecuteScripts - Discovered package.json file package.json
info  npmExecuteScripts - triggering publish for bomFolder/package.json

I'm not sure how that package.json is created in bomFolder, but I feel it should be excluded when publishing.

Apart from that, it works well, having tested it with a few images.

pkg/npm/npm.go Outdated Show resolved Hide resolved
@ashlymat
Copy link
Member Author

ashlymat commented Jul 3, 2023

I now see in the logs that with the publish flag set to true, it finds an additional package.json and publishes that:

info  npmExecuteScripts - Discovered package.json file bomFolder/package.json
info  npmExecuteScripts - Discovered package.json file package.json
info  npmExecuteScripts - triggering publish for bomFolder/package.json

I'm not sure how that package.json is created in bomFolder, but I feel it should be excluded when publishing.

Apart from that, it works well, having tested it with a few images.

Good catch.
I have introduced back "--no-save" option, which seems to solve this issue
but still see the published tarball notices this new folder and installed package and publishes it as a much bigger package .
To solve this we needed to add this new folder to .npmignore in publish.go

@ashlymat ashlymat force-pushed the tryCyclone branch 3 times, most recently from fc40afc to de79343 Compare July 3, 2023 12:06
@ashlymat
Copy link
Member Author

ashlymat commented Jul 4, 2023

/it-go

@ashlymat
Copy link
Member Author

ashlymat commented Jul 6, 2023

@jliempt thanks for approval, will merge on Monday

@ashlymat
Copy link
Member Author

/it-go

3 similar comments
@ashlymat
Copy link
Member Author

/it-go

@ashlymat
Copy link
Member Author

/it-go

@ashlymat
Copy link
Member Author

/it-go

@sonarcloud
Copy link

sonarcloud bot commented Jul 11, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@ashlymat
Copy link
Member Author

/it-go

@ashlymat ashlymat merged commit 34202c7 into master Jul 11, 2023
9 checks passed
@ashlymat ashlymat deleted the tryCyclone branch July 11, 2023 14:18
maxatsap pushed a commit to maxatsap/jenkins-library that referenced this pull request Jul 23, 2024
…er and fallback to cyclonedx/bom to help users generate BOM (SAP#4390)

* Test

* Try omit

* Introduce global installation and fallback

* Extract to a separate function

* Fix unit tests

* Add root permissions for docker image for Azure

* Install in another folder

* fix unit tests

* Cleanup

* introduce back --no-save,change directory name, fix tests

* add tmp folder to npmignore

* change docker image for guage

* Revert "change docker image for guage"

This reverts commit 45ac7ca.
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.

2 participants