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

feat: only return false on 404 in hasNpmPackage #96

Merged
merged 1 commit into from
Jun 16, 2020
Merged

feat: only return false on 404 in hasNpmPackage #96

merged 1 commit into from
Jun 16, 2020

Conversation

CGA1123
Copy link
Contributor

@CGA1123 CGA1123 commented May 16, 2020

Currently, if the registry returns anything that is not a 200 status
code this function returns false. In the case where we are trying to
check whether the package associated with a friendly name and the registry
returns a 503 this will result in fetching and installing
the wrong package.

i.e. Doing heroku plugins:install api

In this case, this is fairly harmless as that particularly library
doesn't do much. However, it could be used maliciously!

I think it may be better to re-raise the initial error in this scenario if we
can't be sure that the package does not exist.

@salesforce-cla
Copy link

Thanks for the contribution! Before we can merge this, we need @CGA1123 to sign the Salesforce.com Contributor License Agreement.

@codecov
Copy link

codecov bot commented May 16, 2020

Codecov Report

Merging #96 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff           @@
##           master     #96   +/-   ##
======================================
  Coverage    0.00%   0.00%           
======================================
  Files           5       5           
  Lines          93      93           
  Branches       17      17           
======================================
  Misses         93      93           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5ef24a1...2f227fa. Read the comment docs.

@RasPhilCo
Copy link
Contributor

Interestingly - say you wanted to install api right now, you couldn't.

Can you fix the merge conflict and I can merge this?

@RasPhilCo RasPhilCo changed the title Only return false on 404 in hasNpmPackage feat: only return false on 404 in hasNpmPackage Jun 10, 2020
Currently, if the registry returns anything that is not a 200 status
code this function returns `false`. In the case where we are trying to
check whether the package associated to a friendly name and the registry
returns for example a 503 this will result in fetching and installing
the wrong package.

i.e. Doing `heroku plugins:install api`
- Attempt to see if [`@heroku-cli/plugin-api`](https://www.npmjs.com/package/@heroku-cli/plugin-api) exists
- NPM returns 503
- Install [`api`](https://www.npmjs.com/package/api)!!

In this case this is fairly harmless as that particularly library
doesn't do much, however, it is annoying and could be used maliciously!
@CGA1123
Copy link
Contributor Author

CGA1123 commented Jun 10, 2020

@RasPhilCo Done ✅

Copy link
Contributor

@RasPhilCo RasPhilCo left a comment

Choose a reason for hiding this comment

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

🏄

@RasPhilCo RasPhilCo merged commit 3599c91 into oclif:master Jun 16, 2020
@CGA1123
Copy link
Contributor Author

CGA1123 commented Jun 16, 2020

Thanks @RasPhilCo 🚀

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