owasp-depscan 5.4.8__py3-none-any.whl → 6.0.0a2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of owasp-depscan might be problematic. Click here for more details.

Files changed (34) hide show
  1. depscan/__init__.py +8 -0
  2. depscan/cli.py +719 -827
  3. depscan/cli_options.py +302 -0
  4. depscan/lib/audit.py +3 -1
  5. depscan/lib/bom.py +390 -288
  6. depscan/lib/config.py +86 -337
  7. depscan/lib/explainer.py +363 -98
  8. depscan/lib/license.py +11 -10
  9. depscan/lib/logger.py +65 -17
  10. depscan/lib/package_query/__init__.py +0 -0
  11. depscan/lib/package_query/cargo_pkg.py +124 -0
  12. depscan/lib/package_query/metadata.py +170 -0
  13. depscan/lib/package_query/npm_pkg.py +345 -0
  14. depscan/lib/package_query/pkg_query.py +195 -0
  15. depscan/lib/package_query/pypi_pkg.py +113 -0
  16. depscan/lib/tomlparse.py +116 -0
  17. depscan/lib/utils.py +34 -188
  18. owasp_depscan-6.0.0a2.dist-info/METADATA +390 -0
  19. {owasp_depscan-5.4.8.dist-info → owasp_depscan-6.0.0a2.dist-info}/RECORD +28 -25
  20. {owasp_depscan-5.4.8.dist-info → owasp_depscan-6.0.0a2.dist-info}/WHEEL +1 -1
  21. vendor/choosealicense.com/_licenses/cern-ohl-p-2.0.txt +1 -1
  22. vendor/choosealicense.com/_licenses/cern-ohl-s-2.0.txt +1 -1
  23. vendor/choosealicense.com/_licenses/cern-ohl-w-2.0.txt +2 -2
  24. vendor/choosealicense.com/_licenses/mit-0.txt +1 -1
  25. vendor/spdx/json/licenses.json +904 -677
  26. depscan/lib/analysis.py +0 -1550
  27. depscan/lib/csaf.py +0 -1860
  28. depscan/lib/normalize.py +0 -312
  29. depscan/lib/orasclient.py +0 -142
  30. depscan/lib/pkg_query.py +0 -532
  31. owasp_depscan-5.4.8.dist-info/METADATA +0 -580
  32. {owasp_depscan-5.4.8.dist-info → owasp_depscan-6.0.0a2.dist-info}/entry_points.txt +0 -0
  33. {owasp_depscan-5.4.8.dist-info → owasp_depscan-6.0.0a2.dist-info/licenses}/LICENSE +0 -0
  34. {owasp_depscan-5.4.8.dist-info → owasp_depscan-6.0.0a2.dist-info}/top_level.txt +0 -0
