fosslight-dependency 3.14.3__tar.gz → 3.15.1__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.14.3 → fosslight_dependency-3.15.1}/PKG-INFO +1 -1
- {fosslight_dependency-3.14.3 → fosslight_dependency-3.15.1}/requirements.txt +1 -1
- {fosslight_dependency-3.14.3 → fosslight_dependency-3.15.1}/setup.py +1 -1
- {fosslight_dependency-3.14.3 → fosslight_dependency-3.15.1}/src/fosslight_dependency/_help.py +1 -0
- {fosslight_dependency-3.14.3 → fosslight_dependency-3.15.1}/src/fosslight_dependency/_package_manager.py +83 -16
- {fosslight_dependency-3.14.3 → fosslight_dependency-3.15.1}/src/fosslight_dependency/package_manager/Android.py +12 -7
- {fosslight_dependency-3.14.3 → fosslight_dependency-3.15.1}/src/fosslight_dependency/run_dependency_scanner.py +22 -8
- {fosslight_dependency-3.14.3 → fosslight_dependency-3.15.1}/src/fosslight_dependency.egg-info/PKG-INFO +1 -1
- {fosslight_dependency-3.14.3 → fosslight_dependency-3.15.1}/src/fosslight_dependency.egg-info/requires.txt +1 -1
- {fosslight_dependency-3.14.3 → fosslight_dependency-3.15.1}/LICENSE +0 -0
- {fosslight_dependency-3.14.3 → fosslight_dependency-3.15.1}/LICENSES/Apache-2.0.txt +0 -0
- {fosslight_dependency-3.14.3 → fosslight_dependency-3.15.1}/LICENSES/LicenseRef-3rd_party_licenses.txt +0 -0
- {fosslight_dependency-3.14.3 → fosslight_dependency-3.15.1}/LICENSES/MIT.txt +0 -0
- {fosslight_dependency-3.14.3 → fosslight_dependency-3.15.1}/MANIFEST.in +0 -0
- {fosslight_dependency-3.14.3 → fosslight_dependency-3.15.1}/README.md +0 -0
- {fosslight_dependency-3.14.3 → fosslight_dependency-3.15.1}/setup.cfg +0 -0
- {fosslight_dependency-3.14.3 → fosslight_dependency-3.15.1}/src/fosslight_dependency/__init__.py +0 -0
- {fosslight_dependency-3.14.3 → fosslight_dependency-3.15.1}/src/fosslight_dependency/_analyze_dependency.py +0 -0
- {fosslight_dependency-3.14.3 → fosslight_dependency-3.15.1}/src/fosslight_dependency/constant.py +0 -0
- {fosslight_dependency-3.14.3 → fosslight_dependency-3.15.1}/src/fosslight_dependency/package_manager/Carthage.py +0 -0
- {fosslight_dependency-3.14.3 → fosslight_dependency-3.15.1}/src/fosslight_dependency/package_manager/Cocoapods.py +0 -0
- {fosslight_dependency-3.14.3 → fosslight_dependency-3.15.1}/src/fosslight_dependency/package_manager/Go.py +0 -0
- {fosslight_dependency-3.14.3 → fosslight_dependency-3.15.1}/src/fosslight_dependency/package_manager/Gradle.py +0 -0
- {fosslight_dependency-3.14.3 → fosslight_dependency-3.15.1}/src/fosslight_dependency/package_manager/Helm.py +0 -0
- {fosslight_dependency-3.14.3 → fosslight_dependency-3.15.1}/src/fosslight_dependency/package_manager/Maven.py +0 -0
- {fosslight_dependency-3.14.3 → fosslight_dependency-3.15.1}/src/fosslight_dependency/package_manager/Npm.py +0 -0
- {fosslight_dependency-3.14.3 → fosslight_dependency-3.15.1}/src/fosslight_dependency/package_manager/Nuget.py +0 -0
- {fosslight_dependency-3.14.3 → fosslight_dependency-3.15.1}/src/fosslight_dependency/package_manager/Pub.py +0 -0
- {fosslight_dependency-3.14.3 → fosslight_dependency-3.15.1}/src/fosslight_dependency/package_manager/Pypi.py +0 -0
- {fosslight_dependency-3.14.3 → fosslight_dependency-3.15.1}/src/fosslight_dependency/package_manager/Swift.py +0 -0
- {fosslight_dependency-3.14.3 → fosslight_dependency-3.15.1}/src/fosslight_dependency/package_manager/Unity.py +0 -0
- {fosslight_dependency-3.14.3 → fosslight_dependency-3.15.1}/src/fosslight_dependency/package_manager/__init__.py +0 -0
- {fosslight_dependency-3.14.3 → fosslight_dependency-3.15.1}/src/fosslight_dependency.egg-info/SOURCES.txt +0 -0
- {fosslight_dependency-3.14.3 → fosslight_dependency-3.15.1}/src/fosslight_dependency.egg-info/dependency_links.txt +0 -0
- {fosslight_dependency-3.14.3 → fosslight_dependency-3.15.1}/src/fosslight_dependency.egg-info/entry_points.txt +0 -0
- {fosslight_dependency-3.14.3 → fosslight_dependency-3.15.1}/src/fosslight_dependency.egg-info/top_level.txt +0 -0
{fosslight_dependency-3.14.3 → fosslight_dependency-3.15.1}/src/fosslight_dependency/_help.py
RENAMED
@@ -32,6 +32,7 @@ _HELP_MESSAGE_DEPENDENCY = """
|
|
32
32
|
-m <package_manager>\t Enter the package manager.
|
33
33
|
\t(npm, maven, gradle, pip, 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
|
+
-e <exclude_path>\t\t Enter the path where the analysis will not be performed.
|
35
36
|
-o <output_path>\t\t Output path
|
36
37
|
\t\t\t\t\t(If you want to generate the specific file name, add the output path with file name.)
|
37
38
|
-f <format>\t\t\t Output file format (excel, csv, opossum, yaml, spdx-tag, spdx-yaml, spdx-json, spdx-xml)
|
@@ -68,11 +68,12 @@ class PackageManager:
|
|
68
68
|
self.package_name = ''
|
69
69
|
|
70
70
|
def run_plugin(self):
|
71
|
+
ret = True
|
71
72
|
if self.package_manager_name == const.GRADLE or self.package_manager_name == const.ANDROID:
|
72
|
-
self.run_gradle_task()
|
73
|
+
ret = self.run_gradle_task()
|
73
74
|
else:
|
74
75
|
logger.info(f"This package manager({self.package_manager_name}) skips the step to run plugin.")
|
75
|
-
return
|
76
|
+
return ret
|
76
77
|
|
77
78
|
def append_input_package_list_file(self, input_package_file):
|
78
79
|
self.input_package_list_file.append(input_package_file)
|
@@ -87,35 +88,101 @@ class PackageManager:
|
|
87
88
|
pass
|
88
89
|
|
89
90
|
def run_gradle_task(self):
|
91
|
+
ret_task = True
|
90
92
|
if os.path.isfile(const.SUPPORT_PACKAE.get(self.package_manager_name)):
|
91
93
|
gradle_backup = f'{const.SUPPORT_PACKAE.get(self.package_manager_name)}_bk'
|
92
94
|
|
93
95
|
shutil.copy(const.SUPPORT_PACKAE.get(self.package_manager_name), gradle_backup)
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
96
|
+
ret_alldeps = self.add_allDeps_in_gradle()
|
97
|
+
|
98
|
+
ret_plugin = False
|
99
|
+
if (self.package_manager_name == const.ANDROID):
|
100
|
+
module_build_gradle = os.path.join(self.app_name, const.SUPPORT_PACKAE.get(self.package_manager_name))
|
101
|
+
module_gradle_backup = f'{module_build_gradle}_bk'
|
102
|
+
if os.path.isfile(module_build_gradle) and (not os.path.isfile(self.input_file_name)):
|
103
|
+
shutil.copy(module_build_gradle, module_gradle_backup)
|
104
|
+
ret_plugin = self.add_android_plugin_in_gradle(module_build_gradle)
|
105
|
+
|
106
|
+
if os.path.isfile('gradlew') or os.path.isfile('gradlew.bat'):
|
107
|
+
if self.platform == const.WINDOWS:
|
108
|
+
cmd_gradle = "gradlew.bat"
|
109
|
+
else:
|
110
|
+
cmd_gradle = "./gradlew"
|
111
|
+
else:
|
112
|
+
ret_task = False
|
113
|
+
logger.warning('No gradlew file exists. (skip to find dependencies relationship.')
|
114
|
+
if ret_plugin:
|
115
|
+
logger.warning('Also it cannot run android-dependency-scanning plugin.')
|
116
|
+
if ret_task:
|
117
|
+
if ret_alldeps:
|
118
|
+
cmd = f"{cmd_gradle} allDeps"
|
119
|
+
try:
|
104
120
|
ret = subprocess.check_output(cmd, shell=True, encoding='utf-8')
|
105
121
|
if ret != 0:
|
106
122
|
self.parse_dependency_tree(ret)
|
107
123
|
else:
|
108
124
|
self.set_direct_dependencies(False)
|
109
125
|
logger.warning("Failed to run allDeps task.")
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
126
|
+
except Exception as e:
|
127
|
+
self.set_direct_dependencies(False)
|
128
|
+
logger.error(f'Fail to run {cmd}: {e}')
|
129
|
+
logger.warning('It cannot print the direct/transitive dependencies relationship.')
|
130
|
+
|
131
|
+
if ret_plugin:
|
132
|
+
cmd = f"{cmd_gradle} generateLicenseTxt"
|
133
|
+
try:
|
134
|
+
ret = subprocess.check_output(cmd, shell=True, encoding='utf-8')
|
135
|
+
if ret == 0:
|
136
|
+
ret_task = False
|
137
|
+
logger.error(f'Fail to run {cmd}')
|
138
|
+
if os.path.isfile(self.input_file_name):
|
139
|
+
logger.info('Automatically run android-dependency-scanning plugin and generate output.')
|
140
|
+
self.plugin_auto_run = True
|
141
|
+
else:
|
142
|
+
logger.warning('Automatically run android-dependency-scanning plugin, but fail to generate output.')
|
143
|
+
except Exception as e:
|
144
|
+
logger.error(f'Fail to run {cmd}: {e}')
|
145
|
+
ret_task = False
|
114
146
|
|
115
147
|
if os.path.isfile(gradle_backup):
|
116
148
|
os.remove(const.SUPPORT_PACKAE.get(self.package_manager_name))
|
117
149
|
shutil.move(gradle_backup, const.SUPPORT_PACKAE.get(self.package_manager_name))
|
118
150
|
|
151
|
+
if (self.package_manager_name == const.ANDROID):
|
152
|
+
if os.path.isfile(module_gradle_backup):
|
153
|
+
os.remove(module_build_gradle)
|
154
|
+
shutil.move(module_gradle_backup, module_build_gradle)
|
155
|
+
return ret_task
|
156
|
+
|
157
|
+
def add_android_plugin_in_gradle(self, module_build_gradle):
|
158
|
+
ret = False
|
159
|
+
build_script = '''buildscript {
|
160
|
+
repositories {
|
161
|
+
mavenCentral()
|
162
|
+
}
|
163
|
+
dependencies {
|
164
|
+
//Android dependency scanning Plugin
|
165
|
+
classpath 'org.fosslight:android-dependency-scanning:+'
|
166
|
+
}
|
167
|
+
}'''
|
168
|
+
apply = "apply plugin: 'org.fosslight'\n"
|
169
|
+
try:
|
170
|
+
with open(const.SUPPORT_PACKAE.get(self.package_manager_name), 'r', encoding='utf-8') as original:
|
171
|
+
data = original.read()
|
172
|
+
with open(const.SUPPORT_PACKAE.get(self.package_manager_name), 'w', encoding='utf-8') as modified:
|
173
|
+
modified.write(f"{build_script}\n{data}")
|
174
|
+
ret = True
|
175
|
+
except Exception as e:
|
176
|
+
logging.warning(f"Cannot add the buildscript task in build.gradle: {e}")
|
177
|
+
|
178
|
+
try:
|
179
|
+
with open(module_build_gradle, 'a', encoding='utf-8') as modified:
|
180
|
+
modified.write(f'\n{apply}\n')
|
181
|
+
ret = True
|
182
|
+
except Exception as e:
|
183
|
+
logging.warning(f"Cannot add the apply plugin in {module_build_gradle}: {e}")
|
184
|
+
return ret
|
185
|
+
|
119
186
|
def add_allDeps_in_gradle(self):
|
120
187
|
ret = False
|
121
188
|
config = android_config if self.package_manager_name == 'android' else gradle_config
|
@@ -11,27 +11,32 @@ from fosslight_dependency._package_manager import PackageManager, get_url_to_pur
|
|
11
11
|
|
12
12
|
logger = logging.getLogger(constant.LOGGER_NAME)
|
13
13
|
|
14
|
-
_plugin_output_file = 'android_dependency_output.txt'
|
15
|
-
|
16
14
|
|
17
15
|
class Android(PackageManager):
|
18
16
|
package_manager_name = const.ANDROID
|
19
17
|
|
18
|
+
plugin_output_file = 'android_dependency_output.txt'
|
20
19
|
app_name = const.default_app_name
|
21
20
|
input_file_name = ''
|
21
|
+
plugin_auto_run = False
|
22
22
|
|
23
23
|
def __init__(self, input_dir, output_dir, app_name):
|
24
24
|
super().__init__(self.package_manager_name, '', input_dir, output_dir)
|
25
25
|
if app_name:
|
26
26
|
self.app_name = app_name
|
27
|
-
self.input_file_name = self.check_input_path(
|
27
|
+
self.input_file_name = self.check_input_path()
|
28
28
|
self.append_input_package_list_file(self.input_file_name)
|
29
29
|
|
30
|
-
def
|
31
|
-
if
|
32
|
-
|
30
|
+
def __del__(self):
|
31
|
+
if self.plugin_auto_run:
|
32
|
+
if os.path.isfile(self.input_file_name):
|
33
|
+
os.remove(self.input_file_name)
|
34
|
+
|
35
|
+
def check_input_path(self):
|
36
|
+
if os.path.isfile(self.plugin_output_file):
|
37
|
+
return self.plugin_output_file
|
33
38
|
else:
|
34
|
-
return os.path.join(app_name,
|
39
|
+
return os.path.join(self.app_name, self.plugin_output_file)
|
35
40
|
|
36
41
|
def parse_oss_information(self, f_name):
|
37
42
|
with open(f_name, 'r', encoding='utf8') as input_fp:
|
@@ -27,7 +27,7 @@ _PKG_NAME = "fosslight_dependency"
|
|
27
27
|
logger = logging.getLogger(constant.LOGGER_NAME)
|
28
28
|
warnings.filterwarnings("ignore", category=FutureWarning)
|
29
29
|
_sheet_name = "DEP_FL_Dependency"
|
30
|
-
EXTENDED_HEADER = {_sheet_name: ['ID', '
|
30
|
+
EXTENDED_HEADER = {_sheet_name: ['ID', 'Package URL', 'OSS Name',
|
31
31
|
'OSS Version', 'License', 'Download Location',
|
32
32
|
'Homepage', 'Copyright Text', 'Exclude',
|
33
33
|
'Comment', 'Depends On']}
|
@@ -37,7 +37,7 @@ CUSTOMIZED_FORMAT = {'excel': '.xlsx', 'csv': '.csv', 'opossum': '.json', 'yaml'
|
|
37
37
|
_exclude_dir = ['node_moduels', 'venv']
|
38
38
|
|
39
39
|
|
40
|
-
def find_package_manager(input_dir):
|
40
|
+
def find_package_manager(input_dir, abs_path_to_exclude=[]):
|
41
41
|
ret = True
|
42
42
|
manifest_file_name = []
|
43
43
|
for value in const.SUPPORT_PACKAE.values():
|
@@ -52,7 +52,14 @@ def find_package_manager(input_dir):
|
|
52
52
|
continue
|
53
53
|
if os.path.basename(parent) in _exclude_dir:
|
54
54
|
continue
|
55
|
+
if os.path.abspath(parent) in abs_path_to_exclude:
|
56
|
+
continue
|
55
57
|
for file in files:
|
58
|
+
file_path = os.path.join(parent, file)
|
59
|
+
file_abs_path = os.path.abspath(file_path)
|
60
|
+
if any(os.path.commonpath([file_abs_path, exclude_path]) == exclude_path
|
61
|
+
for exclude_path in abs_path_to_exclude):
|
62
|
+
continue
|
56
63
|
if file in manifest_file_name:
|
57
64
|
found_manifest_file.append(file)
|
58
65
|
if len(found_manifest_file) > 0:
|
@@ -83,8 +90,9 @@ def find_package_manager(input_dir):
|
|
83
90
|
return ret, found_package_manager, input_dir
|
84
91
|
|
85
92
|
|
86
|
-
def run_dependency_scanner(package_manager='', input_dir='', output_dir_file='', pip_activate_cmd='',
|
87
|
-
output_custom_dir='', app_name=const.default_app_name,
|
93
|
+
def run_dependency_scanner(package_manager='', input_dir='', output_dir_file='', pip_activate_cmd='',
|
94
|
+
pip_deactivate_cmd='', output_custom_dir='', app_name=const.default_app_name,
|
95
|
+
github_token='', format='', direct=True, path_to_exclude=[]):
|
88
96
|
global logger
|
89
97
|
|
90
98
|
ret = True
|
@@ -117,7 +125,8 @@ def run_dependency_scanner(package_manager='', input_dir='', output_dir_file='',
|
|
117
125
|
sys.exit(1)
|
118
126
|
|
119
127
|
logger, _result_log = init_log(os.path.join(output_path, "fosslight_log_dep_" + _start_time + ".txt"),
|
120
|
-
True, logging.INFO, logging.DEBUG, _PKG_NAME)
|
128
|
+
True, logging.INFO, logging.DEBUG, _PKG_NAME, "", path_to_exclude)
|
129
|
+
abs_path_to_exclude = [os.path.abspath(os.path.join(input_dir, path)) for path in path_to_exclude]
|
121
130
|
|
122
131
|
logger.info(f"Tool Info : {_result_log['Tool Info']}")
|
123
132
|
|
@@ -151,7 +160,7 @@ def run_dependency_scanner(package_manager='', input_dir='', output_dir_file='',
|
|
151
160
|
found_package_manager = {}
|
152
161
|
if autodetect:
|
153
162
|
try:
|
154
|
-
ret, found_package_manager, input_dir = find_package_manager(input_dir)
|
163
|
+
ret, found_package_manager, input_dir = find_package_manager(input_dir, abs_path_to_exclude)
|
155
164
|
os.chdir(input_dir)
|
156
165
|
except Exception as e:
|
157
166
|
logger.error(f'Fail to find package manager: {e}')
|
@@ -188,7 +197,8 @@ def run_dependency_scanner(package_manager='', input_dir='', output_dir_file='',
|
|
188
197
|
fail_pm.append(f"{pm} ({', '.join(manifest_file_name)})")
|
189
198
|
cover = CoverItem(tool_name=_PKG_NAME,
|
190
199
|
start_time=_start_time,
|
191
|
-
input_path=input_dir
|
200
|
+
input_path=input_dir,
|
201
|
+
exclude_path=path_to_exclude)
|
192
202
|
cover_comment_arr = []
|
193
203
|
if len(found_package_manager.keys()) > 0:
|
194
204
|
if len(success_pm) > 0:
|
@@ -231,6 +241,7 @@ def main():
|
|
231
241
|
package_manager = ''
|
232
242
|
input_dir = ''
|
233
243
|
output_dir = ''
|
244
|
+
path_to_exclude = []
|
234
245
|
pip_activate_cmd = ''
|
235
246
|
pip_deactivate_cmd = ''
|
236
247
|
output_custom_dir = ''
|
@@ -244,6 +255,7 @@ def main():
|
|
244
255
|
parser.add_argument('-v', '--version', action='store_true', required=False)
|
245
256
|
parser.add_argument('-m', '--manager', nargs=1, type=str, default='', required=False)
|
246
257
|
parser.add_argument('-p', '--path', nargs=1, type=str, required=False)
|
258
|
+
parser.add_argument('-e', '--exclude', nargs='*', required=False, default=[])
|
247
259
|
parser.add_argument('-o', '--output', nargs=1, type=str, required=False)
|
248
260
|
parser.add_argument('-a', '--activate', nargs=1, type=str, default='', required=False)
|
249
261
|
parser.add_argument('-d', '--deactivate', nargs=1, type=str, default='', required=False)
|
@@ -268,6 +280,8 @@ def main():
|
|
268
280
|
package_manager = ''.join(args.manager)
|
269
281
|
if args.path: # -p option
|
270
282
|
input_dir = ''.join(args.path)
|
283
|
+
if args.exclude: # -e option
|
284
|
+
path_to_exclude = args.exclude
|
271
285
|
if args.output: # -o option
|
272
286
|
output_dir = ''.join(args.output)
|
273
287
|
if args.activate: # -a option
|
@@ -301,7 +315,7 @@ def main():
|
|
301
315
|
sys.exit(0)
|
302
316
|
|
303
317
|
run_dependency_scanner(package_manager, input_dir, output_dir, pip_activate_cmd, pip_deactivate_cmd,
|
304
|
-
output_custom_dir, app_name, github_token, format, direct)
|
318
|
+
output_custom_dir, app_name, github_token, format, direct, path_to_exclude)
|
305
319
|
|
306
320
|
|
307
321
|
if __name__ == '__main__':
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{fosslight_dependency-3.14.3 → fosslight_dependency-3.15.1}/src/fosslight_dependency/__init__.py
RENAMED
File without changes
|
File without changes
|
{fosslight_dependency-3.14.3 → fosslight_dependency-3.15.1}/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
|