Steps to reproduce:

  1. Start a Node project that uses at least five direct dependencies.
  2. Leave it alone for three months.
  3. Come back and try to install it.

Something in the dependency tree will yell at you that it is deprecated or discontinued. That thing will not be one of your direct dependencies.

NPM will tell you that you have at least one security vulnerability. At least one of the vulnerabilities will be impossible to trigger in your particular application. At least one of the vulnerabilities will not be able to be fixed by updating the versions of your dependencies.

(I am sure I exaggerate, but not by much!)

Why is it like this? How many hours per week does this running-to-stay-in-place cost the average Node project? How many hours per week of developer time is the minimum viable Node project actually supposed to have available?

86 points

Because 99% of Node projects are web related, and if something’s vulnerable on the web it won’t take long to be abused

permalink
report
reply
13 points

Hey, a good answer! 🙌

permalink
report
parent
reply
6 points

Danke!

permalink
report
parent
reply
3 points

Prego!

permalink
report
parent
reply
7 points
*

Also a great disadvantage with JavaScript being the official scripting language of the web so it needs to work in every browser, but not every browser will implement it the same way. Syntax between the browser and servers also gets conflated.

I’ve done frontend development in Java and it sucks major ass. The “advantage” of using one language for the whole project really ended up as a net negative. For any server-side project I’m totally fine using Java because for all it’s verbosity it’s secure, performant, and examples from 10 years ago aren’t useless.

permalink
report
parent
reply
3 points

Fron-end development with Java? You mean Java applets or something?

permalink
report
parent
reply
4 points

JSF for example. e.g. Primefaces https://www.primefaces.org/ I think there is something like Omnifaces too

permalink
report
parent
reply
2 points

Google Web Toolkit was a thing at some point in time. ;y current company still maintains some apps which are written in it.

permalink
report
parent
reply
3 points

JSP used to be the shit back in the day. Imagine server-side rendered html through Java. Nowadays it’s properly regarded as shit, fortunately.

permalink
report
parent
reply
2 points

I tought JSP was just one templating solution like mustache, jinja2, Thymeleaf etc. But guess theres more to it.

permalink
report
parent
reply
30 points
*

If you set the versions of your dependencies in the package.json file, you’ll reinstall exactly the same ones.

You may get new vulnerability warnings popping up, but what is the issue here ? You’d rather not be aware that a vulnerability has been found since your last development ?

If you are not happy with others modules, dev your own and no one will let you know about security issues 😝

permalink
report
reply
4 points

You’d rather not be aware that a vulnerability has been found since your last development ?

I’d rather develop with dependencies that don’t have so many vulnerabilities.

permalink
report
parent
reply
13 points

Yeah we all wanna do that, but nobody writes perfect code.

permalink
report
parent
reply
5 points
*

That’s why people came up with defensive programming and functional correctness.

Just seems to be difficult for the webdev industry. Seems easier to push fixes from time to time.

permalink
report
parent
reply
9 points

Then you’re in the wrong industry…

permalink
report
parent
reply
3 points

If you mean web development, you’re right.

If you mean computer science, then I’d say that webdevs have little in common with the industry that came up with stuff like ADA or functional correctness.

permalink
report
parent
reply
2 points

If you set the versions of your dependencies in the package.json file

Or if you leave that alone, and update your package-lick.json so can install exact dependencies with npm ci

permalink
report
parent
reply
2 points
Deleted by creator
permalink
report
parent
reply
11 points

I’m struggling to understand how there can be so many security flaws, even in things that don’t seem to matter for security. I think the bar for a security problem might be too low; a lot of these look like footguns that could give my package a security hole, rather than genuine security flaws in the packages they are reported on.

Here’s a progress bar package with a “high” security vulnerability because it contains an internal utility that merges objects and doesn’t stop you writing to the prototype. Did the progress bar package ever promise to provide an object merge function that was safe to use on untrusted user input?

Here’s a notification UI element that bills using HTML in your notification messages as a feature. It has a “medium” level “XSS” security vulnerability where the message parameter is not sanitized to remove HTML. A CVE was issued for this.

