owasp-depscan 4.2.5__tar.gz → 4.2.7__tar.gz

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 (82) hide show
  1. {owasp-depscan-4.2.5/owasp_depscan.egg-info → owasp-depscan-4.2.7}/PKG-INFO +16 -14
  2. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/README.md +4 -12
  3. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/depscan/cli.py +47 -35
  4. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/depscan/lib/bom.py +70 -22
  5. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/depscan/lib/config.py +2 -0
  6. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/depscan/lib/normalize.py +2 -1
  7. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/depscan/lib/utils.py +8 -0
  8. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7/owasp_depscan.egg-info}/PKG-INFO +16 -14
  9. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/owasp_depscan.egg-info/requires.txt +2 -1
  10. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/pyproject.toml +3 -2
  11. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/LICENSE +0 -0
  12. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/MANIFEST.in +0 -0
  13. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/depscan/__init__.py +0 -0
  14. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/depscan/lib/__init__.py +0 -0
  15. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/depscan/lib/analysis.py +0 -0
  16. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/depscan/lib/audit.py +0 -0
  17. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/depscan/lib/license.py +0 -0
  18. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/depscan/lib/logger.py +0 -0
  19. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/depscan/lib/pkg_query.py +0 -0
  20. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/depscan/lib/privado.py +0 -0
  21. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/owasp_depscan.egg-info/SOURCES.txt +0 -0
  22. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/owasp_depscan.egg-info/dependency_links.txt +0 -0
  23. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/owasp_depscan.egg-info/entry_points.txt +0 -0
  24. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/owasp_depscan.egg-info/top_level.txt +0 -0
  25. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/setup.cfg +0 -0
  26. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/test/test_analysis.py +0 -0
  27. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/test/test_bom.py +0 -0
  28. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/test/test_license.py +0 -0
  29. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/test/test_norm.py +0 -0
  30. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/test/test_pkg_query.py +0 -0
  31. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/test/test_privado.py +0 -0
  32. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/test/test_utils.py +0 -0
  33. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/__init__.py +0 -0
  34. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_data/fields.yml +0 -0
  35. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_data/meta.yml +0 -0
  36. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_data/rules.yml +0 -0
  37. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_licenses/0bsd.txt +0 -0
  38. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_licenses/afl-3.0.txt +0 -0
  39. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_licenses/agpl-3.0.txt +0 -0
  40. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_licenses/apache-2.0.txt +0 -0
  41. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_licenses/artistic-2.0.txt +0 -0
  42. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_licenses/bsd-2-clause.txt +0 -0
  43. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_licenses/bsd-3-clause-clear.txt +0 -0
  44. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_licenses/bsd-3-clause.txt +0 -0
  45. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_licenses/bsd-4-clause.txt +0 -0
  46. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_licenses/bsl-1.0.txt +0 -0
  47. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_licenses/cc-by-4.0.txt +0 -0
  48. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_licenses/cc-by-sa-4.0.txt +0 -0
  49. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_licenses/cc0-1.0.txt +0 -0
  50. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_licenses/cecill-2.1.txt +0 -0
  51. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_licenses/cern-ohl-p-2.0.txt +0 -0
  52. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_licenses/cern-ohl-s-2.0.txt +0 -0
  53. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_licenses/cern-ohl-w-2.0.txt +0 -0
  54. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_licenses/ecl-2.0.txt +0 -0
  55. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_licenses/epl-1.0.txt +0 -0
  56. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_licenses/epl-2.0.txt +0 -0
  57. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_licenses/eupl-1.1.txt +0 -0
  58. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_licenses/eupl-1.2.txt +0 -0
  59. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_licenses/gfdl-1.3.txt +0 -0
  60. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_licenses/gpl-2.0.txt +0 -0
  61. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_licenses/gpl-3.0.txt +0 -0
  62. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_licenses/isc.txt +0 -0
  63. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_licenses/lgpl-2.1.txt +0 -0
  64. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_licenses/lgpl-3.0.txt +0 -0
  65. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_licenses/lppl-1.3c.txt +0 -0
  66. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_licenses/mit-0.txt +0 -0
  67. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_licenses/mit.txt +0 -0
  68. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_licenses/mpl-2.0.txt +0 -0
  69. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_licenses/ms-pl.txt +0 -0
  70. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_licenses/ms-rl.txt +0 -0
  71. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_licenses/mulanpsl-2.0.txt +0 -0
  72. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_licenses/ncsa.txt +0 -0
  73. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_licenses/odbl-1.0.txt +0 -0
  74. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_licenses/ofl-1.1.txt +0 -0
  75. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_licenses/osl-3.0.txt +0 -0
  76. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_licenses/postgresql.txt +0 -0
  77. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_licenses/unlicense.txt +0 -0
  78. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_licenses/upl-1.0.txt +0 -0
  79. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_licenses/vim.txt +0 -0
  80. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_licenses/wtfpl.txt +0 -0
  81. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/choosealicense.com/_licenses/zlib.txt +0 -0
  82. {owasp-depscan-4.2.5 → owasp-depscan-4.2.7}/vendor/spdx/json/licenses.json +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: owasp-depscan
