WEBVTT

00:00:01.550 --> 00:00:04.520
There is one last improvement we can make to this scan.

00:00:05.640 --> 00:00:07.020
JavaScript, in particular,

00:00:07.020 --> 00:00:11.100
relies very heavily on external packages in our software build process.

00:00:11.820 --> 00:00:13.680
These are known as development dependencies,

00:00:13.680 --> 00:00:15.130
or dev dependencies,

00:00:15.360 --> 00:00:18.380
and they're used for things like transpiling and bundling the code,

00:00:18.390 --> 00:00:20.330
running development tests, and so on.

00:00:21.630 --> 00:00:23.240
But once the build has completed,

00:00:23.370 --> 00:00:26.670
those packages don't actually get included in the finished product,

00:00:27.160 --> 00:00:29.700
that's in contrast to production dependencies,

00:00:29.820 --> 00:00:32.610
which will actually be shipped in the code that gets deployed

00:00:32.610 --> 00:00:35.070
on a server or run in a user's browser.

00:00:36.190 --> 00:00:40.530
Because dev dependencies often significantly outnumber production dependencies,

00:00:40.780 --> 00:00:43.610
having them included in the scan makes it really hard to

00:00:43.610 --> 00:00:46.620
properly identify and remediate the real threats.

00:00:47.270 --> 00:00:49.680
The noise can really drown out the signal here.

00:00:50.940 --> 00:00:52.660
In the Globomantics search app,

00:00:52.670 --> 00:00:55.110
only one out of the nine reported vulnerable

00:00:55.110 --> 00:00:57.810
dependencies is actually present in production.

00:00:59.120 --> 00:01:01.900
It's understandably then very tempting to ignore

00:01:01.900 --> 00:01:03.450
development dependencies altogether,

00:01:03.460 --> 00:01:07.160
especially in JavaScript applications where they are really prevalent,

00:01:08.540 --> 00:01:10.110
but is that safe?

00:01:10.860 --> 00:01:13.720
Well let's take a look at how Globomantics build and deploy

00:01:13.720 --> 00:01:15.930
their web app to try and understand the risks.

00:01:17.530 --> 00:01:19.230
There is nothing too out of the ordinary here.

00:01:19.560 --> 00:01:21.870
Developers code the web app on their laptops,

00:01:22.280 --> 00:01:23.350
then push their code,

00:01:23.360 --> 00:01:26.130
including the list of required dependencies to a build server.

00:01:26.710 --> 00:01:30.120
The build server automatically installs all of the listed dependencies,

00:01:30.130 --> 00:01:33.590
both dev and prod dependencies, and builds the web app.

00:01:35.190 --> 00:01:38.750
The finished app, which now only contains the production dependencies,

00:01:38.760 --> 00:01:40.430
is then deployed to the web server.

00:01:40.950 --> 00:01:42.590
When users visit the search site,

00:01:42.710 --> 00:01:45.820
their browsers download a copy of the JavaScript application,

00:01:45.870 --> 00:01:47.980
including those production dependencies.

00:01:50.280 --> 00:01:53.660
If we were to take dev dependencies out of our vulnerability scan,

00:01:53.960 --> 00:01:56.520
we'd be able to focus much more effectively on the

00:01:56.520 --> 00:01:58.460
right‑hand side of this diagram,

00:01:58.740 --> 00:02:02.920
keeping our production application and our end users secure.

00:02:04.380 --> 00:02:05.780
But on the other hand,

00:02:06.060 --> 00:02:09.169
dev dependencies can still be dangerous and you can see

00:02:09.250 --> 00:02:10.750
that if we completely ignore them,

00:02:10.850 --> 00:02:14.030
then we're actually failing to secure our development and build

00:02:14.030 --> 00:02:16.190
processes in the left‑hand side of this diagram.

00:02:17.150 --> 00:02:17.850
After all,

00:02:17.860 --> 00:02:21.930
we are downloading code written by strangers off the internet and

00:02:21.930 --> 00:02:23.780
running it on our development infrastructure,

00:02:23.790 --> 00:02:26.110
often with a high‑level of trust too.

00:02:27.060 --> 00:02:29.210
Now without access to our machines,

00:02:29.220 --> 00:02:32.760
most accidental vulnerabilities would be almost impossible for an

00:02:32.760 --> 00:02:35.170
attacker to exploit in this development scenario,

00:02:35.590 --> 00:02:39.480
but intentionally malicious packages have been known to run cryptominers,

00:02:39.510 --> 00:02:43.330
steal secrets, and install ransomware on development infrastructure.

00:02:44.100 --> 00:02:46.900
We'll definitely want to know about that in our dev dependencies.

00:02:48.760 --> 00:02:52.590
We can solve this problem neatly by running two separate scans on our web app,

00:02:52.860 --> 00:02:56.270
one with all dependencies included to check for any really nasty,

00:02:56.270 --> 00:03:01.230
high severity development dependencies and a second stricter scan with

00:03:01.230 --> 00:03:04.970
dev dependencies excluded so that we can make sure that we have a really

00:03:04.970 --> 00:03:07.410
close eye on those production dependencies.

00:03:09.470 --> 00:03:11.880
Dependency‑Check gives us an option to skip dev

00:03:11.880 --> 00:03:14.080
dependencies for the Node Audit Analyzer.

00:03:14.550 --> 00:03:18.970
It's the flag ‑‑nodeAuditSkipDevDependencies.

00:03:20.530 --> 00:03:23.430
We'll go ahead and run that final command on our web app.

00:03:25.990 --> 00:03:27.050
When that's complete,

00:03:27.470 --> 00:03:30.150
you'll see that we have only one single vulnerability in our

00:03:30.150 --> 00:03:33.320
production application and that is the dompurify library.

00:03:33.820 --> 00:03:36.960
It's marked as critical, so we'll probably need to do something about that.

00:03:37.210 --> 00:03:38.590
We'll talk about that in the next clip.
