fosslight-dependency 3.15.4__tar.gz → 3.15.6__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.
- {fosslight_dependency-3.15.4 → fosslight_dependency-3.15.6}/PKG-INFO +1 -1
- fosslight_dependency-3.15.4/src/fosslight_dependency.egg-info/requires.txt → fosslight_dependency-3.15.6/requirements.txt +3 -1
- {fosslight_dependency-3.15.4 → fosslight_dependency-3.15.6}/setup.py +1 -1
- fosslight_dependency-3.15.6/src/fosslight_dependency/_graph_convertor.py +68 -0
- {fosslight_dependency-3.15.4 → fosslight_dependency-3.15.6}/src/fosslight_dependency/_help.py +7 -2
- {fosslight_dependency-3.15.4 → fosslight_dependency-3.15.6}/src/fosslight_dependency/package_manager/Cocoapods.py +1 -1
- {fosslight_dependency-3.15.4 → fosslight_dependency-3.15.6}/src/fosslight_dependency/run_dependency_scanner.py +79 -36
- {fosslight_dependency-3.15.4 → fosslight_dependency-3.15.6}/src/fosslight_dependency.egg-info/PKG-INFO +1 -1
- {fosslight_dependency-3.15.4 → fosslight_dependency-3.15.6}/src/fosslight_dependency.egg-info/SOURCES.txt +1 -0
- fosslight_dependency-3.15.4/requirements.txt → fosslight_dependency-3.15.6/src/fosslight_dependency.egg-info/requires.txt +4 -2
- {fosslight_dependency-3.15.4 → fosslight_dependency-3.15.6}/LICENSE +0 -0
- {fosslight_dependency-3.15.4 → fosslight_dependency-3.15.6}/LICENSES/Apache-2.0.txt +0 -0
- {fosslight_dependency-3.15.4 → fosslight_dependency-3.15.6}/LICENSES/LicenseRef-3rd_party_licenses.txt +0 -0
- {fosslight_dependency-3.15.4 → fosslight_dependency-3.15.6}/LICENSES/MIT.txt +0 -0
- {fosslight_dependency-3.15.4 → fosslight_dependency-3.15.6}/MANIFEST.in +0 -0
- {fosslight_dependency-3.15.4 → fosslight_dependency-3.15.6}/README.md +0 -0
- {fosslight_dependency-3.15.4 → fosslight_dependency-3.15.6}/setup.cfg +0 -0
- {fosslight_dependency-3.15.4 → fosslight_dependency-3.15.6}/src/fosslight_dependency/__init__.py +0 -0
- {fosslight_dependency-3.15.4 → fosslight_dependency-3.15.6}/src/fosslight_dependency/_analyze_dependency.py +0 -0
- {fosslight_dependency-3.15.4 → fosslight_dependency-3.15.6}/src/fosslight_dependency/_package_manager.py +0 -0
- {fosslight_dependency-3.15.4 → fosslight_dependency-3.15.6}/src/fosslight_dependency/constant.py +0 -0
- {fosslight_dependency-3.15.4 → fosslight_dependency-3.15.6}/src/fosslight_dependency/package_manager/Android.py +0 -0
- {fosslight_dependency-3.15.4 → fosslight_dependency-3.15.6}/src/fosslight_dependency/package_manager/Carthage.py +0 -0
- {fosslight_dependency-3.15.4 → fosslight_dependency-3.15.6}/src/fosslight_dependency/package_manager/Go.py +0 -0
- {fosslight_dependency-3.15.4 → fosslight_dependency-3.15.6}/src/fosslight_dependency/package_manager/Gradle.py +0 -0
- {fosslight_dependency-3.15.4 → fosslight_dependency-3.15.6}/src/fosslight_dependency/package_manager/Helm.py +0 -0
- {fosslight_dependency-3.15.4 → fosslight_dependency-3.15.6}/src/fosslight_dependency/package_manager/Maven.py +0 -0
- {fosslight_dependency-3.15.4 → fosslight_dependency-3.15.6}/src/fosslight_dependency/package_manager/Npm.py +0 -0
- {fosslight_dependency-3.15.4 → fosslight_dependency-3.15.6}/src/fosslight_dependency/package_manager/Nuget.py +0 -0
- {fosslight_dependency-3.15.4 → fosslight_dependency-3.15.6}/src/fosslight_dependency/package_manager/Pub.py +0 -0
- {fosslight_dependency-3.15.4 → fosslight_dependency-3.15.6}/src/fosslight_dependency/package_manager/Pypi.py +0 -0
- {fosslight_dependency-3.15.4 → fosslight_dependency-3.15.6}/src/fosslight_dependency/package_manager/Swift.py +0 -0
- {fosslight_dependency-3.15.4 → fosslight_dependency-3.15.6}/src/fosslight_dependency/package_manager/Unity.py +0 -0
- {fosslight_dependency-3.15.4 → fosslight_dependency-3.15.6}/src/fosslight_dependency/package_manager/__init__.py +0 -0
- {fosslight_dependency-3.15.4 → fosslight_dependency-3.15.6}/src/fosslight_dependency.egg-info/dependency_links.txt +0 -0
- {fosslight_dependency-3.15.4 → fosslight_dependency-3.15.6}/src/fosslight_dependency.egg-info/entry_points.txt +0 -0
- {fosslight_dependency-3.15.4 → fosslight_dependency-3.15.6}/src/fosslight_dependency.egg-info/top_level.txt +0 -0
@@ -0,0 +1,68 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
# Copyright (c) 2021 LG Electronics Inc.
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
5
|
+
from typing import Optional, Tuple
|
6
|
+
import igraph as ig
|
7
|
+
import matplotlib.pyplot as plt
|
8
|
+
|
9
|
+
|
10
|
+
class GraphConvertor:
|
11
|
+
def __init__(self, package_list: Optional[list] = None):
|
12
|
+
self._verticies = {}
|
13
|
+
self._edges = []
|
14
|
+
if package_list:
|
15
|
+
self.init_list(package_list)
|
16
|
+
|
17
|
+
def init_list(self, package_list: list):
|
18
|
+
"""
|
19
|
+
Initialize package_list to self._verticies and self._edges
|
20
|
+
|
21
|
+
Args:
|
22
|
+
package_list (list): List containing package information
|
23
|
+
"""
|
24
|
+
depend_on_package_dict = {}
|
25
|
+
for idx, package_info in enumerate(package_list):
|
26
|
+
package_name = package_info[0]
|
27
|
+
depend_on_packages_str = package_info[-1]
|
28
|
+
depend_on_packages = list(map((lambda x: x.strip()), depend_on_packages_str.split(",")))
|
29
|
+
self._verticies[package_name] = idx
|
30
|
+
depend_on_package_dict[package_name] = depend_on_packages
|
31
|
+
else:
|
32
|
+
for package_name, depend_on_packages in depend_on_package_dict.items():
|
33
|
+
if not package_name:
|
34
|
+
pass
|
35
|
+
else:
|
36
|
+
package_idx = self._verticies[package_name]
|
37
|
+
for depend_on_package in depend_on_packages:
|
38
|
+
if not depend_on_package:
|
39
|
+
pass
|
40
|
+
else:
|
41
|
+
depend_on_package_idx = self._verticies[depend_on_package]
|
42
|
+
self._edges.append((package_idx, depend_on_package_idx))
|
43
|
+
|
44
|
+
def save(self, path: str, size: Tuple[(int, int)]):
|
45
|
+
g = ig.Graph((len(self._verticies)), (self._edges), directed=True)
|
46
|
+
|
47
|
+
g["title"] = "Dependency Graph"
|
48
|
+
g.vs["name"] = list(self._verticies.keys())
|
49
|
+
|
50
|
+
fig, ax = plt.subplots(figsize=(tuple(map((lambda x: x / 100), size))))
|
51
|
+
fig.tight_layout()
|
52
|
+
|
53
|
+
ig.plot(
|
54
|
+
g,
|
55
|
+
target=ax,
|
56
|
+
layout="kk",
|
57
|
+
vertex_size=15,
|
58
|
+
vertex_color=["#FFD2D2"],
|
59
|
+
vertex_label=(g.vs["name"]),
|
60
|
+
vertex_label_dist=1.5,
|
61
|
+
vertex_label_size=7.0,
|
62
|
+
edge_width=0.5,
|
63
|
+
edge_color=["#FFD2D2"],
|
64
|
+
edge_arrow_size=5,
|
65
|
+
edge_arrow_width=5,
|
66
|
+
)
|
67
|
+
|
68
|
+
fig.savefig(path)
|
{fosslight_dependency-3.15.4 → fosslight_dependency-3.15.6}/src/fosslight_dependency/_help.py
RENAMED
@@ -30,12 +30,17 @@ _HELP_MESSAGE_DEPENDENCY = """
|
|
30
30
|
-h\t\t\t\t Print help message.
|
31
31
|
-v\t\t\t\t Print the version of the script.
|
32
32
|
-m <package_manager>\t Enter the package manager.
|
33
|
-
\t(npm, maven, gradle,
|
33
|
+
\t(npm, maven, gradle, pypi, pub, cocoapods, android, swift, carthage, go, nuget, helm)
|
34
34
|
-p <input_path>\t\t Enter the path where the script will be run.
|
35
35
|
-e <exclude_path>\t\t Enter the path where the analysis will not be performed.
|
36
36
|
-o <output_path>\t\t Output path
|
37
37
|
\t\t\t\t\t(If you want to generate the specific file name, add the output path with file name.)
|
38
|
-
-f <format
|
38
|
+
-f <format> [<format> ...]\t Output formats (excel, csv, opossum, yaml, spdx-tag, spdx-yaml, spdx-json, spdx-xml)
|
39
|
+
\t\t\t\t Multiple formats can be specified separated by space.
|
40
|
+
--graph-path <save_path> \t Enter the path where the graph image will be saved
|
41
|
+
\t\t\t\t\t(ex. /your/directory/path/filename.{pdf, jpg, png}) (recommend pdf extension)
|
42
|
+
--graph-size <width> <height> Enter the size of the graph image (The size unit is pixels)
|
43
|
+
\t\t\t\t\t--graph-path option is required
|
39
44
|
--direct\t\t\t Print the direct/transitive dependency type in comment.
|
40
45
|
\t\tChoice 'True' or 'False'. (default:True)
|
41
46
|
--notice\t\t\t Print the open source license notice text.
|
@@ -128,7 +128,7 @@ class Cocoapods(PackageManager):
|
|
128
128
|
purl = get_url_to_purl(homepage, self.package_manager_name, pod_oss_name_origin, oss_version)
|
129
129
|
self.purl_dict[f'{pod_oss_name_origin}({oss_version})'] = purl
|
130
130
|
if pod_oss_name in external_source_list:
|
131
|
-
homepage =
|
131
|
+
homepage = ''
|
132
132
|
if oss_name == '':
|
133
133
|
continue
|
134
134
|
if pod_oss_version != oss_version:
|
@@ -17,10 +17,11 @@ from fosslight_util.set_log import init_log
|
|
17
17
|
import fosslight_util.constant as constant
|
18
18
|
from fosslight_dependency._help import print_help_msg
|
19
19
|
from fosslight_dependency._analyze_dependency import analyze_dependency
|
20
|
-
from fosslight_util.output_format import
|
20
|
+
from fosslight_util.output_format import check_output_formats, write_output_file
|
21
21
|
if platform.system() != 'Windows':
|
22
22
|
from fosslight_util.write_spdx import write_spdx
|
23
23
|
from fosslight_util.cover import CoverItem
|
24
|
+
from fosslight_dependency._graph_convertor import GraphConvertor
|
24
25
|
|
25
26
|
# Package Name
|
26
27
|
_PKG_NAME = "fosslight_dependency"
|
@@ -92,7 +93,8 @@ def find_package_manager(input_dir, abs_path_to_exclude=[]):
|
|
92
93
|
|
93
94
|
def run_dependency_scanner(package_manager='', input_dir='', output_dir_file='', pip_activate_cmd='',
|
94
95
|
pip_deactivate_cmd='', output_custom_dir='', app_name=const.default_app_name,
|
95
|
-
github_token='',
|
96
|
+
github_token='', formats=[], direct=True, path_to_exclude=[], graph_path='',
|
97
|
+
graph_size=(600, 600)):
|
96
98
|
global logger
|
97
99
|
|
98
100
|
ret = True
|
@@ -101,25 +103,42 @@ def run_dependency_scanner(package_manager='', input_dir='', output_dir_file='',
|
|
101
103
|
_json_ext = ".json"
|
102
104
|
_start_time = datetime.now().strftime('%y%m%d_%H%M')
|
103
105
|
|
104
|
-
success, msg, output_path,
|
106
|
+
success, msg, output_path, output_files, output_extensions = check_output_formats(output_dir_file, formats, CUSTOMIZED_FORMAT)
|
105
107
|
if success:
|
106
108
|
if output_path == "":
|
107
109
|
output_path = os.getcwd()
|
108
110
|
else:
|
109
111
|
output_path = os.path.abspath(output_path)
|
110
112
|
|
111
|
-
if
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
113
|
+
if not output_files:
|
114
|
+
while len(output_files) < len(output_extensions):
|
115
|
+
output_files.append(None)
|
116
|
+
to_remove = [] # elements of spdx format on windows that should be removed
|
117
|
+
for i, output_extension in enumerate(output_extensions):
|
118
|
+
if formats:
|
119
|
+
if formats[i].startswith('spdx'):
|
120
|
+
if platform.system() != 'Windows':
|
121
|
+
output_files[i] = f"fosslight_spdx_dep_{_start_time}"
|
122
|
+
else:
|
123
|
+
logger.warning('spdx format is not supported on Windows. Please remove spdx from format.')
|
124
|
+
to_remove.append(i)
|
125
|
+
else:
|
126
|
+
if output_extension == _json_ext:
|
127
|
+
output_files[i] = f"fosslight_opossum_dep_{_start_time}"
|
128
|
+
else:
|
129
|
+
output_files[i] = f"fosslight_report_dep_{_start_time}"
|
121
130
|
else:
|
122
|
-
|
131
|
+
if output_extension == _json_ext:
|
132
|
+
output_files[i] = f"fosslight_opossum_dep_{_start_time}"
|
133
|
+
else:
|
134
|
+
output_files[i] = f"fosslight_report_dep_{_start_time}"
|
135
|
+
for index in sorted(to_remove, reverse=True):
|
136
|
+
# remove elements of spdx format on windows
|
137
|
+
del output_files[index]
|
138
|
+
del output_extensions[index]
|
139
|
+
del formats[index]
|
140
|
+
if len(output_extensions) < 1:
|
141
|
+
sys.exit(0)
|
123
142
|
else:
|
124
143
|
logger.error(msg)
|
125
144
|
sys.exit(1)
|
@@ -216,27 +235,42 @@ def run_dependency_scanner(package_manager='', input_dir='', output_dir_file='',
|
|
216
235
|
if cover_comment:
|
217
236
|
cover.comment += f', {cover_comment}'
|
218
237
|
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
238
|
+
if ret and graph_path:
|
239
|
+
graph_path = os.path.abspath(graph_path)
|
240
|
+
try:
|
241
|
+
converter = GraphConvertor(sheet_list[_sheet_name])
|
242
|
+
converter.save(graph_path, graph_size)
|
243
|
+
logger.info(f"Output graph image file: {graph_path}")
|
244
|
+
except Exception as e:
|
245
|
+
logger.error(f'Fail to make graph image: {e}')
|
246
|
+
|
247
|
+
combined_paths_and_files = [os.path.join(output_path, file) for file in output_files]
|
248
|
+
results = []
|
249
|
+
for i, output_extension in enumerate(output_extensions):
|
250
|
+
if formats:
|
251
|
+
if formats[i].startswith('spdx'):
|
252
|
+
if platform.system() != 'Windows':
|
253
|
+
results.append(write_spdx(combined_paths_and_files[i], output_extension, sheet_list, _PKG_NAME,
|
254
|
+
pkg_resources.get_distribution(_PKG_NAME).version, spdx_version=(2, 3)))
|
255
|
+
else:
|
256
|
+
logger.error('Windows not support spdx format.')
|
257
|
+
else:
|
258
|
+
results.append(write_output_file(combined_paths_and_files[i], output_extension, sheet_list, EXTENDED_HEADER,
|
259
|
+
'', cover))
|
225
260
|
else:
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
261
|
+
results.append(write_output_file(combined_paths_and_files[i], output_extension, sheet_list, EXTENDED_HEADER,
|
262
|
+
'', cover))
|
263
|
+
for success_write, err_msg, result_file in results:
|
264
|
+
if success_write:
|
265
|
+
if result_file:
|
266
|
+
logger.info(f"Output file: {result_file}")
|
267
|
+
else:
|
268
|
+
logger.warning(f"{err_msg}")
|
269
|
+
for i in cover_comment_arr:
|
270
|
+
logger.info(i.strip())
|
233
271
|
else:
|
234
|
-
|
235
|
-
|
236
|
-
logger.info(i.strip())
|
237
|
-
else:
|
238
|
-
ret = False
|
239
|
-
logger.error(f"Fail to generate result file. msg:({err_msg})")
|
272
|
+
ret = False
|
273
|
+
logger.error(f"Fail to generate result file. msg:({err_msg})")
|
240
274
|
|
241
275
|
logger.warning("### FINISH ###")
|
242
276
|
return ret, sheet_list
|
@@ -253,6 +287,8 @@ def main():
|
|
253
287
|
app_name = const.default_app_name
|
254
288
|
github_token = ''
|
255
289
|
format = ''
|
290
|
+
graph_path = ''
|
291
|
+
graph_size = (600, 600)
|
256
292
|
direct = True
|
257
293
|
|
258
294
|
parser = argparse.ArgumentParser(add_help=False)
|
@@ -267,7 +303,9 @@ def main():
|
|
267
303
|
parser.add_argument('-c', '--customized', nargs=1, type=str, required=False)
|
268
304
|
parser.add_argument('-n', '--appname', nargs=1, type=str, required=False)
|
269
305
|
parser.add_argument('-t', '--token', nargs=1, type=str, required=False)
|
270
|
-
parser.add_argument('-f', '--format', nargs=
|
306
|
+
parser.add_argument('-f', '--format', nargs="*", type=str, required=False)
|
307
|
+
parser.add_argument('--graph-path', nargs=1, type=str, required=False)
|
308
|
+
parser.add_argument('--graph-size', nargs=2, type=int, metavar=("WIDTH", "HEIGHT"), required=False)
|
271
309
|
parser.add_argument('--direct', choices=('true', 'false'), default='True', required=False)
|
272
310
|
parser.add_argument('--notice', action='store_true', required=False)
|
273
311
|
|
@@ -300,7 +338,11 @@ def main():
|
|
300
338
|
if args.token: # -t option
|
301
339
|
github_token = ''.join(args.token)
|
302
340
|
if args.format: # -f option
|
303
|
-
format =
|
341
|
+
format = list(args.format)
|
342
|
+
if args.graph_path:
|
343
|
+
graph_path = ''.join(args.graph_path)
|
344
|
+
if args.graph_size:
|
345
|
+
graph_size = args.graph_size
|
304
346
|
if args.direct: # --direct option
|
305
347
|
if args.direct == 'true':
|
306
348
|
direct = True
|
@@ -320,7 +362,8 @@ def main():
|
|
320
362
|
sys.exit(0)
|
321
363
|
|
322
364
|
run_dependency_scanner(package_manager, input_dir, output_dir, pip_activate_cmd, pip_deactivate_cmd,
|
323
|
-
output_custom_dir, app_name, github_token, format, direct, path_to_exclude
|
365
|
+
output_custom_dir, app_name, github_token, format, direct, path_to_exclude,
|
366
|
+
graph_path, graph_size)
|
324
367
|
|
325
368
|
|
326
369
|
if __name__ == '__main__':
|
@@ -9,6 +9,7 @@ LICENSES/LicenseRef-3rd_party_licenses.txt
|
|
9
9
|
LICENSES/MIT.txt
|
10
10
|
src/fosslight_dependency/__init__.py
|
11
11
|
src/fosslight_dependency/_analyze_dependency.py
|
12
|
+
src/fosslight_dependency/_graph_convertor.py
|
12
13
|
src/fosslight_dependency/_help.py
|
13
14
|
src/fosslight_dependency/_package_manager.py
|
14
15
|
src/fosslight_dependency/constant.py
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{fosslight_dependency-3.15.4 → fosslight_dependency-3.15.6}/src/fosslight_dependency/__init__.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{fosslight_dependency-3.15.4 → fosslight_dependency-3.15.6}/src/fosslight_dependency/constant.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|