Skip to content

Commit 3436bd7

Browse files
authored
Merge pull request #43 from fosslight/develop
Fix to make executable file including 'dependency-check' package
2 parents ab85391 + 8371ebe commit 3436bd7

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/fosslight_binary/_jar_analysis.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,25 @@
66
import logging
77
import json
88
import os
9-
import subprocess
9+
import sys
1010
import fosslight_util.constant as constant
1111
from ._binary import BinaryItem, OssItem, VulnerabilityItem
12+
from dependency_check import run as dependency_check_run
1213

1314

1415
logger = logging.getLogger(constant.LOGGER_NAME)
1516

1617

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+
1728
def get_oss_ver(version):
1829
oss_version = ""
1930

@@ -98,9 +109,11 @@ def analyze_jar_file(path_to_find_bin):
98109
vulnerability_items = {}
99110

100111
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)
104117

105118
json_file = os.path.join(path_to_find_bin, 'dependency-check-report.json')
106119

0 commit comments

Comments
 (0)