3
- Version: 4.2.5
3
+ Version: 4.2.7
4
4
  Summary: Fully open-source security audit for project dependencies based on known vulnerabilities and advisories.
5
5
  Author-email: Team AppThreat <cloud@appthreat.com>
6
6
  License: MIT
@@ -18,8 +18,18 @@ Classifier: Topic :: Security
18
18
  Classifier: Topic :: Utilities
19
19
  Requires-Python: >=3.8
20
20
  Description-Content-Type: text/markdown
21
- Provides-Extra: dev
22
21
  License-File: LICENSE
22
+ Requires-Dist: appthreat-vulnerability-db>=5.4.2
23
+ Requires-Dist: defusedxml
24
+ Requires-Dist: oras
25
+ Requires-Dist: PyYAML
26
+ Requires-Dist: rich
27
+ Requires-Dist: quart
28
+ Provides-Extra: dev
29
+ Requires-Dist: black; extra == "dev"
30
+ Requires-Dist: flake8; extra == "dev"
31
+ Requires-Dist: pytest; extra == "dev"
32
+ Requires-Dist: pytest-cov; extra == "dev"
23
33
 
24
34
  # Introduction
25
35
 
@@ -46,7 +56,7 @@ OWASP dep-scan is a fully open-source security audit tool based on known vulnera
46
56
  - NVD
47
57
  - GitHub
48
58
  - NPM