Here’s an arbitrary code execution vulnerability in sqlite3! High severity! The bug is that, if you tell sqlite3 to substitute an object into an SQL statement, it will run the ToString() method on the object. If an evil hacker has broken into your lead developer’s house and written a malicious ToString() method into one of the classes of object you use as a database query parameter, then that code would run! The fix here was, instead of letting the normal Javascript stringification rules apply, to hardcode all objects to be inserted into the database as “[object Object]”, because surely that is what the programmer meant to store.

permalink
report
parent
reply
8 points

You don’t need to do anything when you get a security advisory if you’re not impacted or the risk is acceptable. They’re just there to advise you.

permalink
report
parent
reply
8 points

The problem is that when you are alerted for trivial/non-actionable stuff it contributes to “alert-fatigue” and you just start ignoring all of the alerts.

As far as I’m aware, there’s also no way to triage an alert from an install other than to upgrade the offending package, which means you can’t really discriminate on the basis of “acceptable risk”

permalink
report
parent
reply
5 points
Deleted by creator
permalink
report
parent
reply
2 points

Something in the dependency tree will yell at you that it is deprecated or discontinued.

Only if you didn’t pinned the dependencies you actually consume, and expect that all your dependencies magically comply with semver.

Blindly replacing dependency versions never worked, at least reliably. If you do not put in the work to ensure things work, more often than not you’ll be surprised by them not working.

permalink
report
reply
5 points

Then you’ll end up with tons of vulnerabilities within days. That can’t be the solution either.

permalink
report
parent
reply
3 points

Then you’ll end up with tons of vulnerabilities within days.

You only end up with vulnerabilities if you refuse to update your dependencies. Updating a dependency is something you need to do yourself, along with running build validation tests after a successful update. Just because npm can download newer packages that does not mean those packages are good.

permalink
report
parent
reply
4 points

…which is the opposite of the comment above.

So, you still have to go through all the dependencies, vulnerabilities and incompatibilities. Yes, you can now kind of control the timing, but it’s still unacceptable in my opinion, that you have to spend so much time just to not be an active danger to everyone.

NPM is completely alone in that regard. Maven, Pypi, etc. don’t have these problems.

permalink
report
parent
reply
3 points

Often it seems that people will make patch releases that add a “feature” of complaining at install time that that major release/minor release/entire package is bad now and should be replaced with something else. It still works, but it annoys everyone who transitively depends on it forevermore.

permalink
report
parent
reply
4 points

I wonder if it has something to do with the framework you pick. There are probably frameworks that aim to be as stable as possible but lack the cutting edge.

permalink
report
reply
7 points

And these frameworks will fall out of fashion in three days.

permalink
report
parent
reply
19 points

At least part of it is that JavaScript is not really a batteries included language like Python or Java to even PHP.

You can’t really do anything productive without relying on a third party library.

permalink
report
reply
3 points

This is not universally true. You totally can, especially today.

permalink
report
parent
reply
0 points

All the languages you mentioned have some core APIs included and need to rely on third party libraries for more.

permalink
report
parent
reply
1 point

Yes, that’s true, but JavaScript has very few core APIs aside from basic DOM manipulation. Even things like comparing timezones requires a third party dependency, for example.

permalink
report
parent
reply
3 points

Most of those are server-side languages and I’d disagree with the assessment. For web services Java needs some kind of server like Jetty, Undertow, or Tomcat. For testing you need JUnit or NGTest. And for common, everyday utilities you need something like Apache Commons or Guava. These things don’t “ship” with Java (and there’s actually a fair amount of runtimes now, it’s not only Oracle).

The thing that seems to benefit Java over Node is major corporate support (Oracle, RedHat, IBM) so for better or worse you can usually rely on a handful of essential tools being updated regularly.

permalink
report
parent
reply
3 points

I wouldn’t say you need no dependencies in a Java project, but by all means check the average number of dependencies you get with Java or Python and compare it to almost any Node project.

You could probably sample projects on GitHub, look at the dependency graph, and compare.

permalink
report
parent
reply

Programming

!programming@programming.dev

Create post

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person’s post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you’re posting long videos try to add in some form of tldr for those who don’t want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



Community stats

  • 3.5K

    Monthly active users

  • 1.7K

    Posts

  • 28K

    Comments