fosslight-dependency 3.15.3__tar.gz → 3.15.5__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.3 → fosslight_dependency-3.15.5}/PKG-INFO +1 -1
- {fosslight_dependency-3.15.3 → fosslight_dependency-3.15.5}/requirements.txt +1 -1
- {fosslight_dependency-3.15.3 → fosslight_dependency-3.15.5}/setup.py +1 -1
- {fosslight_dependency-3.15.3 → fosslight_dependency-3.15.5}/src/fosslight_dependency/_help.py +3 -2
- {fosslight_dependency-3.15.3 → fosslight_dependency-3.15.5}/src/fosslight_dependency/package_manager/Pub.py +28 -10
- {fosslight_dependency-3.15.3 → fosslight_dependency-3.15.5}/src/fosslight_dependency/run_dependency_scanner.py +58 -35
- {fosslight_dependency-3.15.3 → fosslight_dependency-3.15.5}/src/fosslight_dependency.egg-info/PKG-INFO +1 -1
- {fosslight_dependency-3.15.3 → fosslight_dependency-3.15.5}/src/fosslight_dependency.egg-info/requires.txt +1 -1
- {fosslight_dependency-3.15.3 → fosslight_dependency-3.15.5}/LICENSE +0 -0
- {fosslight_dependency-3.15.3 → fosslight_dependency-3.15.5}/LICENSES/Apache-2.0.txt +0 -0
- {fosslight_dependency-3.15.3 → fosslight_dependency-3.15.5}/LICENSES/LicenseRef-3rd_party_licenses.txt +0 -0
- {fosslight_dependency-3.15.3 → fosslight_dependency-3.15.5}/LICENSES/MIT.txt +0 -0
- {fosslight_dependency-3.15.3 → fosslight_dependency-3.15.5}/MANIFEST.in +0 -0
- {fosslight_dependency-3.15.3 → fosslight_dependency-3.15.5}/README.md +0 -0
- {fosslight_dependency-3.15.3 → fosslight_dependency-3.15.5}/setup.cfg +0 -0
- {fosslight_dependency-3.15.3 → fosslight_dependency-3.15.5}/src/fosslight_dependency/__init__.py +0 -0
- {fosslight_dependency-3.15.3 → fosslight_dependency-3.15.5}/src/fosslight_dependency/_analyze_dependency.py +0 -0
- {fosslight_dependency-3.15.3 → fosslight_dependency-3.15.5}/src/fosslight_dependency/_package_manager.py +0 -0
- {fosslight_dependency-3.15.3 → fosslight_dependency-3.15.5}/src/fosslight_dependency/constant.py +0 -0
- {fosslight_dependency-3.15.3 → fosslight_dependency-3.15.5}/src/fosslight_dependency/package_manager/Android.py +0 -0
- {fosslight_dependency-3.15.3 → fosslight_dependency-3.15.5}/src/fosslight_dependency/package_manager/Carthage.py +0 -0
- {fosslight_dependency-3.15.3 → fosslight_dependency-3.15.5}/src/fosslight_dependency/package_manager/Cocoapods.py +0 -0
- {fosslight_dependency-3.15.3 → fosslight_dependency-3.15.5}/src/fosslight_dependency/package_manager/Go.py +0 -0
- {fosslight_dependency-3.15.3 → fosslight_dependency-3.15.5}/src/fosslight_dependency/package_manager/Gradle.py +0 -0
- {fosslight_dependency-3.15.3 → fosslight_dependency-3.15.5}/src/fosslight_dependency/package_manager/Helm.py +0 -0
- {fosslight_dependency-3.15.3 → fosslight_dependency-3.15.5}/src/fosslight_dependency/package_manager/Maven.py +0 -0
- {fosslight_dependency-3.15.3 → fosslight_dependency-3.15.5}/src/fosslight_dependency/package_manager/Npm.py +0 -0
- {fosslight_dependency-3.15.3 → fosslight_dependency-3.15.5}/src/fosslight_dependency/package_manager/Nuget.py +0 -0
- {fosslight_dependency-3.15.3 → fosslight_dependency-3.15.5}/src/fosslight_dependency/package_manager/Pypi.py +0 -0
- {fosslight_dependency-3.15.3 → fosslight_dependency-3.15.5}/src/fosslight_dependency/package_manager/Swift.py +0 -0
- {fosslight_dependency-3.15.3 → fosslight_dependency-3.15.5}/src/fosslight_dependency/package_manager/Unity.py +0 -0
- {fosslight_dependency-3.15.3 → fosslight_dependency-3.15.5}/src/fosslight_dependency/package_manager/__init__.py +0 -0
- {fosslight_dependency-3.15.3 → fosslight_dependency-3.15.5}/src/fosslight_dependency.egg-info/SOURCES.txt +0 -0
- {fosslight_dependency-3.15.3 → fosslight_dependency-3.15.5}/src/fosslight_dependency.egg-info/dependency_links.txt +0 -0
- {fosslight_dependency-3.15.3 → fosslight_dependency-3.15.5}/src/fosslight_dependency.egg-info/entry_points.txt +0 -0
- {fosslight_dependency-3.15.3 → fosslight_dependency-3.15.5}/src/fosslight_dependency.egg-info/top_level.txt +0 -0
{fosslight_dependency-3.15.3 → fosslight_dependency-3.15.5}/src/fosslight_dependency/_help.py
RENAMED
@@ -30,12 +30,13 @@ _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.
|
39
40
|
--direct\t\t\t Print the direct/transitive dependency type in comment.
|
40
41
|
\t\tChoice 'True' or 'False'. (default:True)
|
41
42
|
--notice\t\t\t Print the open source license notice text.
|
@@ -179,17 +179,35 @@ class Pub(PackageManager):
|
|
179
179
|
self.direct_dep = True
|
180
180
|
tmp_pub_deps_file = 'tmp_deps.json'
|
181
181
|
tmp_no_dev_deps_file = 'tmp_no_dev_deps.txt'
|
182
|
-
|
182
|
+
encoding_list = ['utf8', 'utf16']
|
183
183
|
if os.path.exists(tmp_pub_deps_file) and os.path.exists(tmp_no_dev_deps_file):
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
184
|
+
for encode in encoding_list:
|
185
|
+
try:
|
186
|
+
logger.info(f'Try to encode with {encode}.')
|
187
|
+
with open(tmp_pub_deps_file, 'r+', encoding=encode) as deps_f:
|
188
|
+
lines = deps_f.readlines()
|
189
|
+
deps_f.seek(0)
|
190
|
+
deps_f.truncate()
|
191
|
+
for num, line in enumerate(lines):
|
192
|
+
if line.startswith('{'):
|
193
|
+
first_line = num
|
194
|
+
break
|
195
|
+
deps_f.writelines(lines[first_line:])
|
196
|
+
deps_f.seek(0)
|
197
|
+
deps_l = json.load(deps_f)
|
198
|
+
self.parse_pub_deps_file(deps_l)
|
199
|
+
with open(tmp_no_dev_deps_file, 'r', encoding=encode) as no_dev_f:
|
200
|
+
self.parse_no_dev_command_file(no_dev_f.read())
|
201
|
+
logger.info('Parse tmp pub deps file.')
|
202
|
+
except UnicodeDecodeError as e1:
|
203
|
+
logger.info(f'Fail to encode with {encode}: {e1}')
|
204
|
+
pass
|
205
|
+
except Exception as e:
|
206
|
+
logger.error(f'Fail to parse tmp pub deps result file: {e}')
|
207
|
+
return False
|
208
|
+
else:
|
209
|
+
logger.info(f'Success to encode with {encode}.')
|
210
|
+
break
|
193
211
|
else:
|
194
212
|
try:
|
195
213
|
cmd = "flutter pub get"
|
@@ -17,7 +17,7 @@ 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
|
@@ -92,7 +92,7 @@ def find_package_manager(input_dir, abs_path_to_exclude=[]):
|
|
92
92
|
|
93
93
|
def run_dependency_scanner(package_manager='', input_dir='', output_dir_file='', pip_activate_cmd='',
|
94
94
|
pip_deactivate_cmd='', output_custom_dir='', app_name=const.default_app_name,
|
95
|
-
github_token='',
|
95
|
+
github_token='', formats=[], direct=True, path_to_exclude=[]):
|
96
96
|
global logger
|
97
97
|
|
98
98
|
ret = True
|
@@ -101,25 +101,42 @@ def run_dependency_scanner(package_manager='', input_dir='', output_dir_file='',
|
|
101
101
|
_json_ext = ".json"
|
102
102
|
_start_time = datetime.now().strftime('%y%m%d_%H%M')
|
103
103
|
|
104
|
-
success, msg, output_path,
|
104
|
+
success, msg, output_path, output_files, output_extensions = check_output_formats(output_dir_file, formats, CUSTOMIZED_FORMAT)
|
105
105
|
if success:
|
106
106
|
if output_path == "":
|
107
107
|
output_path = os.getcwd()
|
108
108
|
else:
|
109
109
|
output_path = os.path.abspath(output_path)
|
110
110
|
|
111
|
-
if
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
111
|
+
if not output_files:
|
112
|
+
while len(output_files) < len(output_extensions):
|
113
|
+
output_files.append(None)
|
114
|
+
to_remove = [] # elements of spdx format on windows that should be removed
|
115
|
+
for i, output_extension in enumerate(output_extensions):
|
116
|
+
if formats:
|
117
|
+
if formats[i].startswith('spdx'):
|
118
|
+
if platform.system() != 'Windows':
|
119
|
+
output_files[i] = f"fosslight_spdx_dep_{_start_time}"
|
120
|
+
else:
|
121
|
+
logger.warning('spdx format is not supported on Windows. Please remove spdx from format.')
|
122
|
+
to_remove.append(i)
|
123
|
+
else:
|
124
|
+
if output_extension == _json_ext:
|
125
|
+
output_files[i] = f"fosslight_opossum_dep_{_start_time}"
|
126
|
+
else:
|
127
|
+
output_files[i] = f"fosslight_report_dep_{_start_time}"
|
121
128
|
else:
|
122
|
-
|
129
|
+
if output_extension == _json_ext:
|
130
|
+
output_files[i] = f"fosslight_opossum_dep_{_start_time}"
|
131
|
+
else:
|
132
|
+
output_files[i] = f"fosslight_report_dep_{_start_time}"
|
133
|
+
for index in sorted(to_remove, reverse=True):
|
134
|
+
# remove elements of spdx format on windows
|
135
|
+
del output_files[index]
|
136
|
+
del output_extensions[index]
|
137
|
+
del formats[index]
|
138
|
+
if len(output_extensions) < 1:
|
139
|
+
sys.exit(0)
|
123
140
|
else:
|
124
141
|
logger.error(msg)
|
125
142
|
sys.exit(1)
|
@@ -216,27 +233,33 @@ def run_dependency_scanner(package_manager='', input_dir='', output_dir_file='',
|
|
216
233
|
if cover_comment:
|
217
234
|
cover.comment += f', {cover_comment}'
|
218
235
|
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
236
|
+
combined_paths_and_files = [os.path.join(output_path, file) for file in output_files]
|
237
|
+
results = []
|
238
|
+
for i, output_extension in enumerate(output_extensions):
|
239
|
+
if formats:
|
240
|
+
if formats[i].startswith('spdx'):
|
241
|
+
if platform.system() != 'Windows':
|
242
|
+
results.append(write_spdx(combined_paths_and_files[i], output_extension, sheet_list, _PKG_NAME,
|
243
|
+
pkg_resources.get_distribution(_PKG_NAME).version, spdx_version=(2, 3)))
|
244
|
+
else:
|
245
|
+
logger.error('Windows not support spdx format.')
|
246
|
+
else:
|
247
|
+
results.append(write_output_file(combined_paths_and_files[i], output_extension, sheet_list, EXTENDED_HEADER,
|
248
|
+
'', cover))
|
225
249
|
else:
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
250
|
+
results.append(write_output_file(combined_paths_and_files[i], output_extension, sheet_list, EXTENDED_HEADER,
|
251
|
+
'', cover))
|
252
|
+
for success_write, err_msg, result_file in results:
|
253
|
+
if success_write:
|
254
|
+
if result_file:
|
255
|
+
logger.info(f"Output file: {result_file}")
|
256
|
+
else:
|
257
|
+
logger.warning(f"{err_msg}")
|
258
|
+
for i in cover_comment_arr:
|
259
|
+
logger.info(i.strip())
|
233
260
|
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})")
|
261
|
+
ret = False
|
262
|
+
logger.error(f"Fail to generate result file. msg:({err_msg})")
|
240
263
|
|
241
264
|
logger.warning("### FINISH ###")
|
242
265
|
return ret, sheet_list
|
@@ -267,7 +290,7 @@ def main():
|
|
267
290
|
parser.add_argument('-c', '--customized', nargs=1, type=str, required=False)
|
268
291
|
parser.add_argument('-n', '--appname', nargs=1, type=str, required=False)
|
269
292
|
parser.add_argument('-t', '--token', nargs=1, type=str, required=False)
|
270
|
-
parser.add_argument('-f', '--format', nargs=
|
293
|
+
parser.add_argument('-f', '--format', nargs="*", type=str, required=False)
|
271
294
|
parser.add_argument('--direct', choices=('true', 'false'), default='True', required=False)
|
272
295
|
parser.add_argument('--notice', action='store_true', required=False)
|
273
296
|
|
@@ -300,7 +323,7 @@ def main():
|
|
300
323
|
if args.token: # -t option
|
301
324
|
github_token = ''.join(args.token)
|
302
325
|
if args.format: # -f option
|
303
|
-
format =
|
326
|
+
format = list(args.format)
|
304
327
|
if args.direct: # --direct option
|
305
328
|
if args.direct == 'true':
|
306
329
|
direct = True
|
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.3 → fosslight_dependency-3.15.5}/src/fosslight_dependency/__init__.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{fosslight_dependency-3.15.3 → fosslight_dependency-3.15.5}/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
|
File without changes
|