49
- - Linux [vuln-list](https://github.com/appthreat/vuln-list) (Use `--cache-os`)
59
+ - Linux [vuln-list](https://github.com/appthreat/vuln-list)
50
60
 
51
61
  ### Linux distros
52
62
 
@@ -63,7 +73,7 @@ OWASP dep-scan is a fully open-source security audit tool based on known vulnera
63
73
  - Chainguard
64
74
  - Wolfi OS
65
75
 
66
- 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-os` for the first time. dep-scan would also download the appropriate database based on project type automatically.
76
+ 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.
67
77
 
68
78
  ## Usage
69
79
 
@@ -77,7 +87,7 @@ Use [ORAS cli](https://oras.land/cli/) to download the dep-scan binary and the v
77
87
  export VDB_HOME=depscan
78
88
  mkdir -p $VDB_HOME
79
89
  oras pull ghcr.io/appthreat/vdb:v5 -o $VDB_HOME
80
- oras pull ghcr.io/appthreat/depscan:v4 -o $VDB_HOME
90
+ oras pull ghcr.io/owasp-dep-scan/depscan:v4 -o $VDB_HOME
81
91
  ```
82
92
 
83
93
  ### Single binary executables
@@ -121,13 +131,6 @@ In server mode, use `/cache` endpoint to cache the vulnerability database.
121
131
  curl http://0.0.0.0:7070/cache
122
132
  ```
123
133
 
124
- Cache all vulnerabilities including os.
125
-
126
- ```bash
127
- # This would take over 5 minutes
128
- curl http://0.0.0.0:7070/cache?os=true
129
- ```
130
-
131
134
  Use the `/scan` endpoint to perform scans.
132
135
 
133
136
  ```bash
@@ -168,12 +171,11 @@ depscan --src $PWD --reports-dir $PWD/reports
168
171
  Full list of options are below:
169
172
 
170
173
  ```bash
171
- usage: depscan [-h] [--no-banner] [--cache] [--cache-os] [--sync] [--suggest] [--risk-audit] [--private-ns PRIVATE_NS] [-t PROJECT_TYPE] [--bom BOM] -i SRC_DIR
174
+ usage: depscan [-h] [--no-banner] [--cache] [--sync] [--suggest] [--risk-audit] [--private-ns PRIVATE_NS] [-t PROJECT_TYPE] [--bom BOM] -i SRC_DIR
172
175
  [--reports-dir REPORTS_DIR] [--no-error] [--deep]
173
176
  -h, --help show this help message and exit
174
177
  --no-banner Do not display banner
175
178
  --cache Cache vulnerability information in platform specific user_data_dir
176
- --cache-os Cache OS vulnerability information in platform specific user_data_dir
177
179
  --sync Sync to receive the latest vulnerability data. Should have invoked cache first.
178
180
  --risk-audit Perform package risk audit (slow operation). Npm only.
179
181
  --private-ns PRIVATE_NS
@@ -23,7 +23,7 @@ OWASP dep-scan is a fully open-source security audit tool based on known vulnera
23
23
  - NVD
24
24
  - GitHub
25
25
  - NPM
26
- - Linux [vuln-list](https://github.com/appthreat/vuln-list) (Use `--cache-os`)
26
+ - Linux [vuln-list](https://github.com/appthreat/vuln-list)
27
27
 
28
28
  ### Linux distros
29
29
 
@@ -40,7 +40,7 @@ OWASP dep-scan is a fully open-source security audit tool based on known vulnera
40
40
  - Chainguard
41
41
  - Wolfi OS
42
42
 
43
- 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-os` for the first time. dep-scan would also download the appropriate database based on project type automatically.
43
+ 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.
44
44
 
45
45
  ## Usage
46
46
 
@@ -54,7 +54,7 @@ Use [ORAS cli](https://oras.land/cli/) to download the dep-scan binary and the v
54
54
  export VDB_HOME=depscan
55
55
  mkdir -p $VDB_HOME
56
56
  oras pull ghcr.io/appthreat/vdb:v5 -o $VDB_HOME
57
- oras pull ghcr.io/appthreat/depscan:v4 -o $VDB_HOME
57
+ oras pull ghcr.io/owasp-dep-scan/depscan:v4 -o $VDB_HOME
58
58
  ```
59
59
 
60
60
  ### Single binary executables
@@ -98,13 +98,6 @@ In server mode, use `/cache` endpoint to cache the vulnerability database.
98
98
  curl http://0.0.0.0:7070/cache
99
99
  ```
100
100
 
101
- Cache all vulnerabilities including os.
102
-
103
- ```bash
104
- # This would take over 5 minutes
105
- curl http://0.0.0.0:7070/cache?os=true
106
- ```
107
-
108
101
  Use the `/scan` endpoint to perform scans.
109
102
 
110
103
  ```bash
@@ -145,12 +138,11 @@ depscan --src $PWD --reports-dir $PWD/reports
145
138
  Full list of options are below:
146
139
 
147
140
  ```bash
148
- usage: depscan [-h] [--no-banner] [--cache] [--cache-os] [--sync] [--suggest] [--risk-audit] [--private-ns PRIVATE_NS] [-t PROJECT_TYPE] [--bom BOM] -i SRC_DIR
141
+ usage: depscan [-h] [--no-banner] [--cache] [--sync] [--suggest] [--risk-audit] [--private-ns PRIVATE_NS] [-t PROJECT_TYPE] [--bom BOM] -i SRC_DIR
149
142
  [--reports-dir REPORTS_DIR] [--no-error] [--deep]
150
143
  -h, --help show this help message and exit
151
144
  --no-banner Do not display banner
152
145
  --cache Cache vulnerability information in platform specific user_data_dir
153
- --cache-os Cache OS vulnerability information in platform specific user_data_dir
154
146
  --sync Sync to receive the latest vulnerability data. Should have invoked cache first.
155
147
  --risk-audit Perform package risk audit (slow operation). Npm only.
156
148
  --private-ns PRIVATE_NS
@@ -12,11 +12,14 @@ from rich.terminal_theme import MONOKAI
12
12
  from vdb.lib import config
13
13
  from vdb.lib import db as db_lib
14
14
  from vdb.lib.aqua import AquaSource
15
+ from vdb.lib.config import data_dir
15
16
  from vdb.lib.gha import GitHubSource
16
17
  from vdb.lib.nvd import NvdSource
17
18
  from vdb.lib.osv import OSVSource
18
19
  from vdb.lib.utils import parse_purl
19
20
 
21
+ import oras.client
22
+
20
23
  from depscan.lib import privado, utils
21
24
  from depscan.lib.analysis import (
22
25
  PrepareVexOptions,
@@ -29,9 +32,10 @@ from depscan.lib.analysis import (
29
32
  )
30
33
  from depscan.lib.audit import audit, risk_audit, risk_audit_map, type_audit_map
31
34
  from depscan.lib.bom import create_bom, get_pkg_by_type, get_pkg_list, submit_bom
32
- from depscan.lib.config import UNIVERSAL_SCAN_TYPE, license_data_dir, spdx_license_list
35
+ from depscan.lib.config import UNIVERSAL_SCAN_TYPE, license_data_dir, spdx_license_list, vdb_database_url
33
36
  from depscan.lib.license import build_license_data, bulk_lookup
34
37
  from depscan.lib.logger import LOG, console
38
+ from depscan.lib.utils import get_version
35
39
 
36
40
  try:
37
41
  os.environ["PYTHONIOENCODING"] = "utf-8"
@@ -75,13 +79,6 @@ def build_args():
75
79
  dest="cache",
76
80
  help="Cache vulnerability information in platform specific " "user_data_dir",
77
81
  )
78
- parser.add_argument(
79
- "--cache-os",
80
- action="store_true",
81
- default=False,
82
- dest="cache_os",
83
- help="Cache OS vulnerability information in platform specific " "user_data_dir",
84
- )
85
82
  parser.add_argument(
86
83
  "--sync",
87
84
  action="store_true",
@@ -239,6 +236,13 @@ def build_args():
239
236
  dest="cdxgen_server",
240
237
  help="cdxgen server url. Eg: http://cdxgen:9090",
241
238
  )
239
+ parser.add_argument(
240
+ "-v",
241
+ "--version",
242
+ help="Display the version",
243
+ action="version",
244
+ version="%(prog)s " + get_version(),
245
+ )
242
246
  return parser.parse_args()
243
247
 
244
248
 
@@ -383,6 +387,32 @@ def summarise(
383
387
  with open(bom_file, encoding="utf-8") as fp:
384
388
  bom_data = json.load(fp)
385
389
  if bom_data:
390
+ # Add depscan information as metadata
391
+ metadata = bom_data.get("metadata", {})
392
+ tools = metadata.get("tools", {})
393
+ bom_version = str(bom_data.get("version", 1))
394
+ # Update the version
395
+ if bom_version.isdigit():
396
+ bom_version = int(bom_version) + 1
397
+ bom_data["version"] = bom_version
398
+ # Update the tools section
399
+ if isinstance(tools, dict):
400
+ components = tools.get("components", [])
401
+ ds_version = get_version()
402
+ ds_purl = f"pkg:pypi/owasp-depscan@{ds_version}"
403
+ components.append(
404
+ {
405
+ "type": "application",
406
+ "name": "owasp-depscan",
407
+ "version": ds_version,
408
+ "purl": ds_purl,
409
+ "bom-ref": ds_purl,
410
+ }
411
+ )
412
+ tools["components"] = components
413
+ metadata["tools"] = tools
414
+ bom_data["metadata"] = metadata
415
+
386
416
  bom_data["vulnerabilities"] = pkg_vulnerabilities
387
417
  # Look for any privado json file
388
418
  if os.path.exists(privado_json_file):
@@ -421,17 +451,10 @@ async def cache():
421
451
  :return: a JSON response indicating the status of the caching operation.
422
452
  """
423
453
  db = db_lib.get()
424
- q = request.args
425
454
  if not db_lib.index_count(db["index_file"]):
426
- sources_list = [OSVSource(), NvdSource()]
427
- if os.environ.get("GITHUB_TOKEN"):
428
- sources_list.insert(0, GitHubSource())
429
- # Include aqua source when ?os=true query string is passed
430
- if q.get("os", "").lower() in ("true", "1"):
431
- sources_list.insert(0, AquaSource())
432
- for s in sources_list:
433
- LOG.debug("Refreshing %s", s.__class__.__name__)
434
- s.refresh()
455
+ oras_client = oras.client.OrasClient()
456
+ paths_list = oras_client.pull(target = vdb_database_url, outdir = data_dir)
457
+ LOG.debug(f'VDB data is stored at: {paths_list}')
435
458
  return {
436
459
  "error": "false",
437
460
  "message": "vulnerability database cached successfully",
@@ -573,7 +596,7 @@ def main():
573
596
  else:
574
597
  project_types_list = utils.detect_project_type(src_dir)
575
598
  db = db_lib.get()
576
- run_cacher = args.cache or args.cache_os
599
+ run_cacher = args.cache
577
600
  areport_file = (
578
601
  args.report_file
579
602
  if args.report_file
@@ -712,26 +735,15 @@ def main():
712
735
  run_cacher = True
713
736
  else:
714
737
  LOG.debug("Vulnerability database loaded from %s", config.vdb_bin_file)
738
+
715
739
  sources_list = [OSVSource(), NvdSource()]
716
740
  if os.environ.get("GITHUB_TOKEN"):
717
741
  sources_list.insert(0, GitHubSource())
718
742
  if run_cacher:
719
- if (
720
- args.cache_os
721
- or args.deep_scan
722
- or project_type in ("docker", "podman", "yaml-manifest", "os")
723
- ):
724
- sources_list.insert(0, AquaSource())
725
- LOG.info(
726
- "OS Vulnerability database would be downloaded for the "
727
- "first time. To avoid this step, manually download the "
728
- "vulnerability database using the ORAS cli and set the "
729
- "environment variable VDB_HOME."
730
- )
731
- for s in sources_list:
732
- LOG.debug("Refreshing %s", s.__class__.__name__)
733
- s.refresh()
734
- run_cacher = False
743
+ oras_client = oras.client.OrasClient()
744
+ paths_list = oras_client.pull(target = vdb_database_url, outdir = data_dir)
745
+ LOG.debug(f'VDB data is stored at: {paths_list}')
746
+ run_cacher = False
735
747
  elif args.sync:
736
748
  for s in sources_list:
737
749
  LOG.debug("Syncing %s", s.__class__.__name__)
@@ -245,6 +245,69 @@ def resource_path(relative_path):
245
245
  return os.path.join(base_path, relative_path)
246
246
 
247
247
 
248
+ def exec_cdxgen(bin=True):
249
+ if bin:
250
+ cdxgen_cmd = os.environ.get("CDXGEN_CMD", "cdxgen")
251
+ if not shutil.which(cdxgen_cmd):
252
+ local_bin = resource_path(
253
+ os.path.join(
254
+ "local_bin",
255
+ "cdxgen.exe" if sys.platform == "win32" else "cdxgen",
256
+ )
257
+ )
258
+ if not os.path.exists(local_bin):
259
+ LOG.warning(
260
+ "%s command not found. Please install using npm install "
261
+ "@cyclonedx/cdxgen or set PATH variable",
262
+ cdxgen_cmd,
263
+ )
264
+ return False
265
+ try:
266
+ cdxgen_cmd = local_bin
267
+ # Set the plugins directory as an environment variable
268
+ os.environ["CDXGEN_PLUGINS_DIR"] = resource_path("local_bin")
269
+ return cdxgen_cmd
270
+ except Exception:
271
+ return None
272
+
273
+ else:
274
+ # cdxgen_cmd = (
275
+ # os.environ.get("CDXGEN_CMD", "cdxgen")
276
+ # if sys.platform != "win32"
277
+ # else os.environ.get("CDXGEN_CMD", "cdxgen.CMD")
278
+ # )
279
+ lbin = os.getenv("APPDATA") if sys.platform == "win32" else "local_bin"
280
+ local_bin = resource_path(
281
+ os.path.join(
282
+ f"{lbin}\\npm\\" if sys.platform == "win32" else "local_bin",
283
+ "cdxgen" if sys.platform != "win32" else "cdxgen.cmd",
284
+ )
285
+ )
286
+ if not os.path.exists(local_bin):
287
+ LOG.warning(
288
+ "%s command not found. Please install using npm install "
289
+ "@cyclonedx/cdxgen or set PATH variable",
290
+ local_bin,
291
+ )
292
+ return None
293
+ try:
294
+ cdxgen_cmd = local_bin
295
+ # Set the plugins directory as an environment variable
296
+ os.environ["CDXGEN_PLUGINS_DIR"] = (
297
+ resource_path("local_bin")
298
+ if sys.platform != "win32"
299
+ else resource_path(
300
+ os.path.join(
301
+ lbin,
302
+ "\\npm\\node_modules\\@cyclonedx\\cdxgen\\node_modules\\@cyclonedx\\cdxgen-plugins-bin\\plugins",
303
+ )
304
+ )
305
+ )
306
+ return cdxgen_cmd
307
+ except Exception:
308
+ return None
309
+
310
+
248
311
  def create_bom(project_type, bom_file, src_dir=".", deep=False, options={}):
249
312
  """
250
313
  Method to create BOM file by executing cdxgen command
@@ -303,27 +366,9 @@ def create_bom(project_type, bom_file, src_dir=".", deep=False, options={}):
303
366
  "Unable to generate SBoM with cdxgen server. Trying to "
304
367
  "generate one locally."
305
368
  )
306
- cdxgen_cmd = os.environ.get("CDXGEN_CMD", "cdxgen")
307
- if not shutil.which(cdxgen_cmd):
308
- local_bin = resource_path(
309
- os.path.join(
310
- "local_bin",
311
- "cdxgen.exe" if sys.platform == "win32" else "cdxgen",
312
- )
313
- )
314
- if not os.path.exists(local_bin):
315
- LOG.warning(
316
- "%s command not found. Please install using npm install "
317
- "@cyclonedx/cdxgen or set PATH variable",
318
- cdxgen_cmd,
319
- )
320
- return False
321
- try:
322
- cdxgen_cmd = local_bin
323
- # Set the plugins directory as an environment variable
324
- os.environ["CDXGEN_PLUGINS_DIR"] = resource_path("local_bin")
325
- except Exception:
326
- pass
369
+ cdxgen_cmd = exec_cdxgen()
370
+ if not cdxgen_cmd:
371
+ cdxgen_cmd = exec_cdxgen(False)
327
372
  if project_type in ("docker",):
328
373
  LOG.info(
329
374
  "Generating Software Bill-of-Materials for container image %s. "
@@ -335,7 +380,10 @@ def create_bom(project_type, bom_file, src_dir=".", deep=False, options={}):
335
380
  args.append("--deep")
336
381
  LOG.info("About to perform deep scan. This would take a while ...")
337
382
  args.append(src_dir)
338
- exec_tool(args)
383
+ if cdxgen_cmd:
384
+ exec_tool(args)
385
+ else:
386
+ LOG.warning("Unable to locate cdxgen command. ")
339
387
  return os.path.exists(bom_file)
340
388
 
341
389
 
@@ -296,6 +296,8 @@ npm_app_info = {"name": "appthreat-depscan", "version": "1.0.0"}
296
296
 
297
297
  pypi_server = "https://pypi.org/pypi"
298
298
 
299
+ vdb_database_url = "ghcr.io/appthreat/vdb:v5"
300
+
299
301
  # Package risk scoring using a simple weighted formula with no backing
300
302
  # research All parameters and their max value and weight can be overridden
301
303
  # using environment variables
@@ -245,7 +245,7 @@ def dedup(project_type, pkg_list):
245
245
  version = None
246
246
  if res.matched_by:
247
247
  version = res.matched_by.split("|")[-1]
248
- full_pkg = vid + ":" + package_issue.affected_location.package
248
+ full_pkg = package_issue.affected_location.package
249
249
  if package_issue.affected_location.vendor:
250
250
  full_pkg = (
251
251
  f"{package_issue.affected_location.vendor}:"
@@ -253,6 +253,7 @@ def dedup(project_type, pkg_list):
253
253
  )
254
254
  if version:
255
255
  full_pkg = full_pkg + ":" + version
256
+ full_pkg = vid + ":" + full_pkg
256
257
  # Ignore any result with the exclude fix location
257
258
  # Required for debian
258
259
  if fixed_location == placeholder_exclude_version:
@@ -1,5 +1,6 @@
1
1
  import ast
2
2
  import os
3
+ import pkg_resources
3
4
  import re
4
5
  from collections import defaultdict
5
6
 
@@ -366,3 +367,10 @@ def get_all_imports(src_dir):
366
367
  import_list.add(pkg)
367
368
  import_list.add(pkg.lower().replace("py", ""))
368
369
  return import_list
370
+
371
+
372
+ def get_version():
373
+ """
374
+ Returns the version of depscan
375
+ """
376
+ return pkg_resources.get_distribution("owasp-depscan").version
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: owasp-depscan
3
- Version: 4.2.5
3
+ Version: 4.2.7
4
4
  Summary: Fully open-source security audit for project dependencies based on known vulnerabilities and advisories.
5
5
  Author-email: Team AppThreat <cloud@appthreat.com>
6
6
  License: MIT
@@ -18,8 +18,18 @@ Classifier: Topic :: Security
18
18
  Classifier: Topic :: Utilities
19
19
  Requires-Python: >=3.8
20
20
  Description-Content-Type: text/markdown
21
- Provides-Extra: dev
22
21
  License-File: LICENSE
22
+ Requires-Dist: appthreat-vulnerability-db>=5.4.2
23
+ Requires-Dist: defusedxml
24
+ Requires-Dist: oras
25
+ Requires-Dist: PyYAML
26
+ Requires-Dist: rich
27
+ Requires-Dist: quart
28
+ Provides-Extra: dev
29
+ Requires-Dist: black; extra == "dev"
30
+ Requires-Dist: flake8; extra == "dev"
31
+ Requires-Dist: pytest; extra == "dev"
32
+ Requires-Dist: pytest-cov; extra == "dev"
23
33
 
24
34
  # Introduction
25
35
 
@@ -46,7 +56,7 @@ OWASP dep-scan is a fully open-source security audit tool based on known vulnera
46
56
  - NVD
47
57
  - GitHub
48
58
  - NPM
49
- - Linux [vuln-list](https://github.com/appthreat/vuln-list) (Use `--cache-os`)
59
+ - Linux [vuln-list](https://github.com/appthreat/vuln-list)
50
60
 
51
61
  ### Linux distros
52
62
 
@@ -63,7 +73,7 @@ OWASP dep-scan is a fully open-source security audit tool based on known vulnera
63
73
  - Chainguard
64
74
  - Wolfi OS
65
75
 
66
- 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-os` for the first time. dep-scan would also download the appropriate database based on project type automatically.
76
+ 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.
67
77
 
68
78
  ## Usage
69
79
 
@@ -77,7 +87,7 @@ Use [ORAS cli](https://oras.land/cli/) to download the dep-scan binary and the v
77
87
  export VDB_HOME=depscan
78
88
  mkdir -p $VDB_HOME
79
89
  oras pull ghcr.io/appthreat/vdb:v5 -o $VDB_HOME
80
- oras pull ghcr.io/appthreat/depscan:v4 -o $VDB_HOME
90
+ oras pull ghcr.io/owasp-dep-scan/depscan:v4 -o $VDB_HOME
81
91
  ```
82
92
 
83
93
  ### Single binary executables
@@ -121,13 +131,6 @@ In server mode, use `/cache` endpoint to cache the vulnerability database.
121
131
  curl http://0.0.0.0:7070/cache
122
132
  ```
123
133
 
124
- Cache all vulnerabilities including os.
125
-
126
- ```bash
127
- # This would take over 5 minutes
128
- curl http://0.0.0.0:7070/cache?os=true
129
- ```
130
-
131
134
  Use the `/scan` endpoint to perform scans.
132
135
 
133
136
  ```bash
@@ -168,12 +171,11 @@ depscan --src $PWD --reports-dir $PWD/reports
168
171
  Full list of options are below:
169
172
 
170
173
  ```bash
171
- usage: depscan [-h] [--no-banner] [--cache] [--cache-os] [--sync] [--suggest] [--risk-audit] [--private-ns PRIVATE_NS] [-t PROJECT_TYPE] [--bom BOM] -i SRC_DIR
174
+ usage: depscan [-h] [--no-banner] [--cache] [--sync] [--suggest] [--risk-audit] [--private-ns PRIVATE_NS] [-t PROJECT_TYPE] [--bom BOM] -i SRC_DIR
172
175
  [--reports-dir REPORTS_DIR] [--no-error] [--deep]
173
176
  -h, --help show this help message and exit
174
177
  --no-banner Do not display banner
175
178
  --cache Cache vulnerability information in platform specific user_data_dir
176
- --cache-os Cache OS vulnerability information in platform specific user_data_dir
177
179
  --sync Sync to receive the latest vulnerability data. Should have invoked cache first.
178
180
  --risk-audit Perform package risk audit (slow operation). Npm only.
179
181
  --private-ns PRIVATE_NS
@@ -1,5 +1,6 @@
1
- appthreat-vulnerability-db>=5.4.1
1
+ appthreat-vulnerability-db>=5.4.2
2
2
  defusedxml
3
+ oras
3
4
  PyYAML
4
5
  rich
5
6
  quart
@@ -1,13 +1,14 @@
1
1
  [project]
2
2
  name = "owasp-depscan"
3
- version = "4.2.5"
3
+ version = "4.2.7"
4
4
  description = "Fully open-source security audit for project dependencies based on known vulnerabilities and advisories."
5
5
  authors = [
6
6
  {name = "Team AppThreat", email = "cloud@appthreat.com"},
7
7
  ]
8
8
  dependencies = [
9
- "appthreat-vulnerability-db>=5.4.1",
9
+ "appthreat-vulnerability-db>=5.4.2",
10
10
  "defusedxml",
11
+ "oras",
11
12
  "PyYAML",
12
13
  "rich",
13
14
  "quart",
File without changes
File without changes
File without changes