๐Ÿ™Œ How to get rid of vulnerabilities with just NPM ๐Ÿ‘€

Sometimes when you’re trying to install or re-use some kind of global package on the NPM environment, you will get messages telling you something like this:

As NPM itself will suggest, you, should audit them, to kindly fix them โ˜บ๏ธ

But let me make…


This content originally appeared on DEV Community and was authored by Luรญs Von Muller

Sometimes when you're trying to install or re-use some kind of global package on the NPM environment, you will get messages telling you something like this:

Installing a package

As NPM itself will suggest, you, should audit them, to kindly fix them โ˜บ๏ธ

Warnings of vulnerabilities

But let me make it clear,: That is for sure, not the real way to "Security" audit things, but it is for sure, the minimum safe way that you must stay (at least) for the greater good!

This kind of vulnerability could became a real problem, especially when your packages are global packages.

I mean, When you're using the "-g" flag to make it system wide available.

For this, its a minimum good practice to also use things like NPX. But... if you're that lazy, as I am, here is this small shenanigan that could help you to keep yourself a bit more safe. ๐Ÿ‘€

๐Ÿšถ Step by Step ๐Ÿšถ

1. Lets update NPM itself! ๐Ÿ‘‰

On the bash, or terminal, type:

$ npm install npm@latest -g

The $ means that you're into the bash or at least on a terminal like prompt ๐Ÿ˜…

The output will look something near like...
Updating NPM

And...
Image description
... Ok I'll just type the "$ npm audit" then...

Image description

WAT?

Image description

Yes, that is totally accurate! ๐Ÿ‘Œ

NPM audit will check inside the package you're on (or even none if your not). It will not check the for entire "NPM" global environment.

OMG - David504

Context for the quote: https://www.youtube.com/watch?v=B6LpzJLrhpw

2. So, what should I do!? ๐Ÿค”

The right way? use rust ๐Ÿฆ€ . Joking, you could use NPX, but if you don't want to (as I don't)... wait there!

You know what NPM people loves? Packages. ๐Ÿ“ฆ

And so we does! We love packages ๐Ÿฅฐ! But what about installing another global package to fix global packages?

Avarege Package Enjoyer with a big brain

Now you must say: That looks sooo great!

Then, Kindly type into the terminal this, while praying to NPM's gods:

$ npm install -g npm-check-updates

The output gonna be like:

Output of npm install minus g npm check updates

Thanks god that wasn't any vulnerability inside the vulnerability checking package ๐Ÿ˜ฎโ€๐Ÿ’จ

3. NCU - A Package Inception! ๐Ÿ˜ณ

If all went good till now, guess what? You will have another package globally available to use! ๐Ÿ˜Œ

And guess what? This one can say which ones we should upgrade to get rid of:

(ใฃโ—”โ—กโ—”)ใฃ โ™ฅ legacy code vulnerabilities โ™ฅ

Another Global package? Thats great!

But, how do we use it?. Again, from the terminal, type:

$ ncu -g

Output should like:

An output from the ncu package

On the last line, it will give yourself the minimum needed updates to fix common vulnerabilities that were fixed on newer versions! ๐Ÿคฉ

my upgrade listings...

Now... lets just, as always: CTRL+C -> CTRL+V stuff. ๐Ÿ˜Ž

Then you will be prompted with:
After running upgrades...

Vulnerabilities again?

65 WAT?

Yes, that is again, fairly right ๐Ÿคฆโ€โ™‚๏ธ

What you will need to execute, instead of the other command that I told you to run is this one:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
and you will have Rust and Rust's Cargo!

Nah, lets talk serious now... ๐Ÿ™„

You got rid of the Global Packages vulnerabilities (from themselves) by upgrading them. But those packages (sometimes) depends on other packages...
I told you that NPM's guys really like packages ยฏ_(ใƒ„)_/ยฏ

There will be, always, some vulnerabilities left inside these (dependencies). But not within being into a Global Package itself, then we're kinda good to go.

And to make sure there is not left, you can re-check it by doing so:

$ ncu -g

(to check if there is the need to upgrade any to a safer version)

Rechecking global packages.

Conclusion? ๐Ÿค”

If you gonna stand with just NPM without NPX please, at least do this.

I will soon write a how to NPX... or not

Thanks! Follow me on the Dev Bubble on Twitter


This content originally appeared on DEV Community and was authored by Luรญs Von Muller


Print Share Comment Cite Upload Translate Updates
APA

Luรญs Von Muller | Sciencx (2022-01-04T17:42:05+00:00) ๐Ÿ™Œ How to get rid of vulnerabilities with just NPM ๐Ÿ‘€. Retrieved from https://www.scien.cx/2022/01/04/%f0%9f%99%8c-how-to-get-rid-of-vulnerabilities-with-just-npm-%f0%9f%91%80/

MLA
" » ๐Ÿ™Œ How to get rid of vulnerabilities with just NPM ๐Ÿ‘€." Luรญs Von Muller | Sciencx - Tuesday January 4, 2022, https://www.scien.cx/2022/01/04/%f0%9f%99%8c-how-to-get-rid-of-vulnerabilities-with-just-npm-%f0%9f%91%80/
HARVARD
Luรญs Von Muller | Sciencx Tuesday January 4, 2022 » ๐Ÿ™Œ How to get rid of vulnerabilities with just NPM ๐Ÿ‘€., viewed ,<https://www.scien.cx/2022/01/04/%f0%9f%99%8c-how-to-get-rid-of-vulnerabilities-with-just-npm-%f0%9f%91%80/>
VANCOUVER
Luรญs Von Muller | Sciencx - » ๐Ÿ™Œ How to get rid of vulnerabilities with just NPM ๐Ÿ‘€. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/01/04/%f0%9f%99%8c-how-to-get-rid-of-vulnerabilities-with-just-npm-%f0%9f%91%80/
CHICAGO
" » ๐Ÿ™Œ How to get rid of vulnerabilities with just NPM ๐Ÿ‘€." Luรญs Von Muller | Sciencx - Accessed . https://www.scien.cx/2022/01/04/%f0%9f%99%8c-how-to-get-rid-of-vulnerabilities-with-just-npm-%f0%9f%91%80/
IEEE
" » ๐Ÿ™Œ How to get rid of vulnerabilities with just NPM ๐Ÿ‘€." Luรญs Von Muller | Sciencx [Online]. Available: https://www.scien.cx/2022/01/04/%f0%9f%99%8c-how-to-get-rid-of-vulnerabilities-with-just-npm-%f0%9f%91%80/. [Accessed: ]
rf:citation
» ๐Ÿ™Œ How to get rid of vulnerabilities with just NPM ๐Ÿ‘€ | Luรญs Von Muller | Sciencx | https://www.scien.cx/2022/01/04/%f0%9f%99%8c-how-to-get-rid-of-vulnerabilities-with-just-npm-%f0%9f%91%80/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.