|
6 | 6 | import logging |
7 | 7 | import json |
8 | 8 | import os |
9 | | -import subprocess |
| 9 | +import sys |
10 | 10 | import fosslight_util.constant as constant |
11 | 11 | from ._binary import BinaryItem, OssItem, VulnerabilityItem |
| 12 | +from dependency_check import run as dependency_check_run |
12 | 13 |
|
13 | 14 |
|
14 | 15 | logger = logging.getLogger(constant.LOGGER_NAME) |
15 | 16 |
|
16 | 17 |
|
| 18 | +def run_analysis(params, func): |
| 19 | + try: |
| 20 | + sys.argv = params |
| 21 | + func() |
| 22 | + except SystemExit: |
| 23 | + pass |
| 24 | + except Exception as ex: |
| 25 | + logger.error(f"Run Analysis : {ex}") |
| 26 | + |
| 27 | + |
17 | 28 | def get_oss_ver(version): |
18 | 29 | oss_version = "" |
19 | 30 |
|
@@ -98,9 +109,11 @@ def analyze_jar_file(path_to_find_bin): |
98 | 109 | vulnerability_items = {} |
99 | 110 |
|
100 | 111 | try: |
101 | | - command = f"dependency-check --scan {path_to_find_bin} --out {path_to_find_bin} --disableArchive --disableAssembly --disableRetireJS --disableNodeJS \ |
102 | | - --disableNodeAudit --disableNugetconf --disableNuspec --disableOpenSSL --disableOssIndex --disableBundleAudit -f ALL" |
103 | | - subprocess.run(command, shell=True) |
| 112 | + command = ['dependency-check', '--scan', f'{path_to_find_bin}', '--out', f'{path_to_find_bin}', |
| 113 | + '--disableArchive', '--disableAssembly', '--disableRetireJS', '--disableNodeJS', |
| 114 | + '--disableNodeAudit', '--disableNugetconf', '--disableNuspec', '--disableOpenSSL', |
| 115 | + '--disableOssIndex', '--disableBundleAudit', '-f', 'ALL'] |
| 116 | + run_analysis(command, dependency_check_run) |
104 | 117 |
|
105 | 118 | json_file = os.path.join(path_to_find_bin, 'dependency-check-report.json') |
106 | 119 |
|
|
0 commit comments