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

detectExecuteScan needs to run "npm install" #2142

Closed
phil-mitchell opened this issue Oct 7, 2020 · 7 comments
Closed

detectExecuteScan needs to run "npm install" #2142

phil-mitchell opened this issue Oct 7, 2020 · 7 comments
Labels
BlackDuck discussion stale marks stale issues and pull requests

Comments

@phil-mitchell
Copy link

Whereas whitesourceExecuteScan installs node modules prior to running the scan:

if err := reinstallNodeModulesIfLsFails(modulePath, config, utils); err != nil {

There is no such action taken for detectExecuteScan.

If this installation is not done, it places a restriction on the structure and order of pipelines, which is overly restrictive and, in my case, not desirable.

Can we please relax this restriction by running "npm install" within the detectExecuteScan step?

@stippi2
Copy link
Member

stippi2 commented Oct 7, 2020

Actually, this is something we are not sure about in whitesourceExecuteScan. We almost removed it before merging. The basic principle should be that what is scanned is actually what will be deployed in the end. A problem with "npm ls" could either originate from a broken package-lock.json, or from running the build and the scan with different node versions. It isn't clear to me what the correct fix would be in each case, but maybe the pipeline is right in being restrictive. I am not sure what the root problem is in your case. Has "npm install" happened somewhere else already and the result is not properly transported via stashing/unstashing between stages?

@phil-mitchell
Copy link
Author

phil-mitchell commented Oct 7, 2020

"npm install" elsewhere in the pipeline has the same problem. We want to run the scans in parallel to the other steps. If package-lock.json is broken, would it not also affect other parts of the build in the same way? The current behaviour relies on "accidentally" having the node_modules already installed. Also, what if the node_modules directory exists but is not fully populated due to some behaviour earlier in the pipeline? It will silently scan the wrong thing.

It is messy and error-prone to rely on a particular state of the workspace at the start of the step, unless you are going to explicitly enforce some pre-condition. If you want to be restrictive, then, I would request that you make it explicit. i.e. require a stash to be specified that must be unstashed in a clean workspace prior to running the scans. Otherwise the problems you've listed above are only a small subset of the problems that can occur.

Or, just do the "npm install" yourself to ensure that the workspace is in a consistent state prior to running the scan. Node version should be configurable using a docker image. Broken package-lock is a code error and maybe the package-lock should be verified prior to running if you're worried about that.

@sebastianhof
Copy link

We have the same requirements to run npm install before executing the detect scan. Will there be an official support scanning npm projects in near future? There is even a configuration option InstallArtifacts which unfortunately only works with maven artifacts so far.

@phil-mitchell
Copy link
Author

Any update on this topic? It's a bit of a blocker for us.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2021

Thank you for your contribution! This issue is stale because it has been open 60 days with no activity. In order to keep it open, please remove stale label or add a comment within the next 10 days. If you need a Piper team member to remove the stale label make sure to add @SAP/jenkins-library-team to your comment.

@github-actions github-actions bot added the stale marks stale issues and pull requests label Dec 5, 2021
@github-actions
Copy link
Contributor

Issue got stale and no further activity happened. It has automatically been closed. Please re-open in case you still consider it relevant.

@giancorderoortiz
Copy link

Any updates?
Still need to run 'npm install' so that actual scan can take place ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BlackDuck discussion stale marks stale issues and pull requests
Projects
None yet
Development

No branches or pull requests

5 participants