fosslight-binary 4.1.32__tar.gz → 5.0.0__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_binary-4.1.32 → fosslight_binary-5.0.0}/PKG-INFO +1 -1
- {fosslight_binary-4.1.32 → fosslight_binary-5.0.0}/requirements.txt +1 -1
- {fosslight_binary-4.1.32 → fosslight_binary-5.0.0}/setup.py +1 -1
- fosslight_binary-5.0.0/src/fosslight_binary/_binary.py +102 -0
- {fosslight_binary-4.1.32 → fosslight_binary-5.0.0}/src/fosslight_binary/_binary_dao.py +5 -4
- {fosslight_binary-4.1.32 → fosslight_binary-5.0.0}/src/fosslight_binary/_jar_analysis.py +7 -6
- {fosslight_binary-4.1.32 → fosslight_binary-5.0.0}/src/fosslight_binary/binary_analysis.py +59 -37
- {fosslight_binary-4.1.32 → fosslight_binary-5.0.0}/src/fosslight_binary.egg-info/PKG-INFO +1 -1
- {fosslight_binary-4.1.32 → fosslight_binary-5.0.0}/src/fosslight_binary.egg-info/requires.txt +1 -1
- fosslight_binary-4.1.32/src/fosslight_binary/_binary.py +0 -168
- {fosslight_binary-4.1.32 → fosslight_binary-5.0.0}/LICENSE +0 -0
- {fosslight_binary-4.1.32 → fosslight_binary-5.0.0}/LICENSES/Apache-2.0.txt +0 -0
- {fosslight_binary-4.1.32 → fosslight_binary-5.0.0}/LICENSES/LicenseRef-3rd_party_licenses.txt +0 -0
- {fosslight_binary-4.1.32 → fosslight_binary-5.0.0}/MANIFEST.in +0 -0
- {fosslight_binary-4.1.32 → fosslight_binary-5.0.0}/README.md +0 -0
- {fosslight_binary-4.1.32 → fosslight_binary-5.0.0}/setup.cfg +0 -0
- {fosslight_binary-4.1.32 → fosslight_binary-5.0.0}/src/fosslight_binary/__init__.py +0 -0
- {fosslight_binary-4.1.32 → fosslight_binary-5.0.0}/src/fosslight_binary/_help.py +0 -0
- {fosslight_binary-4.1.32 → fosslight_binary-5.0.0}/src/fosslight_binary/cli.py +0 -0
- {fosslight_binary-4.1.32 → fosslight_binary-5.0.0}/src/fosslight_binary.egg-info/SOURCES.txt +0 -0
- {fosslight_binary-4.1.32 → fosslight_binary-5.0.0}/src/fosslight_binary.egg-info/dependency_links.txt +0 -0
- {fosslight_binary-4.1.32 → fosslight_binary-5.0.0}/src/fosslight_binary.egg-info/entry_points.txt +0 -0
- {fosslight_binary-4.1.32 → fosslight_binary-5.0.0}/src/fosslight_binary.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
# Copyright (c) 2020 LG Electronics Inc.
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
from fosslight_util.oss_item import FileItem
|
|
6
|
+
|
|
7
|
+
EXCLUDE_TRUE_VALUE = "Exclude"
|
|
8
|
+
TLSH_CHECKSUM_NULL = "0"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class VulnerabilityItem:
|
|
12
|
+
file_path = ""
|
|
13
|
+
vul_id = ""
|
|
14
|
+
nvd_url = ""
|
|
15
|
+
|
|
16
|
+
def __init__(self, file_path, id, url):
|
|
17
|
+
self.file_path = file_path
|
|
18
|
+
self.vul_id = id
|
|
19
|
+
self.nvd_url = url
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class BinaryItem(FileItem):
|
|
23
|
+
def __init__(self, value):
|
|
24
|
+
super().__init__("")
|
|
25
|
+
self.exclude = False
|
|
26
|
+
self.source_name_or_path = ""
|
|
27
|
+
self.checksum = TLSH_CHECKSUM_NULL
|
|
28
|
+
self.tlsh = TLSH_CHECKSUM_NULL
|
|
29
|
+
self.vulnerability_items = []
|
|
30
|
+
self.binary_name_without_path = ""
|
|
31
|
+
self.bin_name_with_path = value
|
|
32
|
+
self.found_in_owasp = False
|
|
33
|
+
self.is_binary = True
|
|
34
|
+
|
|
35
|
+
def __del__(self):
|
|
36
|
+
pass
|
|
37
|
+
|
|
38
|
+
def set_oss_items(self, new_oss_list, exclude=False, exclude_msg=""):
|
|
39
|
+
if exclude:
|
|
40
|
+
for oss in new_oss_list:
|
|
41
|
+
oss.exclude = True
|
|
42
|
+
oss.comment = exclude_msg
|
|
43
|
+
# Append New input OSS
|
|
44
|
+
self.oss_items.extend(new_oss_list)
|
|
45
|
+
|
|
46
|
+
def get_vulnerability_items(self):
|
|
47
|
+
nvd_url = [vul_item.nvd_url for vul_item in self.vulnerability_items]
|
|
48
|
+
return ", ".join(nvd_url)
|
|
49
|
+
|
|
50
|
+
def get_print_binary_only(self):
|
|
51
|
+
return (self.source_name_or_path + "\t" + self.checksum + "\t" + self.tlsh)
|
|
52
|
+
|
|
53
|
+
def get_print_array(self):
|
|
54
|
+
items = []
|
|
55
|
+
if self.oss_items:
|
|
56
|
+
for oss in self.oss_items:
|
|
57
|
+
lic = ",".join(oss.license)
|
|
58
|
+
exclude = EXCLUDE_TRUE_VALUE if (self.exclude or oss.exclude) else ""
|
|
59
|
+
nvd_url = self.get_vulnerability_items()
|
|
60
|
+
items.append([self.source_name_or_path, oss.name, oss.version,
|
|
61
|
+
lic, oss.download_location, oss.homepage,
|
|
62
|
+
oss.copyright, exclude, oss.comment,
|
|
63
|
+
nvd_url, self.tlsh, self.checksum])
|
|
64
|
+
else:
|
|
65
|
+
exclude = EXCLUDE_TRUE_VALUE if self.exclude else ""
|
|
66
|
+
items.append([self.source_name_or_path, '',
|
|
67
|
+
'', '', '', '', '', exclude, self.comment, '',
|
|
68
|
+
self.tlsh, self.checksum])
|
|
69
|
+
return items
|
|
70
|
+
|
|
71
|
+
def get_print_json(self):
|
|
72
|
+
items = []
|
|
73
|
+
if self.oss_items:
|
|
74
|
+
for oss in self.oss_items:
|
|
75
|
+
json_item = {}
|
|
76
|
+
json_item["name"] = oss.name
|
|
77
|
+
json_item["version"] = oss.version
|
|
78
|
+
|
|
79
|
+
if self.source_name_or_path:
|
|
80
|
+
json_item["source path"] = self.source_name_or_path
|
|
81
|
+
if len(oss.license) > 0:
|
|
82
|
+
json_item["license"] = oss.license
|
|
83
|
+
if oss.download_location:
|
|
84
|
+
json_item["download location"] = oss.download_location
|
|
85
|
+
if oss.homepage:
|
|
86
|
+
json_item["homepage"] = oss.homepage
|
|
87
|
+
if oss.copyright:
|
|
88
|
+
json_item["copyright text"] = oss.copyright
|
|
89
|
+
if self.exclude or oss.exclude:
|
|
90
|
+
json_item["exclude"] = True
|
|
91
|
+
if oss.comment:
|
|
92
|
+
json_item["comment"] = oss.comment
|
|
93
|
+
items.append(json_item)
|
|
94
|
+
else:
|
|
95
|
+
json_item = {}
|
|
96
|
+
if self.source_name_or_path:
|
|
97
|
+
json_item["source path"] = self.source_name_or_path
|
|
98
|
+
if self.exclude:
|
|
99
|
+
json_item["exclude"] = True
|
|
100
|
+
if self.comment:
|
|
101
|
+
json_item["comment"] = self.comment
|
|
102
|
+
return items
|
|
@@ -8,7 +8,8 @@ import logging
|
|
|
8
8
|
import psycopg2
|
|
9
9
|
import pandas as pd
|
|
10
10
|
from urllib.parse import urlparse
|
|
11
|
-
from ._binary import
|
|
11
|
+
from ._binary import TLSH_CHECKSUM_NULL
|
|
12
|
+
from fosslight_util.oss_item import OssItem
|
|
12
13
|
import fosslight_util.constant as constant
|
|
13
14
|
|
|
14
15
|
columns = ['filename', 'pathname', 'checksum', 'tlshchecksum', 'ossname',
|
|
@@ -43,10 +44,10 @@ def get_oss_info_from_db(bin_info_list, dburl=""):
|
|
|
43
44
|
if not item.found_in_owasp:
|
|
44
45
|
oss_from_db = OssItem(row['ossname'], row['ossversion'], row['license'])
|
|
45
46
|
bin_oss_items.append(oss_from_db)
|
|
46
|
-
item.set_comment("Binary DB result")
|
|
47
47
|
|
|
48
48
|
if bin_oss_items:
|
|
49
49
|
item.set_oss_items(bin_oss_items)
|
|
50
|
+
item.comment = "Binary DB result"
|
|
50
51
|
|
|
51
52
|
disconnect_lge_bin_db()
|
|
52
53
|
return bin_info_list, _cnt_auto_identified
|
|
@@ -97,14 +98,14 @@ def get_oss_info_by_tlsh_and_filename(file_name, checksum_value, tlsh_value):
|
|
|
97
98
|
sql_statement_filename, ['tlshchecksum'])
|
|
98
99
|
if df_result is None or len(df_result) <= 0:
|
|
99
100
|
final_result_item = ""
|
|
100
|
-
elif tlsh_value ==
|
|
101
|
+
elif tlsh_value == TLSH_CHECKSUM_NULL: # Couldn't get the tlsh of a file.
|
|
101
102
|
final_result_item = ""
|
|
102
103
|
else:
|
|
103
104
|
matched_tlsh = ""
|
|
104
105
|
matched_tlsh_diff = -1
|
|
105
106
|
for row in df_result.tlshchecksum:
|
|
106
107
|
try:
|
|
107
|
-
if row !=
|
|
108
|
+
if row != TLSH_CHECKSUM_NULL:
|
|
108
109
|
tlsh_diff = tlsh.diff(row, tlsh_value)
|
|
109
110
|
if tlsh_diff <= 120: # MATCHED
|
|
110
111
|
if (matched_tlsh_diff < 0) or (tlsh_diff < matched_tlsh_diff):
|
|
@@ -8,7 +8,8 @@ import json
|
|
|
8
8
|
import os
|
|
9
9
|
import sys
|
|
10
10
|
import fosslight_util.constant as constant
|
|
11
|
-
from ._binary import BinaryItem,
|
|
11
|
+
from ._binary import BinaryItem, VulnerabilityItem
|
|
12
|
+
from fosslight_util.oss_item import OssItem
|
|
12
13
|
from dependency_check import run as dependency_check_run
|
|
13
14
|
|
|
14
15
|
|
|
@@ -63,21 +64,21 @@ def merge_binary_list(owasp_items, vulnerability_items, bin_list):
|
|
|
63
64
|
for key, value in owasp_items.items():
|
|
64
65
|
found = False
|
|
65
66
|
for bin in bin_list:
|
|
66
|
-
if bin.
|
|
67
|
+
if bin.source_name_or_path == key:
|
|
67
68
|
for oss in value:
|
|
68
69
|
if oss.name and oss.license:
|
|
69
70
|
bin.found_in_owasp = True
|
|
70
71
|
break
|
|
71
72
|
bin.set_oss_items(value)
|
|
72
|
-
if vulnerability_items
|
|
73
|
-
bin.
|
|
73
|
+
if vulnerability_items and vulnerability_items.get(key):
|
|
74
|
+
bin.vulnerability_items.extend(vulnerability_items.get(key))
|
|
74
75
|
found = True
|
|
75
76
|
break
|
|
76
77
|
|
|
77
78
|
if not found:
|
|
78
79
|
bin_item = BinaryItem(os.path.abspath(key))
|
|
79
80
|
bin_item.binary_name_without_path = os.path.basename(key)
|
|
80
|
-
bin_item.
|
|
81
|
+
bin_item.source_name_or_path = key
|
|
81
82
|
bin_item.set_oss_items(value)
|
|
82
83
|
not_found_bin.append(bin_item)
|
|
83
84
|
|
|
@@ -261,7 +262,7 @@ def analyze_jar_file(path_to_find_bin, path_to_exclude):
|
|
|
261
262
|
|
|
262
263
|
if oss_name != "" or oss_ver != "" or oss_license != "" or oss_dl_url != "":
|
|
263
264
|
oss = OssItem(oss_name, oss_ver, oss_license, oss_dl_url)
|
|
264
|
-
oss.
|
|
265
|
+
oss.comment = "OWASP result"
|
|
265
266
|
|
|
266
267
|
remove_owasp_item = owasp_items.get(file_with_path)
|
|
267
268
|
if remove_owasp_item:
|
|
@@ -15,12 +15,15 @@ from fosslight_util.set_log import init_log
|
|
|
15
15
|
import fosslight_util.constant as constant
|
|
16
16
|
from fosslight_util.output_format import check_output_formats, write_output_file
|
|
17
17
|
from ._binary_dao import get_oss_info_from_db
|
|
18
|
-
from ._binary import BinaryItem
|
|
18
|
+
from ._binary import BinaryItem, TLSH_CHECKSUM_NULL
|
|
19
19
|
from ._jar_analysis import analyze_jar_file, merge_binary_list
|
|
20
20
|
from fosslight_util.correct import correct_with_yaml
|
|
21
|
-
from fosslight_util.
|
|
21
|
+
from fosslight_util.oss_item import ScannerItem
|
|
22
|
+
import hashlib
|
|
23
|
+
import tlsh
|
|
24
|
+
from io import open
|
|
22
25
|
|
|
23
|
-
|
|
26
|
+
PKG_NAME = "fosslight_binary"
|
|
24
27
|
logger = logging.getLogger(constant.LOGGER_NAME)
|
|
25
28
|
|
|
26
29
|
_REMOVE_FILE_EXTENSION = ['qm', 'xlsx', 'pdf', 'pptx', 'jfif', 'docx', 'doc', 'whl',
|
|
@@ -28,8 +31,9 @@ _REMOVE_FILE_EXTENSION = ['qm', 'xlsx', 'pdf', 'pptx', 'jfif', 'docx', 'doc', 'w
|
|
|
28
31
|
_REMOVE_FILE_COMMAND_RESULT = [
|
|
29
32
|
'data', 'timezone data', 'apple binary property list']
|
|
30
33
|
INCLUDE_FILE_COMMAND_RESULT = ['current ar archive']
|
|
34
|
+
_EXCLUDE_FILE_EXTENSION = ['class']
|
|
31
35
|
_EXCLUDE_FILE = ['fosslight_bin', 'fosslight_bin.exe']
|
|
32
|
-
_EXCLUDE_DIR = ["test", "tests", "doc", "docs"]
|
|
36
|
+
_EXCLUDE_DIR = ["test", "tests", "doc", "docs", "intermediates"]
|
|
33
37
|
_EXCLUDE_DIR = [os.path.sep + dir_name + os.path.sep for dir_name in _EXCLUDE_DIR]
|
|
34
38
|
_EXCLUDE_DIR.append("/.")
|
|
35
39
|
_REMOVE_DIR = ['.git']
|
|
@@ -39,11 +43,31 @@ _root_path = ""
|
|
|
39
43
|
_start_time = ""
|
|
40
44
|
windows = False
|
|
41
45
|
BYTES = 2048
|
|
42
|
-
|
|
43
46
|
BIN_EXT_HEADER = {'BIN_FL_Binary': ['ID', 'Binary Path', 'OSS Name',
|
|
44
47
|
'OSS Version', 'License', 'Download Location',
|
|
45
48
|
'Homepage', 'Copyright Text', 'Exclude',
|
|
46
49
|
'Comment', 'Vulnerability Link', 'TLSH', 'SHA1']}
|
|
50
|
+
HIDE_HEADER = {'TLSH', "SHA1"}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def get_checksum_and_tlsh(bin_with_path):
|
|
54
|
+
checksum_value = TLSH_CHECKSUM_NULL
|
|
55
|
+
tlsh_value = TLSH_CHECKSUM_NULL
|
|
56
|
+
error_msg = ""
|
|
57
|
+
try:
|
|
58
|
+
f = open(bin_with_path, "rb")
|
|
59
|
+
byte = f.read()
|
|
60
|
+
sha1_hash = hashlib.sha1(byte)
|
|
61
|
+
checksum_value = str(sha1_hash.hexdigest())
|
|
62
|
+
try:
|
|
63
|
+
tlsh_value = str(tlsh.hash(byte))
|
|
64
|
+
except:
|
|
65
|
+
tlsh_value = TLSH_CHECKSUM_NULL
|
|
66
|
+
f.close()
|
|
67
|
+
except Exception as ex:
|
|
68
|
+
error_msg = f"(Error) Get_checksum, tlsh: {ex}"
|
|
69
|
+
|
|
70
|
+
return checksum_value, tlsh_value, error_msg
|
|
47
71
|
|
|
48
72
|
|
|
49
73
|
def init(path_to_find_bin, output_file_name, formats, path_to_exclude=[]):
|
|
@@ -52,7 +76,7 @@ def init(path_to_find_bin, output_file_name, formats, path_to_exclude=[]):
|
|
|
52
76
|
_json_ext = ".json"
|
|
53
77
|
_start_time = datetime.now().strftime('%y%m%d_%H%M')
|
|
54
78
|
_result_log = {
|
|
55
|
-
"Tool Info":
|
|
79
|
+
"Tool Info": PKG_NAME
|
|
56
80
|
}
|
|
57
81
|
|
|
58
82
|
_root_path = path_to_find_bin
|
|
@@ -82,7 +106,8 @@ def init(path_to_find_bin, output_file_name, formats, path_to_exclude=[]):
|
|
|
82
106
|
sys.exit(1)
|
|
83
107
|
|
|
84
108
|
log_file = os.path.join(output_path, f"fosslight_log_bin_{_start_time}.txt")
|
|
85
|
-
logger, _result_log = init_log(log_file, True, logging.INFO, logging.DEBUG,
|
|
109
|
+
logger, _result_log = init_log(log_file, True, logging.INFO, logging.DEBUG,
|
|
110
|
+
PKG_NAME, path_to_find_bin, path_to_exclude)
|
|
86
111
|
|
|
87
112
|
if not success:
|
|
88
113
|
error_occured(error_msg=msg,
|
|
@@ -106,7 +131,7 @@ def get_file_list(path_to_find, abs_path_to_exclude):
|
|
|
106
131
|
for exclude_path in abs_path_to_exclude):
|
|
107
132
|
continue
|
|
108
133
|
file_lower_case = file.lower()
|
|
109
|
-
extension =
|
|
134
|
+
extension = os.path.splitext(file_lower_case)[1][1:].strip()
|
|
110
135
|
|
|
111
136
|
if extension == 'jar':
|
|
112
137
|
found_jar = True
|
|
@@ -120,13 +145,15 @@ def get_file_list(path_to_find, abs_path_to_exclude):
|
|
|
120
145
|
bin_with_path = os.path.join(root, file)
|
|
121
146
|
bin_item = BinaryItem(bin_with_path)
|
|
122
147
|
bin_item.binary_name_without_path = file
|
|
123
|
-
bin_item.
|
|
148
|
+
bin_item.source_name_or_path = bin_with_path.replace(
|
|
124
149
|
_root_path, '', 1)
|
|
125
150
|
|
|
126
151
|
if any(dir_name in dir_path for dir_name in _EXCLUDE_DIR):
|
|
127
|
-
bin_item.
|
|
152
|
+
bin_item.exclude = True
|
|
128
153
|
elif file.lower() in _EXCLUDE_FILE:
|
|
129
|
-
bin_item.
|
|
154
|
+
bin_item.exclude = True
|
|
155
|
+
elif extension in _EXCLUDE_FILE_EXTENSION:
|
|
156
|
+
bin_item.exclude = True
|
|
130
157
|
bin_list.append(bin_item)
|
|
131
158
|
file_cnt += 1
|
|
132
159
|
return file_cnt, bin_list, found_jar
|
|
@@ -143,11 +170,10 @@ def find_binaries(path_to_find_bin, output_dir, formats, dburl="", simple_mode=F
|
|
|
143
170
|
db_loaded_cnt = 0
|
|
144
171
|
success_to_write = False
|
|
145
172
|
writing_msg = ""
|
|
146
|
-
hide_header = {'TLSH', "SHA1"}
|
|
147
|
-
content_list = []
|
|
148
173
|
results = []
|
|
149
174
|
bin_list = []
|
|
150
175
|
base_dir_name = os.path.basename(path_to_find_bin)
|
|
176
|
+
scan_item = ScannerItem(PKG_NAME, "")
|
|
151
177
|
abs_path_to_exclude = [os.path.abspath(os.path.join(base_dir_name, path)) for path in path_to_exclude if path.strip() != ""]
|
|
152
178
|
|
|
153
179
|
if not os.path.isdir(path_to_find_bin):
|
|
@@ -165,12 +191,10 @@ def find_binaries(path_to_find_bin, output_dir, formats, dburl="", simple_mode=F
|
|
|
165
191
|
exit=True)
|
|
166
192
|
total_bin_cnt = len(return_list)
|
|
167
193
|
if simple_mode:
|
|
168
|
-
bin_list = [bin.
|
|
194
|
+
bin_list = [bin.bin_name_with_path for bin in return_list]
|
|
169
195
|
else:
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
input_path=path_to_find_bin,
|
|
173
|
-
exclude_path=path_to_exclude)
|
|
196
|
+
scan_item = ScannerItem(PKG_NAME, _start_time)
|
|
197
|
+
scan_item.set_cover_pathinfo(path_to_find_bin, path_to_exclude)
|
|
174
198
|
try:
|
|
175
199
|
# Run OWASP Dependency-check
|
|
176
200
|
if found_jar:
|
|
@@ -182,25 +206,23 @@ def find_binaries(path_to_find_bin, output_dir, formats, dburl="", simple_mode=F
|
|
|
182
206
|
logger.warning("Could not find OSS information for some jar files.")
|
|
183
207
|
|
|
184
208
|
return_list, db_loaded_cnt = get_oss_info_from_db(return_list, dburl)
|
|
185
|
-
return_list = sorted(return_list, key=lambda row: (row.
|
|
186
|
-
|
|
187
|
-
sheet_list = {}
|
|
188
|
-
for item in return_list:
|
|
189
|
-
content_list.extend(item.get_oss_report())
|
|
190
|
-
sheet_list["BIN_FL_Binary"] = content_list
|
|
209
|
+
return_list = sorted(return_list, key=lambda row: (row.bin_name_with_path))
|
|
210
|
+
scan_item.append_file_items(return_list, PKG_NAME)
|
|
191
211
|
if correct_mode:
|
|
192
|
-
success, msg_correct, correct_list = correct_with_yaml(correct_filepath, path_to_find_bin,
|
|
212
|
+
success, msg_correct, correct_list = correct_with_yaml(correct_filepath, path_to_find_bin, scan_item)
|
|
193
213
|
if not success:
|
|
194
214
|
logger.info(f"No correction with yaml: {msg_correct}")
|
|
195
215
|
else:
|
|
196
|
-
|
|
216
|
+
return_list = correct_list
|
|
197
217
|
logger.info("Success to correct with yaml.")
|
|
198
|
-
|
|
218
|
+
|
|
219
|
+
scan_item.set_cover_comment(f"Total number of binaries: {total_bin_cnt}")
|
|
199
220
|
if total_bin_cnt == 0:
|
|
200
|
-
|
|
201
|
-
|
|
221
|
+
scan_item.set_cover_comment("(No binary detected.) ")
|
|
222
|
+
scan_item.set_cover_comment(f"Total number of files: {total_file_cnt}")
|
|
223
|
+
|
|
202
224
|
for combined_path_and_file, output_extension in zip(result_reports, output_extensions):
|
|
203
|
-
results.append(write_output_file(combined_path_and_file, output_extension,
|
|
225
|
+
results.append(write_output_file(combined_path_and_file, output_extension, scan_item, BIN_EXT_HEADER, HIDE_HEADER))
|
|
204
226
|
|
|
205
227
|
except Exception as ex:
|
|
206
228
|
error_occured(error_msg=str(ex), exit=False)
|
|
@@ -211,8 +233,8 @@ def find_binaries(path_to_find_bin, output_dir, formats, dburl="", simple_mode=F
|
|
|
211
233
|
logger.info(f"Output file :{result_file}")
|
|
212
234
|
else:
|
|
213
235
|
logger.warning(f"{writing_msg}")
|
|
214
|
-
|
|
215
|
-
logger.info(
|
|
236
|
+
for row in scan_item.get_cover_comment():
|
|
237
|
+
logger.info(row)
|
|
216
238
|
else:
|
|
217
239
|
logger.error(f"Fail to generate result file.:{writing_msg}")
|
|
218
240
|
|
|
@@ -224,21 +246,21 @@ def find_binaries(path_to_find_bin, output_dir, formats, dburl="", simple_mode=F
|
|
|
224
246
|
except Exception as ex:
|
|
225
247
|
error_occured(error_msg=f"Print log : {ex}", exit=False)
|
|
226
248
|
|
|
227
|
-
return success_to_write,
|
|
249
|
+
return success_to_write, scan_item
|
|
228
250
|
|
|
229
251
|
|
|
230
252
|
def return_bin_only(file_list, need_checksum_tlsh=True):
|
|
231
253
|
for file_item in file_list:
|
|
232
254
|
try:
|
|
233
|
-
if check_binary(file_item.
|
|
255
|
+
if check_binary(file_item.bin_name_with_path):
|
|
234
256
|
if need_checksum_tlsh:
|
|
235
|
-
|
|
236
|
-
if
|
|
257
|
+
file_item.checksum, file_item.tlsh, error_msg = get_checksum_and_tlsh(file_item.bin_name_with_path)
|
|
258
|
+
if error_msg:
|
|
237
259
|
error_occured(error_msg=error_msg, exit=False)
|
|
238
260
|
yield file_item
|
|
239
261
|
except Exception as ex:
|
|
240
262
|
logger.debug(f"Exception in get_file_list: {ex}")
|
|
241
|
-
file_item.
|
|
263
|
+
file_item.comment = "Exclude or delete if it is not binary."
|
|
242
264
|
yield file_item
|
|
243
265
|
|
|
244
266
|
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
# Copyright (c) 2020 LG Electronics Inc.
|
|
4
|
-
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
import hashlib
|
|
6
|
-
import tlsh
|
|
7
|
-
from io import open
|
|
8
|
-
|
|
9
|
-
_EXCLUDE_TRUE_VALUE = "Exclude"
|
|
10
|
-
_TLSH_CHECKSUM_NULL = "0"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
class OssItem:
|
|
14
|
-
name = ""
|
|
15
|
-
version = ""
|
|
16
|
-
license = ""
|
|
17
|
-
dl_url = ""
|
|
18
|
-
comment = ""
|
|
19
|
-
exclude = False
|
|
20
|
-
|
|
21
|
-
def __init__(self, name, version, license, dl_url=""):
|
|
22
|
-
self.name = name
|
|
23
|
-
self.version = version
|
|
24
|
-
self.license = license
|
|
25
|
-
self.dl_url = dl_url
|
|
26
|
-
self.exclude = False
|
|
27
|
-
self.comment = ""
|
|
28
|
-
|
|
29
|
-
def set_comment(self, value):
|
|
30
|
-
if self.comment:
|
|
31
|
-
self.comment = f"{self.comment} / {value}"
|
|
32
|
-
else:
|
|
33
|
-
self.comment = value
|
|
34
|
-
|
|
35
|
-
def set_exclude(self, value):
|
|
36
|
-
self.exclude = value
|
|
37
|
-
|
|
38
|
-
def get_comment(self):
|
|
39
|
-
return self.comment
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
class VulnerabilityItem:
|
|
43
|
-
file_path = ""
|
|
44
|
-
vul_id = ""
|
|
45
|
-
nvd_url = ""
|
|
46
|
-
|
|
47
|
-
def __init__(self, file_path, id, url):
|
|
48
|
-
self.file_path = file_path
|
|
49
|
-
self.vul_id = id
|
|
50
|
-
self.nvd_url = url
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
class BinaryItem:
|
|
54
|
-
bin_name = ""
|
|
55
|
-
binary_name_without_path = ""
|
|
56
|
-
binary_strip_root = "" # Value of binary name column
|
|
57
|
-
tlsh = _TLSH_CHECKSUM_NULL
|
|
58
|
-
checksum = _TLSH_CHECKSUM_NULL
|
|
59
|
-
oss_items = []
|
|
60
|
-
vulnerability_items = []
|
|
61
|
-
exclude = False
|
|
62
|
-
comment = ""
|
|
63
|
-
found_in_owasp = False
|
|
64
|
-
|
|
65
|
-
def __init__(self, value):
|
|
66
|
-
self.exclude = False
|
|
67
|
-
self.binary_strip_root = ""
|
|
68
|
-
self.checksum = _TLSH_CHECKSUM_NULL
|
|
69
|
-
self.tlsh = _TLSH_CHECKSUM_NULL
|
|
70
|
-
self.oss_items = []
|
|
71
|
-
self.vulnerability_items = []
|
|
72
|
-
self.binary_name_without_path = ""
|
|
73
|
-
self.set_bin_name(value)
|
|
74
|
-
|
|
75
|
-
def __del__(self):
|
|
76
|
-
pass
|
|
77
|
-
|
|
78
|
-
def set_oss_items(self, new_oss_list, exclude=False, exclude_msg=""):
|
|
79
|
-
if exclude:
|
|
80
|
-
for oss in new_oss_list:
|
|
81
|
-
oss.set_exclude(True)
|
|
82
|
-
oss.set_comment(exclude_msg)
|
|
83
|
-
# Append New input OSS
|
|
84
|
-
self.oss_items.extend(new_oss_list)
|
|
85
|
-
|
|
86
|
-
def get_oss_items(self):
|
|
87
|
-
return self.oss_items
|
|
88
|
-
|
|
89
|
-
def set_vulnerability_items(self, vul_list):
|
|
90
|
-
if vul_list is not None:
|
|
91
|
-
self.vulnerability_items.extend(vul_list)
|
|
92
|
-
|
|
93
|
-
def get_vulnerability_items(self):
|
|
94
|
-
nvd_url = [vul_item.nvd_url for vul_item in self.vulnerability_items]
|
|
95
|
-
return ", ".join(nvd_url)
|
|
96
|
-
|
|
97
|
-
def set_comment(self, value):
|
|
98
|
-
if self.comment:
|
|
99
|
-
self.comment = f"{self.comment} / {value}"
|
|
100
|
-
else:
|
|
101
|
-
self.comment = value
|
|
102
|
-
|
|
103
|
-
def set_bin_name(self, value):
|
|
104
|
-
self.bin_name = value
|
|
105
|
-
|
|
106
|
-
def set_exclude(self, value):
|
|
107
|
-
self.exclude = value
|
|
108
|
-
|
|
109
|
-
def set_checksum(self, value):
|
|
110
|
-
self.checksum = value
|
|
111
|
-
|
|
112
|
-
def set_tlsh(self, value):
|
|
113
|
-
self.tlsh = value
|
|
114
|
-
|
|
115
|
-
def get_comment(self):
|
|
116
|
-
return self.comment
|
|
117
|
-
|
|
118
|
-
def get_print_binary_only(self):
|
|
119
|
-
return (self.binary_strip_root + "\t" + self.checksum + "\t" + self.tlsh)
|
|
120
|
-
|
|
121
|
-
def get_oss_report(self):
|
|
122
|
-
comment = ""
|
|
123
|
-
if len(self.oss_items) > 0:
|
|
124
|
-
for oss in self.oss_items:
|
|
125
|
-
exclude = _EXCLUDE_TRUE_VALUE if (self.exclude or oss.exclude) else ""
|
|
126
|
-
nvd_url = self.get_vulnerability_items()
|
|
127
|
-
|
|
128
|
-
if self.comment:
|
|
129
|
-
if oss.comment:
|
|
130
|
-
comment = f"{self.comment} / {oss.comment}"
|
|
131
|
-
else:
|
|
132
|
-
comment = self.comment
|
|
133
|
-
else:
|
|
134
|
-
comment = oss.comment
|
|
135
|
-
|
|
136
|
-
yield [self.binary_strip_root, oss.name, oss.version,
|
|
137
|
-
oss.license, oss.dl_url, '', '', exclude, comment,
|
|
138
|
-
nvd_url, self.tlsh, self.checksum]
|
|
139
|
-
else:
|
|
140
|
-
exclude = _EXCLUDE_TRUE_VALUE if self.exclude else ""
|
|
141
|
-
yield [self.binary_strip_root, '',
|
|
142
|
-
'', '', '', '', '', exclude, self.comment, '', self.tlsh, self.checksum]
|
|
143
|
-
|
|
144
|
-
def set_checksum_tlsh(self):
|
|
145
|
-
self.checksum, self.tlsh, error, msg = get_checksum_and_tlsh(
|
|
146
|
-
self.bin_name)
|
|
147
|
-
return error, msg
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
def get_checksum_and_tlsh(bin_with_path):
|
|
151
|
-
checksum_value = _TLSH_CHECKSUM_NULL
|
|
152
|
-
tlsh_value = _TLSH_CHECKSUM_NULL
|
|
153
|
-
error_msg = ""
|
|
154
|
-
error = False
|
|
155
|
-
try:
|
|
156
|
-
f = open(bin_with_path, "rb")
|
|
157
|
-
byte = f.read()
|
|
158
|
-
sha1_hash = hashlib.sha1(byte)
|
|
159
|
-
checksum_value = str(sha1_hash.hexdigest())
|
|
160
|
-
try:
|
|
161
|
-
tlsh_value = str(tlsh.hash(byte))
|
|
162
|
-
except:
|
|
163
|
-
tlsh_value = _TLSH_CHECKSUM_NULL
|
|
164
|
-
f.close()
|
|
165
|
-
except Exception as ex:
|
|
166
|
-
error_msg = f"(Error) Get_checksum, tlsh: {ex}"
|
|
167
|
-
error = True
|
|
168
|
-
return checksum_value, tlsh_value, error, error_msg
|
|
File without changes
|
|
File without changes
|
{fosslight_binary-4.1.32 → fosslight_binary-5.0.0}/LICENSES/LicenseRef-3rd_party_licenses.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fosslight_binary-4.1.32 → fosslight_binary-5.0.0}/src/fosslight_binary.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{fosslight_binary-4.1.32 → fosslight_binary-5.0.0}/src/fosslight_binary.egg-info/entry_points.txt
RENAMED
|
File without changes
|
{fosslight_binary-4.1.32 → fosslight_binary-5.0.0}/src/fosslight_binary.egg-info/top_level.txt
RENAMED
|
File without changes
|