owasp-depscan 5.1.4__py3-none-any.whl → 5.1.5__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.
- depscan/cli.py +12 -94
- depscan/lib/analysis.py +325 -169
- depscan/lib/config.py +113 -5
- depscan/lib/csaf.py +1327 -1451
- depscan/lib/logger.py +0 -1
- depscan/lib/orasclient.py +127 -0
- {owasp_depscan-5.1.4.dist-info → owasp_depscan-5.1.5.dist-info}/METADATA +41 -33
- {owasp_depscan-5.1.4.dist-info → owasp_depscan-5.1.5.dist-info}/RECORD +12 -11
- {owasp_depscan-5.1.4.dist-info → owasp_depscan-5.1.5.dist-info}/LICENSE +0 -0
- {owasp_depscan-5.1.4.dist-info → owasp_depscan-5.1.5.dist-info}/WHEEL +0 -0
- {owasp_depscan-5.1.4.dist-info → owasp_depscan-5.1.5.dist-info}/entry_points.txt +0 -0
- {owasp_depscan-5.1.4.dist-info → owasp_depscan-5.1.5.dist-info}/top_level.txt +0 -0
depscan/cli.py
CHANGED
|
@@ -2,22 +2,17 @@
|
|
|
2
2
|
# -*- coding: utf-8 -*-
|
|
3
3
|
|
|
4
4
|
import argparse
|
|
5
|
-
from defusedxml.ElementTree import parse
|
|
6
5
|
import json
|
|
7
6
|
import os
|
|
8
|
-
import shutil
|
|
9
|
-
import subprocess
|
|
10
7
|
import sys
|
|
11
|
-
import tarfile
|
|
12
8
|
import tempfile
|
|
13
9
|
|
|
14
|
-
import
|
|
10
|
+
from defusedxml.ElementTree import parse
|
|
15
11
|
from quart import Quart, request
|
|
16
12
|
from rich.panel import Panel
|
|
17
13
|
from rich.terminal_theme import DEFAULT_TERMINAL_THEME, MONOKAI
|
|
18
14
|
from vdb.lib import config
|
|
19
15
|
from vdb.lib import db as db_lib
|
|
20
|
-
from vdb.lib.config import data_dir
|
|
21
16
|
from vdb.lib.gha import GitHubSource
|
|
22
17
|
from vdb.lib.nvd import NvdSource
|
|
23
18
|
from vdb.lib.osv import OSVSource
|
|
@@ -45,12 +40,11 @@ from depscan.lib.config import (
|
|
|
45
40
|
UNIVERSAL_SCAN_TYPE,
|
|
46
41
|
license_data_dir,
|
|
47
42
|
spdx_license_list,
|
|
48
|
-
vdb_database_url,
|
|
49
|
-
vdb_rafs_database_url,
|
|
50
43
|
)
|
|
51
44
|
from depscan.lib.csaf import export_csaf, write_toml
|
|
52
45
|
from depscan.lib.license import build_license_data, bulk_lookup
|
|
53
46
|
from depscan.lib.logger import DEBUG, LOG, console
|
|
47
|
+
from depscan.lib.orasclient import download_image
|
|
54
48
|
|
|
55
49
|
try:
|
|
56
50
|
os.environ["PYTHONIOENCODING"] = "utf-8"
|
|
@@ -497,69 +491,6 @@ def summarise(
|
|
|
497
491
|
return summary, vdr_file, pkg_vulnerabilities, pkg_group_rows
|
|
498
492
|
|
|
499
493
|
|
|
500
|
-
def download_rafs_based_image():
|
|
501
|
-
rafs_image_downloaded, paths_list = False, None
|
|
502
|
-
nydus_image_command = shutil.which("nydus-image", mode=os.X_OK)
|
|
503
|
-
if nydus_image_command is not None:
|
|
504
|
-
LOG.info(
|
|
505
|
-
"About to download the vulnerability database from %s. This might take a while ...",
|
|
506
|
-
vdb_rafs_database_url,
|
|
507
|
-
)
|
|
508
|
-
|
|
509
|
-
try:
|
|
510
|
-
oras_client = oras.client.OrasClient()
|
|
511
|
-
rafs_data_dir = tempfile.TemporaryDirectory()
|
|
512
|
-
paths_list = oras_client.pull(
|
|
513
|
-
target=vdb_rafs_database_url, outdir=rafs_data_dir.name
|
|
514
|
-
)
|
|
515
|
-
|
|
516
|
-
if (
|
|
517
|
-
paths_list
|
|
518
|
-
and os.path.exists(
|
|
519
|
-
os.path.join(rafs_data_dir.name, "data.rafs")
|
|
520
|
-
)
|
|
521
|
-
and os.path.exists(
|
|
522
|
-
os.path.join(rafs_data_dir.name, "meta.rafs")
|
|
523
|
-
)
|
|
524
|
-
):
|
|
525
|
-
nydus_download_command = [
|
|
526
|
-
f"{nydus_image_command}",
|
|
527
|
-
"unpack",
|
|
528
|
-
"--blob",
|
|
529
|
-
os.path.join(rafs_data_dir.name, "data.rafs"),
|
|
530
|
-
"--output",
|
|
531
|
-
os.path.join(data_dir, "vdb.tar"),
|
|
532
|
-
"--bootstrap",
|
|
533
|
-
os.path.join(rafs_data_dir.name, "meta.rafs"),
|
|
534
|
-
]
|
|
535
|
-
_ = subprocess.run(
|
|
536
|
-
nydus_download_command,
|
|
537
|
-
check=True,
|
|
538
|
-
stdout=subprocess.DEVNULL,
|
|
539
|
-
stderr=subprocess.DEVNULL,
|
|
540
|
-
)
|
|
541
|
-
if os.path.exists(os.path.join(data_dir, "vdb.tar")):
|
|
542
|
-
rafs_image_downloaded = True
|
|
543
|
-
with tarfile.open(
|
|
544
|
-
os.path.join(data_dir, "vdb.tar"), "r"
|
|
545
|
-
) as tar:
|
|
546
|
-
tar.extractall(path=data_dir)
|
|
547
|
-
os.remove(os.path.join(data_dir, "vdb.tar"))
|
|
548
|
-
else:
|
|
549
|
-
raise FileNotFoundError("vdb.tar not found")
|
|
550
|
-
else:
|
|
551
|
-
raise FileNotFoundError("data.rafs or meta.rafs not found")
|
|
552
|
-
|
|
553
|
-
except Exception:
|
|
554
|
-
LOG.info(
|
|
555
|
-
"Unable to pull the vulnerability database (rafs image) from %s. Trying to pull the non-rafs-based VDB image.",
|
|
556
|
-
vdb_rafs_database_url,
|
|
557
|
-
)
|
|
558
|
-
rafs_image_downloaded = False
|
|
559
|
-
|
|
560
|
-
return rafs_image_downloaded, data_dir
|
|
561
|
-
|
|
562
|
-
|
|
563
494
|
@app.get("/")
|
|
564
495
|
async def index():
|
|
565
496
|
"""
|
|
@@ -577,18 +508,17 @@ async def cache():
|
|
|
577
508
|
"""
|
|
578
509
|
db = db_lib.get()
|
|
579
510
|
if not db_lib.index_count(db["index_file"]):
|
|
580
|
-
|
|
581
|
-
if
|
|
582
|
-
LOG.info(
|
|
583
|
-
"About to download the vulnerability database from %s. This might take a while ...",
|
|
584
|
-
vdb_database_url,
|
|
585
|
-
)
|
|
586
|
-
oras_client = oras.client.OrasClient()
|
|
587
|
-
oras_client.pull(target=vdb_database_url, outdir=data_dir)
|
|
511
|
+
paths_list = download_image()
|
|
512
|
+
if paths_list:
|
|
588
513
|
return {
|
|
589
514
|
"error": "false",
|
|
590
515
|
"message": "vulnerability database cached successfully",
|
|
591
516
|
}
|
|
517
|
+
else:
|
|
518
|
+
return {
|
|
519
|
+
"error": "true",
|
|
520
|
+
"message": "vulnerability database was not cached",
|
|
521
|
+
}
|
|
592
522
|
return {
|
|
593
523
|
"error": "false",
|
|
594
524
|
"message": "vulnerability database already exists",
|
|
@@ -1036,17 +966,7 @@ def main():
|
|
|
1036
966
|
except Exception:
|
|
1037
967
|
pass
|
|
1038
968
|
if run_cacher:
|
|
1039
|
-
|
|
1040
|
-
if not rafs_image_downloaded:
|
|
1041
|
-
LOG.info(
|
|
1042
|
-
"About to download the vulnerability database from %s. This might take a while ...",
|
|
1043
|
-
vdb_database_url,
|
|
1044
|
-
)
|
|
1045
|
-
oras_client = oras.client.OrasClient()
|
|
1046
|
-
paths_list = oras_client.pull(
|
|
1047
|
-
target=vdb_database_url, outdir=data_dir
|
|
1048
|
-
)
|
|
1049
|
-
|
|
969
|
+
paths_list = download_image()
|
|
1050
970
|
LOG.debug("VDB data is stored at: %s", paths_list)
|
|
1051
971
|
run_cacher = False
|
|
1052
972
|
db = db_lib.get()
|
|
@@ -1101,12 +1021,10 @@ def main():
|
|
|
1101
1021
|
# CSAF VEX export
|
|
1102
1022
|
if args.csaf:
|
|
1103
1023
|
export_csaf(
|
|
1104
|
-
|
|
1024
|
+
pkg_vulnerabilities,
|
|
1105
1025
|
src_dir,
|
|
1106
1026
|
reports_dir,
|
|
1107
|
-
|
|
1108
|
-
direct_purls=direct_purls,
|
|
1109
|
-
reached_purls=reached_purls,
|
|
1027
|
+
bom_file,
|
|
1110
1028
|
)
|
|
1111
1029
|
console.save_html(
|
|
1112
1030
|
html_file,
|