@@ -1,580 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: owasp-depscan
3
- Version: 5.4.8
4
- Summary: Fully open-source security audit for project dependencies based on known vulnerabilities and advisories.
5
- Author-email: Team AppThreat <cloud@appthreat.com>
6
- License: MIT
7
- Project-URL: Homepage, https://github.com/owasp-dep-scan/dep-scan
8
- Classifier: Development Status :: 5 - Production/Stable
9
- Classifier: Intended Audience :: Developers
10
- Classifier: Intended Audience :: System Administrators
11
- Classifier: License :: OSI Approved :: MIT License
12
- Classifier: Operating System :: OS Independent
13
- Classifier: Programming Language :: Python :: 3.8
14
- Classifier: Programming Language :: Python :: 3.9
15
- Classifier: Programming Language :: Python :: 3.10
16
- Classifier: Programming Language :: Python :: 3.11
17
- Classifier: Programming Language :: Python :: 3.12
18
- Classifier: Topic :: Security
19
- Classifier: Topic :: Utilities
20
- Requires-Python: >=3.8
21
- Description-Content-Type: text/markdown
22
- License-File: LICENSE
23
- Requires-Dist: appthreat-vulnerability-db==5.7.8
24
- Requires-Dist: defusedxml
25
- Requires-Dist: oras~=0.1.26
26
- Requires-Dist: PyYAML
27
- Requires-Dist: rich
28
- Requires-Dist: quart
29
- Requires-Dist: PyGithub
30
- Requires-Dist: toml
31
- Requires-Dist: pdfkit
32
- Requires-Dist: Jinja2
33
- Requires-Dist: packageurl-python
34
- Requires-Dist: cvss
35
- Provides-Extra: dev
36
- Requires-Dist: black; extra == "dev"
37
- Requires-Dist: flake8; extra == "dev"
38
- Requires-Dist: pytest; extra == "dev"
39
- Requires-Dist: pytest-cov; extra == "dev"
40
- Requires-Dist: httpretty; extra == "dev"
41
-
42
- # Introduction
43
-
44
- OWASP dep-scan is a next-generation security and risk audit tool based on known vulnerabilities, advisories, and license limitations for project dependencies. Both local repositories and container images are supported as the input, and the tool is ideal for integration with ASPM/VM platforms and in CI environments.
45
-
46
- ![Depscan logo](dep-scan.png)
47
-
48
- [![release](https://github.com/owasp-dep-scan/dep-scan/actions/workflows/pythonpublish.yml/badge.svg)](https://github.com/owasp-dep-scan/dep-scan/actions/workflows/pythonpublish.yml)
49
- [![Discord](https://img.shields.io/badge/-Discord-lime?style=for-the-badge&logo=discord&logoColor=white&color=black)](https://discord.gg/pF4BYWEJcS)
50
-
51
- ## Contents
52
-
53
- - [Features](#features)
54
- - [Vulnerability Data sources](#vulnerability-data-sources)
55
- - [Linux distros](#linux-distros)
56
- - [Usage](#usage)
57
- - [OCI Artifacts via ORAS cli](#oci-artifacts-via-oras-cli)
58
- - [Server mode](#server-mode)
59
- - [Scanning projects locally (Python version)](#scanning-projects-locally-python-version)
60
- - [Scanning containers locally (Python version)](#scanning-containers-locally-python-version)
61
- - [Scanning projects locally (Docker container)](#scanning-projects-locally-docker-container)
62
- - [Supported languages and package format](#supported-languages-and-package-format)
63
- - [Reachability analysis](#reachability-analysis)
64
- - [Example analysis for a Java project](#example-analysis-for-a-java-project)
65
- - [Example analysis for a JavaScript project](#example-analysis-for-a-javascript-project)
66
- - [Customization through environment variables](#customization-through-environment-variables)
67
- - [GitHub Security Advisory](#github-security-advisory)
68
- - [Suggest mode](#suggest-mode)
69
- - [Package Risk audit](#package-risk-audit)
70
- - [Automatic adjustment](#automatic-adjustment)
71
- - [Configuring weights](#configuring-weights)
72
- - [Live OS scan](#live-os-scan)
73
- - [License scan](#license-scan)
74
- - [Kubernetes and Cloud apps](#kubernetes-and-cloud-apps)
75
- - [PDF reports](#pdf-reports)
76
- - [Custom reports](#custom-reports)
77
- - [Performance tuning](#performance-tuning)
78
- - [Use nydus to speed up the initial vdb download](#use-nydus-to-speed-up-the-initial-vdb-download)
79
- - [Discord support](#discord-support)
80
- - [License](#license)
81
-
82
- ## Features
83
-
84
- - Scan most application code - local repos, Linux container images, Kubernetes manifests, and OS - to identify known CVEs with prioritization
85
- - Perform advanced reachability analysis for multiple languages (See reachability analysis)
86
- - Package vulnerability scanning is performed locally and is quite fast. No server is used!
87
- - Generate Software Bill-of-Materials (SBOM) with Vulnerability Disclosure Report (VDR) information
88
- - Generate a Common Security Advisory Framework (CSAF) 2.0 VEX document (check out the [CSAF Readme](contrib/CSAF_README.md))
89
- - Perform deep packages risk audit for dependency confusion attacks and maintenance risks (See risk audit)
90
-
91
- ![Reachable Flows](docs/depscan-flows.png)
92
-
93
- ![Dependency Tree with Insights](docs/tree1.jpg)
94
-
95
- ![Dependency Tree with Insights](docs/prioritization.jpg)
96
-
97
- ### Vulnerability Data sources
98
-
99
- - OSV
100
- - NVD
101
- - GitHub
102
- - NPM
103
- - Linux [vuln-list](https://github.com/appthreat/vuln-list)
104
-
105
- ### Linux distros
106
-
107
- - AlmaLinux
108
- - Debian
109
- - Alpine
110
- - Amazon Linux
111
- - Arch Linux
112
- - RHEL/CentOS
113
- - Rocky Linux
114
- - Ubuntu
115
- - OpenSUSE/SLES
116
- - Photon
117
- - Chainguard
118
- - Wolfi OS
119
-
120
- Application vulnerabilities would be reported for all Linux distros and Windows. To download the full vulnerability database suitable for scanning OS, invoke dep-scan with `--cache` for the first time. dep-scan would also download the appropriate database based on project type automatically.
121
-
122
- ## Usage
123
-
124
- dep-scan is ideal for use during continuous integration (CI) and as a local development tool.
125
-
126
- ### OCI Artifacts via ORAS cli
127
-
128
- Use [ORAS cli](https://oras.land/docs/) to download the vulnerability database for effortless integration. Example workflow is [here](https://github.com/owasp-dep-scan/dep-scan/blob/master/.github/workflows/gobintests.yml#L44-L53).
129
-
130
- ```bash
131
- export VDB_HOME=depscan
132
- mkdir -p $VDB_HOME
133
- oras pull ghcr.io/appthreat/vdb:v5 -o $VDB_HOME
134
- # oras pull ghcr.io/appthreat/vdb-10y:v5 -o $VDB_HOME
135
- oras pull ghcr.io/owasp-dep-scan/depscan:v4 -o $VDB_HOME
136
- ```
137
-
138
- Use `vdb-10y` which is a larger database with vulnerability data spanning the last 10 years from 2014. In contrast, vdb with a starting year of 2018 is appropriate for most users.
139
-
140
- ### Server mode
141
-
142
- dep-scan and cdxgen could be run in server mode. Use the included docker-compose file to get started.
143
-
144
- ```bash
145
- git clone https://github.com/owasp-dep-scan/dep-scan
146
- docker compose up
147
- ```
148
-
149
- ```bash
150
- depscan --server --server-host 0.0.0.0 --server-port 7070
151
- ```
152
-
153
- In server mode, use `/cache` endpoint to cache the vulnerability database.
154
-
155
- ```bash
156
- # This would take over 5 minutes
157
- curl http://0.0.0.0:7070/cache
158
- ```
159
-
160
- Use the `/scan` endpoint to perform scans.
161
-
162
- > [!NOTE]
163
- > The `type` parameter is mandatory in server mode.
164
-
165
- - Scanning a local directory.
166
-
167
- ```bash
168
- curl --json '{"path": "/tmp/vulnerable-aws-koa-app", "type": "js"}' http://0.0.0.0:7070/scan
169
- ```
170
-
171
- - Scanning an SBOM file (present locally).
172
-
173
- ```bash
174
- curl --json '{"path": "/tmp/vulnerable-aws-koa-app/sbom_file.json", "type": "js"}' http://0.0.0.0:7070/scan
175
- ```
176
-
177
- - Scanning a GitHub repo.
178
- Uploading an SBOM file and generating results based on it.
179
-
180
- ```bash
181
- curl -X POST -H 'Content-Type: multipart/form-data' -F 'file=@/tmp/app/sbom_file.json' http://0.0.0.0:7070/scan?type=js
182
- ```
183
-
184
- ### Scanning projects locally (Python version)
185
-
186
- ```bash
187
- sudo npm install -g @cyclonedx/cdxgen
188
- pip install owasp-depscan
189
- ```
190
-
191
- This would install two commands called `cdxgen` and `depscan`.
192
-
193
- You can invoke the scan command directly with the various options.
194
-
195
- ```bash
196
- cd <project to scan>
197
- depscan --src $PWD --reports-dir $PWD/reports
198
- ```
199
-
200
- The full list of options is below:
201
-
202
- ```bash
203
- usage: cli.py [-h] [--no-banner] [--cache] [--csaf] [--sync] [--profile {appsec,research,operational,threat-modeling,license-compliance,generic}] [--no-suggest] [--risk-audit] [--private-ns PRIVATE_NS] [-t PROJECT_TYPE] [--bom BOM]
204
- [-i SRC_DIR_IMAGE] [-o REPORT_FILE] [--reports-dir REPORTS_DIR] [--report-template REPORT_TEMPLATE] [--report-name REPORT_NAME] [--no-error] [--no-license-scan] [--deep] [--no-universal] [--no-vuln-table]
205
- [--threatdb-server THREATDB_SERVER] [--threatdb-username THREATDB_USERNAME] [--threatdb-password THREATDB_PASSWORD] [--threatdb-token THREATDB_TOKEN] [--server] [--server-host SERVER_HOST] [--server-port SERVER_PORT]
206
- [--cdxgen-server CDXGEN_SERVER] [--debug] [--explain] [--reachables-slices-file REACHABLES_SLICES_FILE] [-v]
207
-
208
- Fully open-source security and license audit for application dependencies and container images based on known vulnerabilities and advisories.
209
-
210
- options:
211
- -h, --help show this help message and exit
212
- --no-banner Do not display banner
213
- --cache Cache vulnerability information in platform specific user_data_dir
214
- --csaf Generate a OASIS CSAF VEX document
215
- --sync Sync to receive the latest vulnerability data. Should have invoked cache first.
216
- --profile {appsec,research,operational,threat-modeling,license-compliance,generic}
217
- Profile to use while generating the BOM.
218
- --no-suggest Disable suggest mode
219
- --risk-audit Perform package risk audit (slow operation). Npm only.
220
- --private-ns PRIVATE_NS
221
- Private namespace to use while performing oss risk audit. Private packages should not be available in public registries by default. Comma separated values accepted.
222
- -t PROJECT_TYPE, --type PROJECT_TYPE
223
- Override project type if auto-detection is incorrect
224
- --bom BOM Examine using the given Software Bill-of-Materials (SBOM) file in CycloneDX format. Use cdxgen command to produce one.
225
- -i SRC_DIR_IMAGE, --src SRC_DIR_IMAGE
226
- Source directory or container image or binary file
227
- -o REPORT_FILE, --report_file REPORT_FILE
228
- DEPRECATED. Use reports directory since multiple files are created. Report filename with directory
229
- --reports-dir REPORTS_DIR
230
- Reports directory
231
- --report-template REPORT_TEMPLATE
232
- Jinja template file used for rendering a custom report
233
- --report-name REPORT_NAME
234
- Filename of the custom report written to the --reports-dir
235
- --no-error UNUSED: Continue on error to prevent build from breaking
236
- --no-license-scan UNUSED: dep-scan doesn't perform license scanning by default
237
- --deep Perform deep scan by passing this --deep argument to cdxgen. Useful while scanning docker images and OS packages.
238
- --no-universal Depscan would attempt to perform a single universal scan instead of individual scans per language type.
239
- --no-vuln-table Do not print the table with the full list of vulnerabilities. This can help reduce console output.
240
- --threatdb-server THREATDB_SERVER
241
- ThreatDB server url. Eg: https://api.sbom.cx
242
- --threatdb-username THREATDB_USERNAME
243
- ThreatDB username
244
- --threatdb-password THREATDB_PASSWORD
245
- ThreatDB password
246
- --threatdb-token THREATDB_TOKEN
247
- ThreatDB token for token based submission
248
- --server Run depscan as a server
249
- --server-host SERVER_HOST
250
- depscan server host
251
- --server-port SERVER_PORT
252
- depscan server port
253
- --cdxgen-server CDXGEN_SERVER
254
- cdxgen server url. Eg: http://cdxgen:9090
255
- --debug Run depscan in debug mode.
256
- --explain Makes depscan to explain the various analysis. Useful for creating detailed reports.
257
- --reachables-slices-file REACHABLES_SLICES_FILE
258
- Path for the reachables slices file created by atom.
259
- --purl SEARCH_PURL Scan a single package url.
260
- -v, --version Display the version
261
- ```
262
-
263
- ### Scanning containers locally (Python version)
264
-
265
- Scan `latest` tag of the container `shiftleft/scan-slim`
266
-
267
- ```bash
268
- depscan --cache --src shiftleft/scan-slim -o containertests/depscan-scan.json -t docker
269
- ```
270
-
271
- Include `license` to the type to perform the license audit.
272
-
273
- ```bash
274
- depscan --cache --src shiftleft/scan-slim -o containertests/depscan-scan.json -t docker,license
275
- ```
276
-
277
- You can also specify the image using the sha256 digest
278
-
279
- ```bash
280
- depscan --src redmine@sha256:a5c5f8a64a0d9a436a0a6941bc3fb156be0c89996add834fe33b66ebeed2439e -o containertests/depscan-redmine.json -t docker
281
- ```
282
-
283
- You can also save container images using the docker or podman save command and pass the archive to depscan for scanning.
284
-
285
- ```bash
286
- docker save -o /tmp/scanslim.tar shiftleft/scan-slim:latest
287
- # podman save --format oci-archive -o /tmp/scanslim.tar shiftleft/scan-slim:latest
288
- depscan --src /tmp/scanslim.tar -o reports/depscan-scan.json -t docker
289
- ```
290
-
291
- Refer to the docker tests under the GitHub action workflow for this repo for more examples.
292
-
293
- ### Scanning projects locally (Docker container)
294
-
295
- `ghcr.io/owasp-dep-scan/dep-scan` container image can be used to perform the scan.
296
-
297
- To scan with default settings
298
-
299
- ```bash
300
- docker run --rm -v $PWD:/app ghcr.io/owasp-dep-scan/dep-scan --src /app --reports-dir /app/reports
301
- ```
302
-
303
- To scan with custom environment variables based configuration
304
-
305
- ```bash
306
- docker run --rm \
307
- -e VDB_HOME=/db \
308
- -e GITHUB_TOKEN=<token> \
309
- -v /tmp:/db \
310
- -v $PWD:/app ghcr.io/owasp-dep-scan/dep-scan --src /app --reports-dir /app/reports
311
- ```
312
-
313
- In the above example, `/tmp` is mounted as `/db` into the container. This directory is then specified as `VDB_HOME` for caching the vulnerability information. This way the database can be cached and reused to improve performance.
314
-
315
- ## Supported languages and package format
316
-
317
- dep-scan uses [cdxgen](https://github.com/CycloneDX/cdxgen) command internally to create a Software Bill-of-Materials (SBOM) file for the project. This is then used for performing the scans.
318
-
319
- The following projects and package-dependency format is supported by cdxgen.
320
-
321
- | Language/Platform | Project Types | Package Formats | Supported Evidence | Supports Transitives |
322
- | --------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | -------------------- |
323
- | Node.js | `npm`, `pnpm`, `nodejs`, `js`, `javascript`, `typescript`, `ts`, `tsx` | `npm-shrinkwrap.json`, `package-lock.json`, `pnpm-lock.yaml`, `yarn.lock`, `rush.js`, `bower.json`, `.min.js` | Yes, except for `.min.` | ✅ |
324
- | Java | `java`, `groovy`, `kotlin`, `scala`, `jvm`, `gradle`, `mvn`, `maven`, `sbt` | `pom.xml` [1], `build.gradle`, `.kts`, `sbt`, `bazel` | Yes, unless `pom.xml` is manually parsed due to unavailability of maven or errors) | ✅ |
325
- | Android | `android`, `apk`, `aab` | `apk`, `aab` | - | - |
326
- | JAR | `jar` | `.jar` | - | - |
327
- | JAR (Gradle Cache) | `gradle-index`, `gradle-cache` | `$HOME/caches/modules-2/files-2.1/\*\*/\*.jar` | - | - |
328
- | JAR (SBT Cache) | `sbt-index`, `sbt-cache` | `$HOME/.ivy2/cache/\*\*/\*.jar ` | - | - |
329
- | JAR (Maven Cache) | `maven-index`, `maven-cache`, `maven-repo` | `$HOME/.m2/repository/\*\*/\*.jar` | - | - |
330
- | Python | `python`, `py`, `pypi` | `pyproject.toml`, `setup.py`, `requirements.txt` [2], `Pipfile.lock`, `poetry.lock`, `pdm.lock`, `bdist_wheel`, `.whl`, `.egg-info` | Yes using the automatic pip install/freeze. When disabled, only with `Pipfile.lock` and `poetry.lock` | ✅ |
331
- | Golang | `go`, `golang` | `binary`, `go.mod`, `go.sum`, `Gopkg.lock` | Yes except binary | ✅ |
332
- | Rust | `rust`, `rust-lang`, `cargo` | `binary`, `Cargo.toml`, `Cargo.lock` | Only for `Cargo.lock` | - |
333
- | Ruby | `ruby`, `gems` | `Gemfile.lock`, `gemspec` | Only for `Gemfile.lock` | - |
334
- | .NET (#C) | `csharp`, `netcore`, `dotnet`, `vb`, `dotnet-framework` | `.csproj`, `.vbproj`, `.fsproj`, `packages.config`, `project.assets.json` [3], `packages.lock.json`, `.nupkg`, `paket.lock`, `binary` | Only for `project.assets.json`, `packages.lock.json`, `paket.lock` | - |
335
- | Dart | `dart`, `flutter`, `pub` | `pubspec.lock`, `pubspec.yaml` | Only for `pubspec.lock` | - |
336
- | Haskell | `haskell`, `hackage`, `cabal` | `cabal.project.freeze` | Yes | |
337
- | Elixir | `elixir`, `hex`, `mix` | `mix.lock` | Yes | - |
338
- | C++ | `c`, `cpp`, `c++`, `conan` | `conan.lock`, `conanfile.txt`, `\*.cmake`, `CMakeLists.txt`, `meson.build`, codebase without package managers! | Yes only for `conan.lock`. Best effort basis for `cmake` without version numbers. | ✅ |
339
- | Clojure | `clojure`, `edn`, `clj`, `leiningen` | `deps.edn`, `project.clj` | Yes unless the files are parsed manually due to lack of clojure cli or leiningen command | - |
340
- | GitHub Actions | `github`, `actions` | `.github/workflows/\*.yml` | n/a | ✅ |
341
- | Operation System (OS) | `os`, `osquery`, `windows`, `linux`, `mac`, `macos`, `darwin` |
342
- | Jenkins Plugins | `jenkins` | `.hpi files` | - | ✅ |
343
- | Helm | `helm`, `charts` | `.yaml` | n/a | |
344
- | Helm (Cache) | `helm-index`, `helm-repo` | `$HOME/.cache/helm/repository/\*\*/\*.yaml` | - | - |
345
- | Container | `universal`, `containerfile`, `docker-compose`, `dockerfile`, `swarm`, `tekton`, `kustomize`, `operator`, `skaffold`, `kubernetes`, `openshift`, `yaml-manifest` | `.yaml`, `docker-compose\*.yml`, `*Dockerfile*`, `*Containerfile*`, `bitbucket-pipelines.yml` | n/a | - |
346
- | Google Cloud Build | `cloudbuild` | `cloudbuild.yaml` | n/a | - |
347
- | Swift (iOS) | `swift` | `Package.resolved`, `Package.swift` (swiftpm) | Yes | - |
348
- | Binary | `binary`, `blint` |
349
- | Open API | Open API Specification, Swagger | `openapi\*.json`, `openapi\*.yaml` | n/a | - |
350
-
351
- ## Reachability analysis
352
-
353
- Depscan can perform reachability analysis for Java, JavaScript, TypeScript and Python with built-in support for parsing [atom](https://github.com/AppThreat/atom) reachables slicing. Simply invoke depscan with the `research` profile and language type to enable this feature.
354
-
355
- To receive a verbose output including the reachable flows, pass the argument `--explain`
356
-
357
- ```shell
358
- --profile research -t language [--explain]
359
- ```
360
-
361
- ### Example analysis for a Java project
362
-
363
- ```shell
364
- depscan --profile research -t java -i <source directory> --reports-dir <reports directory> --explain
365
- ```
366
-
367
- ### Example analysis for a JavaScript project
368
-
369
- ```shell
370
- depscan --profile research -t js -i <source directory> --reports-dir <reports directory> --explain
371
- ```
372
-
373
- ### Example analysis for a PHP project
374
-
375
- Ensure PHP > 7.4 is installed. However, we support scanning PHP 5.2 - 8.3. Alternatively, use the depscan container image.
376
-
377
- ```shell
378
- depscan --profile research -t php -i <source directory> --reports-dir <reports directory> --explain
379
- ```
380
-
381
- <img src="docs/php-reach1.png" alt="PHP Reachability" width="256">
382
-
383
- <img src="docs/not-reachable.png" alt="PHP NOT Reachability" width="256">
384
-
385
- ## Customization through environment variables
386
-
387
- The following environment variables can be used to customize the behavior.
388
-
389
- - VDB_HOME - Directory to use for caching database. For docker-based execution, this directory should get mounted as a volume from the host
390
- - VDB_DATABASE_URL - Vulnerability DB URL. Defaults to: ghcr.io/appthreat/vdbgz:v5
391
- - USE_VDB_10Y - Set to true to use the larger 10-year vulnerability database. Default download url: ghcr.io/appthreat/vdb-10y:v5
392
- - VDB_APP_ONLY - Set to true to use a special app-only vulnerability database. Default download url: ghcr.io/appthreat/vdbgz-app:v5
393
-
394
- Example 1 - Run depscan with app-only vdb.
395
-
396
- ```shell
397
- docker run --rm \
398
- -e VDB_HOME=/db \
399
- -e VDB_APP_ONLY=true \
400
- -e SCAN_DEBUG_MODE=debug \
401
- -v /tmp:/db \
402
- -v $PWD:/app ghcr.io/owasp-dep-scan/dep-scan --src /app --reports-dir /app/reports
403
- ```
404
-
405
- Example 2 - Run depscan with a larger 10 year app-only vdb.
406
-
407
- ```shell
408
- docker run --rm \
409
- -e VDB_HOME=/db \
410
- -e VDB_APP_ONLY=true \
411
- -e USE_VDB_10Y=true \
412
- -e SCAN_DEBUG_MODE=debug \
413
- -v /tmp:/db \
414
- -v $PWD:/app ghcr.io/owasp-dep-scan/dep-scan --src /app --reports-dir /app/reports
415
- ```
416
-
417
- ## GitHub Security Advisory
418
-
419
- To download security advisories from GitHub, a personal access token with minimal permissions is necessary.
420
-
421
- - Fine-grained token: Grant no permissions and select the following for repository access: `Public Repositories (read-only)`
422
- - Token (classic): Grant no permissions
423
-
424
- ```bash
425
- export GITHUB_TOKEN="<PAT token>"
426
- ```
427
-
428
- ## Suggest mode
429
-
430
- Depscan comes with a suggest mode enabled by default to simplify the triaging experience. The fix version for each vulnerability is retrieved from the sources. Sometimes, there might be known vulnerabilities in the fix version reported. Eg: in the below screenshot the fix versions suggested for jackson-databind might contain known vulnerabilities.
431
-
432
- ![Normal mode](docs/depscan-normal.png)
433
-
434
- ![Suggest mode](docs/depscan-suggest.png)
435
-
436
- Notice, how the new suggested version is `2.9.10.5` which is an optimal fix version. Please note that the optimal fix version may not be the appropriate version for your application based on compatibility.
437
-
438
- Pass `--no-suggest` to disable this behavior.
439
-
440
- ## Package Risk audit
441
-
442
- `--risk-audit` argument enables package risk audit. Currently, only npm and PyPI packages are supported in this mode. Some risk factors are identified and assigned weights to compute a final risk score. Packages that then exceed a maximum risk score (`config.pkg_max_risk_score`) are presented in a table.
443
-
444
- Use `--private-ns` to specify the private package namespace that should be checked for dependency confusion type issues where a private package is available on the public npm/pypi registry.
445
-
446
- For example, to check if private packages with namespaces @appthreat and @shiftleft are not accidentally made public, use the below argument.
447
-
448
- ```
449
- --private-ns appthreat,shiftleft
450
- ```
451
-
452
- | Risk category | Default Weight | Reason |
453
- | ------------------------------ | -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
454
- | pkg_private_on_public_registry | 4 | Private package is available on a public registry |
455
- | pkg_min_versions | 2 | Packages with less than 3 versions represent an extreme where they could be either super stable or quite recent. Special heuristics are applied to ignore older stable packages |
456
- | mod_create_min_seconds | 1 | Less than 12 hours difference between modified and creation time. This indicates that the upload had a defect that had to be rectified immediately. Sometimes, such a rapid update could also be malicious |
457
- | latest_now_min_seconds | 0.5 | Less than 12 hours difference between the latest version and the current time. Depending on the package such a latest version may or may not be desirable |
458
- | latest_now_max_seconds | 0.5 | Package versions that are over 6 years old are in use. Such packages might have vulnerable dependencies that are known or yet to be found |
459
- | pkg_min_maintainers | 2 | Package has less than 2 maintainers. Many opensource projects have only 1 or 2 maintainers so special heuristics are used to ignore older stable packages |
460
- | pkg_min_users | 0.25 | Package has less than 2 npm users |
461
- | pkg_install_scripts | 2 | Package runs a custom pre or post installation scripts. This is often malicious and a downside of npm. |
462
- | pkg_node_version | 0.5 | Package supports outdated version of node such as 0.8, 0.10, 4 or 6.x. Such projects might have prototype pollution or closure related vulnerabilities |
463
- | pkg_scope | 4 or 0.5 | Packages that are used directly in the application (required scope) gets a score with a weight of 4. Optional packages get a score of 0.25 |
464
- | deprecated | 1 | Latest version is deprecated |
465
-
466
- Refer to `pkg_query.py::get_category_score` method for the risk formula.
467
-
468
- ### Automatic adjustment
469
-
470
- A parameter called `created_now_quarantine_seconds` is used to identify packages that are safely past the quarantine period (1 year). Certain risks such as `pkg_min_versions` and `pkg_min_maintainers` are suppressed for packages past the quarantine period. This adjustment helps reduce noise since it is unlikely that a malicious package can exist in a registry unnoticed for over a year.
471
-
472
- ### Configuring weights
473
-
474
- All parameters can be customized by using environment variables. For eg:
475
-
476
- export PKG_MIN_VERSIONS=4 to increase and set the minimum versions category to 4.
477
-
478
- ## Live OS scan
479
-
480
- By passing `-t os`, depscan can generate an SBOM for a live operating system or a VM with OS packages and kernel information. Optionally, pass the argument `--deep` to generate an SBOM with both OS and application packages and to check for application vulnerabilities.
481
-
482
- All OS packages.
483
-
484
- ```bash
485
- depscan -t os -i . -o reports/depscan.json
486
- ```
487
-
488
- All OS and application packages.
489
-
490
- ```bash
491
- depscan -t os --deep -i . -o reports/depscan.json
492
- ```
493
-
494
- ## License scan
495
-
496
- dep-scan can scan the dependencies for any license limitations and report them directly on the console log. To enable license scanning set the environment variable `FETCH_LICENSE` to `true`.
497
-
498
- ```
499
- export FETCH_LICENSE=true
500
- ```
501
-
502
- The license data is sourced from choosealicense.com and is quite limited. If the license of a given package cannot be reliably matched against this list it will get silently ignored to reduce any noise. This behavior could change in the future once the detection logic gets improved.
503
-
504
- ![License scan](docs/license-scan.png)
505
-
506
- ## Kubernetes and Cloud apps
507
-
508
- dep-scan could auto-detect most cloud applications and Kubernetes manifest files. Pass the argument `-t yaml-manifest` to manually specify the type.
509
-
510
- ## PDF reports
511
-
512
- Ensure [wkhtmltopdf](https://wkhtmltopdf.org/downloads.html) is installed or use the official container image to generate pdf reports. Use with `--explain` for more detailed reports.
513
-
514
- ## Custom reports
515
-
516
- dep-scan can be provided with a [Jinja](https://jinja.palletsprojects.com/en/3.1.x/) template using the `--report-template` parameter.
517
- Giving it will pass the vulnerability report into your template for rendering the report.
518
-
519
- Please find a basic example here:
520
-
521
- ```jinja
522
- {% if metadata -%}
523
- Report for {{ metadata.component.group }}:{{ metadata.component.name }}:{{ metadata.component.version }}
524
- {% endif -%}
525
-
526
- {% if vulnerabilities -%}
527
- There were {{ vulnerabilities | length }} issues identified:
528
-
529
- {% for vuln in vulnerabilities -%}
530
- * {{ vuln['bom-ref'] }} - {{ vuln.recommendation }}
531
- {% endfor -%}
532
- {% else -%}
533
- 🏆 _No vulnerabilities found_
534
- {% endif -%}
535
-
536
- Severity counts:
537
- * Low: {{ summary.LOW }}
538
- * Medium: {{ summary.MEDIUM }}
539
- * High: {{ summary.HIGH }}
540
- * Critical: {{ summary.CRITICAL }}
541
- * Unspecified: {{ summary.UNSPECIFIED }}
542
- ```
543
-
544
- The objects available are taken from the CycloneDX \*.vdr.json BOM file generated, just have a look at the file for its full structure:
545
-
546
- - `metadata`
547
- - `vulnerabilities`
548
- - `components`
549
- - `dependencies`
550
- - `services`
551
-
552
- `summary` is a dictionary type with vulnerability severity quantities as shown in the example above.
553
- `pkg_vulnerabilities` - Same as `vulnerabilities` from the VDR
554
- `pkg_group_rows` - List of vulnerability id and the dependency tree prioritized by depscan.
555
-
556
- Furthermore, insights are imaginable to be made available to the template, please reach out or contribute on demand.
557
- We appreciate it if you like to contribute your report templates as examples, please add/find them [here](contrib/report-templates).
558
-
559
- ## Performance tuning
560
-
561
- ### Use nydus to speed up the initial vdb download
562
-
563
- vdb v5 is published in RAFS (Registry Accelerated File System) format with better de-duplication and packing. depscan would automatically use this image if `nydus-static` binary is available in the PATH.
564
-
565
- ```shell
566
- curl -LO https://github.com/dragonflyoss/nydus/releases/download/v2.2.4/nydus-static-v2.2.4-linux-amd64.tgz
567
- tar -xvf nydus-static-v2.2.4-linux-amd64.tgz
568
- chmod +x nydus-static/*
569
- mv nydus-static/* /usr/local/bin/
570
- ```
571
-
572
- ## Discord support
573
-
574
- The developers could be reached via the [discord](https://discord.gg/DCNxzaeUpd) channel for enterprise support.
575
-
576
- ## License
577
-
578
- MIT License
579
-
580
- This project was donated to the OWASP Foundation in August 2023 by AppThreat Ltd.