fosslight-source 2.0.0__tar.gz → 2.1.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_source-2.0.0 → fosslight_source-2.1.1}/PKG-INFO +1 -1
- fosslight_source-2.1.1/requirements.txt +9 -0
- {fosslight_source-2.0.0 → fosslight_source-2.1.1}/setup.py +1 -1
- {fosslight_source-2.0.0 → fosslight_source-2.1.1}/src/fosslight_source/_help.py +2 -2
- {fosslight_source-2.0.0 → fosslight_source-2.1.1}/src/fosslight_source/_license_matched.py +8 -8
- {fosslight_source-2.0.0 → fosslight_source-2.1.1}/src/fosslight_source/_parsing_scancode_file_item.py +10 -5
- {fosslight_source-2.0.0 → fosslight_source-2.1.1}/src/fosslight_source/_parsing_scanoss_file.py +4 -2
- {fosslight_source-2.0.0 → fosslight_source-2.1.1}/src/fosslight_source/_scan_item.py +14 -12
- {fosslight_source-2.0.0 → fosslight_source-2.1.1}/src/fosslight_source/cli.py +53 -18
- {fosslight_source-2.0.0 → fosslight_source-2.1.1}/src/fosslight_source/run_scancode.py +11 -5
- {fosslight_source-2.0.0 → fosslight_source-2.1.1}/src/fosslight_source/run_scanoss.py +5 -5
- {fosslight_source-2.0.0 → fosslight_source-2.1.1}/src/fosslight_source/run_spdx_extractor.py +2 -2
- {fosslight_source-2.0.0 → fosslight_source-2.1.1}/src/fosslight_source.egg-info/PKG-INFO +1 -1
- fosslight_source-2.1.1/src/fosslight_source.egg-info/requires.txt +9 -0
- fosslight_source-2.0.0/requirements.txt +0 -10
- fosslight_source-2.0.0/src/fosslight_source.egg-info/requires.txt +0 -12
- {fosslight_source-2.0.0 → fosslight_source-2.1.1}/LICENSE +0 -0
- {fosslight_source-2.0.0 → fosslight_source-2.1.1}/MANIFEST.in +0 -0
- {fosslight_source-2.0.0 → fosslight_source-2.1.1}/README.md +0 -0
- {fosslight_source-2.0.0 → fosslight_source-2.1.1}/setup.cfg +0 -0
- {fosslight_source-2.0.0 → fosslight_source-2.1.1}/src/fosslight_source/__init__.py +0 -0
- {fosslight_source-2.0.0 → fosslight_source-2.1.1}/src/fosslight_source.egg-info/SOURCES.txt +0 -0
- {fosslight_source-2.0.0 → fosslight_source-2.1.1}/src/fosslight_source.egg-info/dependency_links.txt +0 -0
- {fosslight_source-2.0.0 → fosslight_source-2.1.1}/src/fosslight_source.egg-info/entry_points.txt +0 -0
- {fosslight_source-2.0.0 → fosslight_source-2.1.1}/src/fosslight_source.egg-info/top_level.txt +0 -0
|
@@ -14,7 +14,7 @@ with open('requirements.txt', 'r', 'utf-8') as f:
|
|
|
14
14
|
if __name__ == "__main__":
|
|
15
15
|
setup(
|
|
16
16
|
name='fosslight_source',
|
|
17
|
-
version='2.
|
|
17
|
+
version='2.1.1',
|
|
18
18
|
package_dir={"": "src"},
|
|
19
19
|
packages=find_packages(where='src'),
|
|
20
20
|
description='FOSSLight Source Scanner',
|
|
@@ -30,10 +30,10 @@ _HELP_MESSAGE_SOURCE_SCANNER = """
|
|
|
30
30
|
--correct_fpath <path> Path to the sbom-info.yaml file"""
|
|
31
31
|
|
|
32
32
|
|
|
33
|
-
def print_version(pkg_name):
|
|
33
|
+
def print_version(pkg_name: str) -> None:
|
|
34
34
|
print_package_version(pkg_name, "FOSSLight Source Scanner Version:")
|
|
35
35
|
|
|
36
36
|
|
|
37
|
-
def print_help_msg_source_scanner():
|
|
37
|
+
def print_help_msg_source_scanner() -> None:
|
|
38
38
|
helpMsg = PrintHelpMsg(_HELP_MESSAGE_SOURCE_SCANNER)
|
|
39
39
|
helpMsg.print_help_msg(True)
|
|
@@ -20,33 +20,33 @@ class MatchedLicense:
|
|
|
20
20
|
matched_text = ""
|
|
21
21
|
priority = 0
|
|
22
22
|
|
|
23
|
-
def __init__(self, lic, category, text, file):
|
|
23
|
+
def __init__(self, lic: str, category: str, text: str, file: str) -> None:
|
|
24
24
|
self.files = [file]
|
|
25
25
|
self.license = lic
|
|
26
26
|
self.matched_text = text
|
|
27
27
|
self.set_category(category)
|
|
28
28
|
|
|
29
|
-
def __del__(self):
|
|
29
|
+
def __del__(self) -> None:
|
|
30
30
|
pass
|
|
31
31
|
|
|
32
|
-
def set_license(self, value):
|
|
32
|
+
def set_license(self, value: str) -> None:
|
|
33
33
|
self.license = value
|
|
34
34
|
|
|
35
|
-
def set_files(self, value):
|
|
35
|
+
def set_files(self, value: str) -> None:
|
|
36
36
|
if value not in self.files:
|
|
37
37
|
self.files.append(value)
|
|
38
38
|
|
|
39
|
-
def set_category(self, value):
|
|
39
|
+
def set_category(self, value: str) -> None:
|
|
40
40
|
self.category = value
|
|
41
41
|
if value in LOW_PRIORITY:
|
|
42
42
|
self.priority = 1
|
|
43
43
|
else:
|
|
44
44
|
self.priority = 0
|
|
45
45
|
|
|
46
|
-
def set_matched_text(self, value):
|
|
46
|
+
def set_matched_text(self, value: str) -> None:
|
|
47
47
|
self.matched_text = value
|
|
48
48
|
|
|
49
|
-
def get_row_to_print(self, result_for_32_earlier=True):
|
|
49
|
+
def get_row_to_print(self, result_for_32_earlier: bool = True) -> list:
|
|
50
50
|
if result_for_32_earlier:
|
|
51
51
|
print_rows = [self.category, self.license, self.matched_text, str(len(self.files)), ','.join(self.files)]
|
|
52
52
|
else:
|
|
@@ -54,7 +54,7 @@ class MatchedLicense:
|
|
|
54
54
|
return print_rows
|
|
55
55
|
|
|
56
56
|
|
|
57
|
-
def get_license_list_to_print(license_list):
|
|
57
|
+
def get_license_list_to_print(license_list: dict) -> list:
|
|
58
58
|
result_for_32_earlier = any([value.category for key, value in license_list.items()])
|
|
59
59
|
license_items = license_list.values()
|
|
60
60
|
license_items = sorted(license_items, key=lambda row: (row.priority, row.category, row.license))
|
|
@@ -13,6 +13,7 @@ from ._scan_item import is_exclude_dir
|
|
|
13
13
|
from ._scan_item import is_exclude_file
|
|
14
14
|
from ._scan_item import replace_word
|
|
15
15
|
from ._scan_item import is_notice_file
|
|
16
|
+
from typing import Tuple
|
|
16
17
|
|
|
17
18
|
logger = logging.getLogger(constant.LOGGER_NAME)
|
|
18
19
|
_exclude_directory = ["test", "tests", "doc", "docs"]
|
|
@@ -30,7 +31,7 @@ KEY_AND = r"(?<=\s)and(?=\s)"
|
|
|
30
31
|
KEY_OR = r"(?<=\s)or(?=\s)"
|
|
31
32
|
|
|
32
33
|
|
|
33
|
-
def get_error_from_header(header_item):
|
|
34
|
+
def get_error_from_header(header_item: list) -> Tuple[bool, str]:
|
|
34
35
|
has_error = False
|
|
35
36
|
str_error = ""
|
|
36
37
|
key_error = "errors"
|
|
@@ -49,7 +50,7 @@ def get_error_from_header(header_item):
|
|
|
49
50
|
return has_error, str_error
|
|
50
51
|
|
|
51
52
|
|
|
52
|
-
def parsing_scancode_32_earlier(scancode_file_list, has_error=False):
|
|
53
|
+
def parsing_scancode_32_earlier(scancode_file_list: list, has_error: bool = False) -> Tuple[bool, list, list, dict]:
|
|
53
54
|
rc = True
|
|
54
55
|
msg = []
|
|
55
56
|
scancode_file_item = []
|
|
@@ -178,7 +179,7 @@ def parsing_scancode_32_earlier(scancode_file_list, has_error=False):
|
|
|
178
179
|
return rc, scancode_file_item, msg, license_list
|
|
179
180
|
|
|
180
181
|
|
|
181
|
-
def split_spdx_expression(spdx_string):
|
|
182
|
+
def split_spdx_expression(spdx_string: str) -> list:
|
|
182
183
|
license = []
|
|
183
184
|
for replace in SPDX_REPLACE_WORDS:
|
|
184
185
|
spdx_string = spdx_string.replace(replace, "")
|
|
@@ -186,7 +187,9 @@ def split_spdx_expression(spdx_string):
|
|
|
186
187
|
return license
|
|
187
188
|
|
|
188
189
|
|
|
189
|
-
def parsing_scancode_32_later(
|
|
190
|
+
def parsing_scancode_32_later(
|
|
191
|
+
scancode_file_list: list, has_error: bool = False
|
|
192
|
+
) -> Tuple[bool, list, list, dict]:
|
|
190
193
|
rc = True
|
|
191
194
|
msg = []
|
|
192
195
|
scancode_file_item = []
|
|
@@ -274,7 +277,9 @@ def parsing_scancode_32_later(scancode_file_list, has_error=False):
|
|
|
274
277
|
return rc, scancode_file_item, msg, license_list
|
|
275
278
|
|
|
276
279
|
|
|
277
|
-
def parsing_file_item(
|
|
280
|
+
def parsing_file_item(
|
|
281
|
+
scancode_file_list: list, has_error: bool, need_matched_license: bool = False
|
|
282
|
+
) -> Tuple[bool, list, list, dict]:
|
|
278
283
|
|
|
279
284
|
rc = True
|
|
280
285
|
msg = []
|
{fosslight_source-2.0.0 → fosslight_source-2.1.1}/src/fosslight_source/_parsing_scanoss_file.py
RENAMED
|
@@ -9,6 +9,7 @@ import fosslight_util.constant as constant
|
|
|
9
9
|
from ._scan_item import SourceItem
|
|
10
10
|
from ._scan_item import is_exclude_file
|
|
11
11
|
from ._scan_item import replace_word
|
|
12
|
+
from typing import Tuple
|
|
12
13
|
|
|
13
14
|
logger = logging.getLogger(constant.LOGGER_NAME)
|
|
14
15
|
SCANOSS_INFO_HEADER = ['No', 'Source Path', 'Component Declared', 'SPDX Tag',
|
|
@@ -16,7 +17,7 @@ SCANOSS_INFO_HEADER = ['No', 'Source Path', 'Component Declared', 'SPDX Tag',
|
|
|
16
17
|
'Matched Rate (line number)', 'scanoss_fileURL']
|
|
17
18
|
|
|
18
19
|
|
|
19
|
-
def parsing_extraInfo(scanned_result):
|
|
20
|
+
def parsing_extraInfo(scanned_result: dict) -> list:
|
|
20
21
|
scanoss_extra_info = []
|
|
21
22
|
for scan_item in scanned_result:
|
|
22
23
|
license_w_source = scan_item.scanoss_reference
|
|
@@ -35,7 +36,7 @@ def parsing_extraInfo(scanned_result):
|
|
|
35
36
|
return scanoss_extra_info
|
|
36
37
|
|
|
37
38
|
|
|
38
|
-
def parsing_scanResult(scanoss_report, path_to_scan="", path_to_exclude=[]):
|
|
39
|
+
def parsing_scanResult(scanoss_report: dict, path_to_scan: str = "", path_to_exclude: list = []) -> Tuple[bool, list]:
|
|
39
40
|
scanoss_file_item = []
|
|
40
41
|
abs_path_to_exclude = [os.path.abspath(os.path.join(path_to_scan, path)) for path in path_to_exclude]
|
|
41
42
|
|
|
@@ -44,6 +45,7 @@ def parsing_scanResult(scanoss_report, path_to_scan="", path_to_exclude=[]):
|
|
|
44
45
|
if any(os.path.commonpath([abs_file_path, exclude_path]) == exclude_path for exclude_path in abs_path_to_exclude):
|
|
45
46
|
continue
|
|
46
47
|
result_item = SourceItem(file_path)
|
|
48
|
+
|
|
47
49
|
if 'id' in findings[0]:
|
|
48
50
|
if "none" == findings[0]['id']:
|
|
49
51
|
continue
|
|
@@ -7,7 +7,7 @@ import os
|
|
|
7
7
|
import logging
|
|
8
8
|
import re
|
|
9
9
|
import fosslight_util.constant as constant
|
|
10
|
-
from fosslight_util.oss_item import FileItem, OssItem
|
|
10
|
+
from fosslight_util.oss_item import FileItem, OssItem, get_checksum_sha1
|
|
11
11
|
|
|
12
12
|
logger = logging.getLogger(constant.LOGGER_NAME)
|
|
13
13
|
replace_word = ["-only", "-old-style", "-or-later", "licenseref-scancode-", "licenseref-"]
|
|
@@ -28,7 +28,7 @@ SUBSTRING_LICENSE_COMMENT = "Maximum character limit (License)"
|
|
|
28
28
|
|
|
29
29
|
class SourceItem(FileItem):
|
|
30
30
|
|
|
31
|
-
def __init__(self, value):
|
|
31
|
+
def __init__(self, value: str) -> None:
|
|
32
32
|
super().__init__("")
|
|
33
33
|
self.source_name_or_path = value
|
|
34
34
|
self.is_license_text = False
|
|
@@ -42,18 +42,20 @@ class SourceItem(FileItem):
|
|
|
42
42
|
self.oss_name = ""
|
|
43
43
|
self.oss_version = ""
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
self.checksum = get_checksum_sha1(value)
|
|
46
|
+
|
|
47
|
+
def __del__(self) -> None:
|
|
46
48
|
pass
|
|
47
49
|
|
|
48
|
-
def __hash__(self):
|
|
50
|
+
def __hash__(self) -> int:
|
|
49
51
|
return hash(self.file)
|
|
50
52
|
|
|
51
53
|
@property
|
|
52
|
-
def licenses(self):
|
|
54
|
+
def licenses(self) -> list:
|
|
53
55
|
return self._licenses
|
|
54
56
|
|
|
55
57
|
@licenses.setter
|
|
56
|
-
def licenses(self, value):
|
|
58
|
+
def licenses(self, value: list) -> None:
|
|
57
59
|
if value:
|
|
58
60
|
max_length_exceed = False
|
|
59
61
|
for new_lic in value:
|
|
@@ -70,7 +72,7 @@ class SourceItem(FileItem):
|
|
|
70
72
|
if max_length_exceed and (SUBSTRING_LICENSE_COMMENT not in self.comment):
|
|
71
73
|
self.comment = f"{self.comment}/ {SUBSTRING_LICENSE_COMMENT}" if self.comment else SUBSTRING_LICENSE_COMMENT
|
|
72
74
|
|
|
73
|
-
def set_oss_item(self):
|
|
75
|
+
def set_oss_item(self) -> None:
|
|
74
76
|
self.oss_items = []
|
|
75
77
|
if self.download_location:
|
|
76
78
|
for url in self.download_location:
|
|
@@ -84,7 +86,7 @@ class SourceItem(FileItem):
|
|
|
84
86
|
item.comment = self.comment
|
|
85
87
|
self.oss_items.append(item)
|
|
86
88
|
|
|
87
|
-
def get_print_array(self):
|
|
89
|
+
def get_print_array(self) -> list:
|
|
88
90
|
print_rows = []
|
|
89
91
|
for item in self.oss_items:
|
|
90
92
|
print_rows.append([self.source_name_or_path, item.name, item.version, ",".join(item.license),
|
|
@@ -93,14 +95,14 @@ class SourceItem(FileItem):
|
|
|
93
95
|
self.license_reference])
|
|
94
96
|
return print_rows
|
|
95
97
|
|
|
96
|
-
def __eq__(self, other):
|
|
98
|
+
def __eq__(self, other: object) -> bool:
|
|
97
99
|
if type(other) == str:
|
|
98
100
|
return self.source_name_or_path == other
|
|
99
101
|
else:
|
|
100
102
|
return self.source_name_or_path == other.source_name_or_path
|
|
101
103
|
|
|
102
104
|
|
|
103
|
-
def is_exclude_dir(dir_path):
|
|
105
|
+
def is_exclude_dir(dir_path: str) -> bool:
|
|
104
106
|
if dir_path != "":
|
|
105
107
|
dir_path = dir_path.lower()
|
|
106
108
|
dir_path = dir_path if dir_path.endswith(
|
|
@@ -111,7 +113,7 @@ def is_exclude_dir(dir_path):
|
|
|
111
113
|
return False
|
|
112
114
|
|
|
113
115
|
|
|
114
|
-
def is_exclude_file(file_path, prev_dir=None, prev_dir_exclude_value=None):
|
|
116
|
+
def is_exclude_file(file_path: str, prev_dir: str = None, prev_dir_exclude_value: bool = None) -> bool:
|
|
115
117
|
file_path = file_path.lower()
|
|
116
118
|
filename = os.path.basename(file_path)
|
|
117
119
|
if os.path.splitext(filename)[1] in _exclude_extension:
|
|
@@ -133,7 +135,7 @@ def is_exclude_file(file_path, prev_dir=None, prev_dir_exclude_value=None):
|
|
|
133
135
|
return False
|
|
134
136
|
|
|
135
137
|
|
|
136
|
-
def is_notice_file(file_path):
|
|
138
|
+
def is_notice_file(file_path: str) -> bool:
|
|
137
139
|
pattern = r"({})(?<!w)".format("|".join(_notice_filename))
|
|
138
140
|
file_path = file_path.lower()
|
|
139
141
|
filename = os.path.basename(file_path)
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import sys
|
|
7
7
|
import os
|
|
8
|
+
import platform
|
|
8
9
|
import warnings
|
|
9
10
|
import logging
|
|
10
11
|
from datetime import datetime
|
|
@@ -13,7 +14,7 @@ from fosslight_util.set_log import init_log
|
|
|
13
14
|
from fosslight_util.timer_thread import TimerThread
|
|
14
15
|
from ._help import print_version, print_help_msg_source_scanner
|
|
15
16
|
from ._license_matched import get_license_list_to_print
|
|
16
|
-
from fosslight_util.output_format import
|
|
17
|
+
from fosslight_util.output_format import check_output_formats_v2, write_output_file
|
|
17
18
|
from fosslight_util.correct import correct_with_yaml
|
|
18
19
|
from .run_scancode import run_scan
|
|
19
20
|
from .run_scanoss import run_scanoss_py
|
|
@@ -23,6 +24,7 @@ import argparse
|
|
|
23
24
|
from .run_spdx_extractor import get_spdx_downloads
|
|
24
25
|
from ._scan_item import SourceItem
|
|
25
26
|
from fosslight_util.oss_item import ScannerItem
|
|
27
|
+
from typing import Tuple
|
|
26
28
|
|
|
27
29
|
SRC_SHEET_NAME = 'SRC_FL_Source'
|
|
28
30
|
SCANOSS_HEADER = {SRC_SHEET_NAME: ['ID', 'Source Path', 'OSS Name',
|
|
@@ -39,7 +41,7 @@ PKG_NAME = "fosslight_source"
|
|
|
39
41
|
RESULT_KEY = "Scan Result"
|
|
40
42
|
|
|
41
43
|
|
|
42
|
-
def main():
|
|
44
|
+
def main() -> None:
|
|
43
45
|
global logger
|
|
44
46
|
_result_log = {}
|
|
45
47
|
|
|
@@ -48,7 +50,7 @@ def main():
|
|
|
48
50
|
write_json_file = False
|
|
49
51
|
output_file_name = ""
|
|
50
52
|
print_matched_text = False
|
|
51
|
-
formats =
|
|
53
|
+
formats = []
|
|
52
54
|
selected_scanner = ""
|
|
53
55
|
correct_mode = True
|
|
54
56
|
|
|
@@ -121,7 +123,7 @@ def main():
|
|
|
121
123
|
sys.exit(1)
|
|
122
124
|
|
|
123
125
|
|
|
124
|
-
def count_files(path_to_scan, path_to_exclude):
|
|
126
|
+
def count_files(path_to_scan: str, path_to_exclude: list) -> Tuple[int, int]:
|
|
125
127
|
total_files = 0
|
|
126
128
|
excluded_files = 0
|
|
127
129
|
abs_path_to_exclude = [os.path.abspath(os.path.join(path_to_scan, path)) for path in path_to_exclude]
|
|
@@ -138,9 +140,15 @@ def count_files(path_to_scan, path_to_exclude):
|
|
|
138
140
|
return total_files, excluded_files
|
|
139
141
|
|
|
140
142
|
|
|
141
|
-
def create_report_file(
|
|
142
|
-
|
|
143
|
-
|
|
143
|
+
def create_report_file(
|
|
144
|
+
_start_time: str, merged_result: list,
|
|
145
|
+
license_list: list, scanoss_result: list,
|
|
146
|
+
selected_scanner: str, need_license: bool = False,
|
|
147
|
+
output_path: str = "", output_files: list = [],
|
|
148
|
+
output_extensions: list = [], correct_mode: bool = True,
|
|
149
|
+
correct_filepath: str = "", path_to_scan: str = "", path_to_exclude: list = [],
|
|
150
|
+
formats: list = []
|
|
151
|
+
) -> 'ScannerItem':
|
|
144
152
|
"""
|
|
145
153
|
Create report files for given scanned result.
|
|
146
154
|
|
|
@@ -162,12 +170,33 @@ def create_report_file(_start_time, merged_result, license_list, scanoss_result,
|
|
|
162
170
|
# If -o does not contains file name, set default name
|
|
163
171
|
while len(output_files) < len(output_extensions):
|
|
164
172
|
output_files.append(None)
|
|
173
|
+
to_remove = [] # elements of spdx format on windows that should be removed
|
|
165
174
|
for i, output_extension in enumerate(output_extensions):
|
|
166
175
|
if output_files[i] is None or output_files[i] == "":
|
|
167
|
-
if
|
|
168
|
-
|
|
176
|
+
if formats:
|
|
177
|
+
if formats[i].startswith('spdx'):
|
|
178
|
+
if platform.system() != 'Windows':
|
|
179
|
+
output_files[i] = f"fosslight_spdx_src_{_start_time}"
|
|
180
|
+
else:
|
|
181
|
+
logger.warning('spdx format is not supported on Windows. Please remove spdx from format.')
|
|
182
|
+
to_remove.append(i)
|
|
183
|
+
else:
|
|
184
|
+
if output_extension == _json_ext:
|
|
185
|
+
output_files[i] = f"fosslight_opossum_src_{_start_time}"
|
|
186
|
+
else:
|
|
187
|
+
output_files[i] = f"fosslight_report_src_{_start_time}"
|
|
169
188
|
else:
|
|
170
|
-
|
|
189
|
+
if output_extension == _json_ext:
|
|
190
|
+
output_files[i] = f"fosslight_opossum_src_{_start_time}"
|
|
191
|
+
else:
|
|
192
|
+
output_files[i] = f"fosslight_report_src_{_start_time}"
|
|
193
|
+
for index in sorted(to_remove, reverse=True):
|
|
194
|
+
# remove elements of spdx format on windows
|
|
195
|
+
del output_files[index]
|
|
196
|
+
del output_extensions[index]
|
|
197
|
+
del formats[index]
|
|
198
|
+
if len(output_extensions) < 1:
|
|
199
|
+
sys.exit(0)
|
|
171
200
|
|
|
172
201
|
if not correct_filepath:
|
|
173
202
|
correct_filepath = path_to_scan
|
|
@@ -213,10 +242,10 @@ def create_report_file(_start_time, merged_result, license_list, scanoss_result,
|
|
|
213
242
|
|
|
214
243
|
combined_paths_and_files = [os.path.join(output_path, file) for file in output_files]
|
|
215
244
|
results = []
|
|
216
|
-
for combined_path_and_file, output_extension in zip(combined_paths_and_files, output_extensions):
|
|
245
|
+
for combined_path_and_file, output_extension, output_format in zip(combined_paths_and_files, output_extensions, formats):
|
|
217
246
|
# if need_license and output_extension == _json_ext and "scanoss_reference" in sheet_list:
|
|
218
247
|
# del sheet_list["scanoss_reference"]
|
|
219
|
-
results.append(write_output_file(combined_path_and_file, output_extension, scan_item, extended_header, ""))
|
|
248
|
+
results.append(write_output_file(combined_path_and_file, output_extension, scan_item, extended_header, "", output_format))
|
|
220
249
|
for success, msg, result_file in results:
|
|
221
250
|
if success:
|
|
222
251
|
logger.info(f"Output file: {result_file}")
|
|
@@ -227,7 +256,7 @@ def create_report_file(_start_time, merged_result, license_list, scanoss_result,
|
|
|
227
256
|
return scan_item
|
|
228
257
|
|
|
229
258
|
|
|
230
|
-
def merge_results(scancode_result=[], scanoss_result=[], spdx_downloads={}):
|
|
259
|
+
def merge_results(scancode_result: list = [], scanoss_result: list = [], spdx_downloads: dict = {}) -> list:
|
|
231
260
|
"""
|
|
232
261
|
Merge scanner results and spdx parsing result.
|
|
233
262
|
:param scancode_result: list of scancode results in SourceItem.
|
|
@@ -257,9 +286,14 @@ def merge_results(scancode_result=[], scanoss_result=[], spdx_downloads={}):
|
|
|
257
286
|
return scancode_result
|
|
258
287
|
|
|
259
288
|
|
|
260
|
-
def run_scanners(
|
|
261
|
-
|
|
262
|
-
|
|
289
|
+
def run_scanners(
|
|
290
|
+
path_to_scan: str, output_file_name: str = "",
|
|
291
|
+
write_json_file: bool = False, num_cores: int = -1,
|
|
292
|
+
called_by_cli: bool = True, print_matched_text: bool = False,
|
|
293
|
+
formats: list = [], time_out: int = 120,
|
|
294
|
+
correct_mode: bool = True, correct_filepath: str = "",
|
|
295
|
+
selected_scanner: str = 'all', path_to_exclude: list = []
|
|
296
|
+
) -> Tuple[bool, str, 'ScannerItem', list, list]:
|
|
263
297
|
"""
|
|
264
298
|
Run Scancode and scanoss.py for the given path.
|
|
265
299
|
|
|
@@ -284,8 +318,9 @@ def run_scanners(path_to_scan, output_file_name="", write_json_file=False, num_c
|
|
|
284
318
|
license_list = []
|
|
285
319
|
spdx_downloads = {}
|
|
286
320
|
result_log = {}
|
|
321
|
+
scan_item = []
|
|
287
322
|
|
|
288
|
-
success, msg, output_path, output_files, output_extensions =
|
|
323
|
+
success, msg, output_path, output_files, output_extensions, formats = check_output_formats_v2(output_file_name, formats)
|
|
289
324
|
|
|
290
325
|
logger, result_log = init_log(os.path.join(output_path, f"fosslight_log_src_{start_time}.txt"),
|
|
291
326
|
True, logging.INFO, logging.DEBUG, PKG_NAME, path_to_scan, path_to_exclude)
|
|
@@ -308,7 +343,7 @@ def run_scanners(path_to_scan, output_file_name="", write_json_file=False, num_c
|
|
|
308
343
|
merged_result = merge_results(scancode_result, scanoss_result, spdx_downloads)
|
|
309
344
|
scan_item = create_report_file(start_time, merged_result, license_list, scanoss_result, selected_scanner,
|
|
310
345
|
print_matched_text, output_path, output_files, output_extensions, correct_mode,
|
|
311
|
-
correct_filepath, path_to_scan, path_to_exclude)
|
|
346
|
+
correct_filepath, path_to_scan, path_to_exclude, formats)
|
|
312
347
|
else:
|
|
313
348
|
print_help_msg_source_scanner()
|
|
314
349
|
result_log[RESULT_KEY] = "Unsupported scanner"
|
|
@@ -14,17 +14,23 @@ import fosslight_util.constant as constant
|
|
|
14
14
|
from fosslight_util.set_log import init_log
|
|
15
15
|
from ._parsing_scancode_file_item import parsing_file_item
|
|
16
16
|
from ._parsing_scancode_file_item import get_error_from_header
|
|
17
|
-
from fosslight_util.output_format import
|
|
17
|
+
from fosslight_util.output_format import check_output_formats_v2
|
|
18
18
|
from fosslight_binary.binary_analysis import check_binary
|
|
19
|
+
from typing import Tuple
|
|
19
20
|
|
|
20
21
|
logger = logging.getLogger(constant.LOGGER_NAME)
|
|
21
22
|
warnings.filterwarnings("ignore", category=FutureWarning)
|
|
22
23
|
_PKG_NAME = "fosslight_source"
|
|
23
24
|
|
|
24
25
|
|
|
25
|
-
def run_scan(
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
def run_scan(
|
|
27
|
+
path_to_scan: str, output_file_name: str = "",
|
|
28
|
+
_write_json_file: bool = False, num_cores: int = -1,
|
|
29
|
+
return_results: bool = False, need_license: bool = False,
|
|
30
|
+
formats: list = [], called_by_cli: bool = False,
|
|
31
|
+
time_out: int = 120, correct_mode: bool = True,
|
|
32
|
+
correct_filepath: str = "", path_to_exclude: list = []
|
|
33
|
+
) -> Tuple[bool, str, list, list]:
|
|
28
34
|
if not called_by_cli:
|
|
29
35
|
global logger
|
|
30
36
|
|
|
@@ -40,7 +46,7 @@ def run_scan(path_to_scan, output_file_name="",
|
|
|
40
46
|
if not correct_filepath:
|
|
41
47
|
correct_filepath = path_to_scan
|
|
42
48
|
|
|
43
|
-
success, msg, output_path, output_files, output_extensions =
|
|
49
|
+
success, msg, output_path, output_files, output_extensions, formats = check_output_formats_v2(output_file_name, formats)
|
|
44
50
|
if success:
|
|
45
51
|
if output_path == "": # if json output with _write_json_file not used, output_path won't be needed.
|
|
46
52
|
output_path = os.getcwd()
|
|
@@ -11,7 +11,7 @@ import json
|
|
|
11
11
|
from datetime import datetime
|
|
12
12
|
import fosslight_util.constant as constant
|
|
13
13
|
from fosslight_util.set_log import init_log
|
|
14
|
-
from fosslight_util.output_format import
|
|
14
|
+
from fosslight_util.output_format import check_output_formats_v2 # , write_output_file
|
|
15
15
|
from ._parsing_scanoss_file import parsing_scanResult # scanoss
|
|
16
16
|
from ._parsing_scanoss_file import parsing_extraInfo # scanoss
|
|
17
17
|
import shutil
|
|
@@ -25,12 +25,12 @@ SCANOSS_RESULT_FILE = "scanner_output.wfp"
|
|
|
25
25
|
SCANOSS_OUTPUT_FILE = "scanoss_raw_result.json"
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
def get_scanoss_extra_info(scanned_result):
|
|
28
|
+
def get_scanoss_extra_info(scanned_result: dict) -> list:
|
|
29
29
|
return parsing_extraInfo(scanned_result)
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
def run_scanoss_py(path_to_scan, output_file_name="", format=
|
|
33
|
-
write_json_file=False, num_threads
|
|
32
|
+
def run_scanoss_py(path_to_scan: str, output_file_name: str = "", format: list = [], called_by_cli: bool = False,
|
|
33
|
+
write_json_file: bool = False, num_threads: int = -1, path_to_exclude: list = []) -> list:
|
|
34
34
|
"""
|
|
35
35
|
Run scanoss.py for the given path.
|
|
36
36
|
|
|
@@ -41,7 +41,7 @@ def run_scanoss_py(path_to_scan, output_file_name="", format="", called_by_cli=F
|
|
|
41
41
|
:param write_json_file: if requested, keep the raw files.
|
|
42
42
|
:return scanoss_file_list: list of ScanItem (scanned result by files).
|
|
43
43
|
"""
|
|
44
|
-
success, msg, output_path, output_files, output_extensions =
|
|
44
|
+
success, msg, output_path, output_files, output_extensions, formats = check_output_formats_v2(output_file_name, format)
|
|
45
45
|
|
|
46
46
|
if not called_by_cli:
|
|
47
47
|
global logger
|
{fosslight_source-2.0.0 → fosslight_source-2.1.1}/src/fosslight_source/run_spdx_extractor.py
RENAMED
|
@@ -12,7 +12,7 @@ import mmap
|
|
|
12
12
|
logger = logging.getLogger(constant.LOGGER_NAME)
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
def get_file_list(path_to_scan, path_to_exclude=[]):
|
|
15
|
+
def get_file_list(path_to_scan: str, path_to_exclude: list = []) -> list:
|
|
16
16
|
file_list = []
|
|
17
17
|
abs_path_to_exclude = [os.path.abspath(os.path.join(path_to_scan, path)) for path in path_to_exclude]
|
|
18
18
|
for root, dirs, files in os.walk(path_to_scan):
|
|
@@ -26,7 +26,7 @@ def get_file_list(path_to_scan, path_to_exclude=[]):
|
|
|
26
26
|
return file_list
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
def get_spdx_downloads(path_to_scan, path_to_exclude=[]):
|
|
29
|
+
def get_spdx_downloads(path_to_scan: str, path_to_exclude: list = []) -> dict:
|
|
30
30
|
download_dict = {}
|
|
31
31
|
find_word = re.compile(rb"SPDX-PackageDownloadLocation\s*:\s*(\S+)", re.IGNORECASE)
|
|
32
32
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fosslight_source-2.0.0 → fosslight_source-2.1.1}/src/fosslight_source.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{fosslight_source-2.0.0 → fosslight_source-2.1.1}/src/fosslight_source.egg-info/entry_points.txt
RENAMED
|
File without changes
|
{fosslight_source-2.0.0 → fosslight_source-2.1.1}/src/fosslight_source.egg-info/top_level.txt
RENAMED
|
File without changes
|