fosslight-binary 5.1.8__tar.gz → 5.1.9__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-5.1.8 → fosslight_binary-5.1.9}/PKG-INFO +1 -1
- {fosslight_binary-5.1.8 → fosslight_binary-5.1.9}/setup.py +1 -1
- {fosslight_binary-5.1.8 → fosslight_binary-5.1.9}/src/fosslight_binary/_binary.py +18 -5
- {fosslight_binary-5.1.8 → fosslight_binary-5.1.9}/src/fosslight_binary/_jar_analysis.py +40 -29
- {fosslight_binary-5.1.8 → fosslight_binary-5.1.9}/src/fosslight_binary/binary_analysis.py +10 -3
- {fosslight_binary-5.1.8 → fosslight_binary-5.1.9}/src/fosslight_binary.egg-info/PKG-INFO +1 -1
- {fosslight_binary-5.1.8 → fosslight_binary-5.1.9}/LICENSE +0 -0
- {fosslight_binary-5.1.8 → fosslight_binary-5.1.9}/LICENSES/Apache-2.0.txt +0 -0
- {fosslight_binary-5.1.8 → fosslight_binary-5.1.9}/LICENSES/LicenseRef-3rd_party_licenses.txt +0 -0
- {fosslight_binary-5.1.8 → fosslight_binary-5.1.9}/MANIFEST.in +0 -0
- {fosslight_binary-5.1.8 → fosslight_binary-5.1.9}/README.md +0 -0
- {fosslight_binary-5.1.8 → fosslight_binary-5.1.9}/requirements.txt +0 -0
- {fosslight_binary-5.1.8 → fosslight_binary-5.1.9}/setup.cfg +0 -0
- {fosslight_binary-5.1.8 → fosslight_binary-5.1.9}/src/fosslight_binary/LICENSES/LICENSE +0 -0
- {fosslight_binary-5.1.8 → fosslight_binary-5.1.9}/src/fosslight_binary/LICENSES/LicenseRef-3rd_party_licenses.txt +0 -0
- {fosslight_binary-5.1.8 → fosslight_binary-5.1.9}/src/fosslight_binary/__init__.py +0 -0
- {fosslight_binary-5.1.8 → fosslight_binary-5.1.9}/src/fosslight_binary/_binary_dao.py +0 -0
- {fosslight_binary-5.1.8 → fosslight_binary-5.1.9}/src/fosslight_binary/_help.py +0 -0
- {fosslight_binary-5.1.8 → fosslight_binary-5.1.9}/src/fosslight_binary/_simple_mode.py +0 -0
- {fosslight_binary-5.1.8 → fosslight_binary-5.1.9}/src/fosslight_binary/cli.py +0 -0
- {fosslight_binary-5.1.8 → fosslight_binary-5.1.9}/src/fosslight_binary.egg-info/SOURCES.txt +0 -0
- {fosslight_binary-5.1.8 → fosslight_binary-5.1.9}/src/fosslight_binary.egg-info/dependency_links.txt +0 -0
- {fosslight_binary-5.1.8 → fosslight_binary-5.1.9}/src/fosslight_binary.egg-info/entry_points.txt +0 -0
- {fosslight_binary-5.1.8 → fosslight_binary-5.1.9}/src/fosslight_binary.egg-info/requires.txt +0 -0
- {fosslight_binary-5.1.8 → fosslight_binary-5.1.9}/src/fosslight_binary.egg-info/top_level.txt +0 -0
- {fosslight_binary-5.1.8 → fosslight_binary-5.1.9}/tests/test_fosslight_binary.py +0 -0
|
@@ -2,14 +2,18 @@
|
|
|
2
2
|
# -*- coding: utf-8 -*-
|
|
3
3
|
# Copyright (c) 2020 LG Electronics Inc.
|
|
4
4
|
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
|
|
5
|
+
import os
|
|
6
6
|
import urllib.parse
|
|
7
7
|
import logging
|
|
8
8
|
import fosslight_util.constant as constant
|
|
9
|
+
from typing import Tuple
|
|
10
|
+
from fosslight_util.oss_item import FileItem
|
|
9
11
|
|
|
10
12
|
EXCLUDE_TRUE_VALUE = "Exclude"
|
|
11
13
|
TLSH_CHECKSUM_NULL = "0"
|
|
12
14
|
MAX_EXCEL_URL_LENGTH = 255
|
|
15
|
+
EXCEEDED_VUL_URL_LENGTH_COMMENT = f"Exceeded the maximum vulnerability URL length of {MAX_EXCEL_URL_LENGTH} characters."
|
|
16
|
+
_PACKAGE_DIR = ["node_modules", "venv", "Pods", "Carthage"]
|
|
13
17
|
|
|
14
18
|
logger = logging.getLogger(constant.LOGGER_NAME)
|
|
15
19
|
|
|
@@ -54,12 +58,9 @@ class BinaryItem(FileItem):
|
|
|
54
58
|
nvd_url = ", ".join(nvd_url).strip()
|
|
55
59
|
|
|
56
60
|
if nvd_url and len(nvd_url) > MAX_EXCEL_URL_LENGTH:
|
|
57
|
-
oss.comment =
|
|
61
|
+
oss.comment = EXCEEDED_VUL_URL_LENGTH_COMMENT
|
|
58
62
|
return nvd_url
|
|
59
63
|
|
|
60
|
-
def get_print_binary_only(self):
|
|
61
|
-
return (self.source_name_or_path + "\t" + self.checksum + "\t" + self.tlsh)
|
|
62
|
-
|
|
63
64
|
def get_print_array(self):
|
|
64
65
|
items = []
|
|
65
66
|
if self.oss_items:
|
|
@@ -110,3 +111,15 @@ class BinaryItem(FileItem):
|
|
|
110
111
|
if self.comment:
|
|
111
112
|
json_item["comment"] = self.comment
|
|
112
113
|
return items
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def is_package_dir(bin_with_path: str, _root_path: str) -> Tuple[bool, str]:
|
|
117
|
+
is_pkg = False
|
|
118
|
+
pkg_path = ""
|
|
119
|
+
path_parts = bin_with_path.split(os.path.sep)
|
|
120
|
+
for pkg_dir in _PACKAGE_DIR:
|
|
121
|
+
if pkg_dir in path_parts:
|
|
122
|
+
pkg_index = path_parts.index(pkg_dir)
|
|
123
|
+
pkg_path = os.path.sep.join(path_parts[:pkg_index + 1]).replace(_root_path, '', 1)
|
|
124
|
+
is_pkg = True
|
|
125
|
+
return is_pkg, pkg_path
|
|
@@ -8,7 +8,7 @@ import json
|
|
|
8
8
|
import os
|
|
9
9
|
import sys
|
|
10
10
|
import fosslight_util.constant as constant
|
|
11
|
-
from ._binary import BinaryItem, VulnerabilityItem
|
|
11
|
+
from ._binary import BinaryItem, VulnerabilityItem, is_package_dir
|
|
12
12
|
from fosslight_util.oss_item import OssItem
|
|
13
13
|
from dependency_check import run as dependency_check_run
|
|
14
14
|
|
|
@@ -57,29 +57,42 @@ def get_oss_lic_in_jar(data):
|
|
|
57
57
|
return license
|
|
58
58
|
|
|
59
59
|
|
|
60
|
+
def merge_oss_and_vul_items(bin, key, oss_list, vulnerability_items):
|
|
61
|
+
bin.set_oss_items(oss_list)
|
|
62
|
+
if vulnerability_items and vulnerability_items.get(key):
|
|
63
|
+
bin.vulnerability_items.extend(vulnerability_items.get(key, []))
|
|
64
|
+
|
|
65
|
+
|
|
60
66
|
def merge_binary_list(owasp_items, vulnerability_items, bin_list):
|
|
61
67
|
not_found_bin = []
|
|
62
68
|
|
|
63
|
-
# key : file_path / value : oss_list for one binary
|
|
69
|
+
# key : file_path / value : {"oss_list": [oss], "sha1": sha1} for one binary
|
|
64
70
|
for key, value in owasp_items.items():
|
|
65
71
|
found = False
|
|
72
|
+
oss_list = value["oss_list"]
|
|
73
|
+
sha1 = value.get("sha1", "")
|
|
66
74
|
for bin in bin_list:
|
|
67
75
|
if bin.source_name_or_path == key:
|
|
68
|
-
|
|
76
|
+
found = True
|
|
77
|
+
for oss in oss_list:
|
|
69
78
|
if oss.name and oss.license:
|
|
70
79
|
bin.found_in_owasp = True
|
|
71
80
|
break
|
|
72
|
-
bin
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
break
|
|
81
|
+
merge_oss_and_vul_items(bin, key, oss_list, vulnerability_items)
|
|
82
|
+
else:
|
|
83
|
+
if bin.checksum == sha1:
|
|
84
|
+
merge_oss_and_vul_items(bin, key, oss_list, vulnerability_items)
|
|
77
85
|
|
|
78
86
|
if not found:
|
|
79
87
|
bin_item = BinaryItem(os.path.abspath(key))
|
|
80
88
|
bin_item.binary_name_without_path = os.path.basename(key)
|
|
81
89
|
bin_item.source_name_or_path = key
|
|
82
|
-
|
|
90
|
+
|
|
91
|
+
is_pkg, _ = is_package_dir(bin_item.source_name_or_path, '')
|
|
92
|
+
if is_pkg:
|
|
93
|
+
continue
|
|
94
|
+
|
|
95
|
+
bin_item.set_oss_items(oss_list)
|
|
83
96
|
not_found_bin.append(bin_item)
|
|
84
97
|
|
|
85
98
|
bin_list += not_found_bin
|
|
@@ -192,7 +205,8 @@ def analyze_jar_file(path_to_find_bin, path_to_exclude):
|
|
|
192
205
|
success = False
|
|
193
206
|
return owasp_items, vulnerability_items, success
|
|
194
207
|
|
|
195
|
-
dependencies = jar_contents.get("dependencies")
|
|
208
|
+
dependencies = jar_contents.get("dependencies", [])
|
|
209
|
+
|
|
196
210
|
try:
|
|
197
211
|
for val in dependencies:
|
|
198
212
|
bin_with_path = ""
|
|
@@ -204,6 +218,8 @@ def analyze_jar_file(path_to_find_bin, path_to_exclude):
|
|
|
204
218
|
oss_license = get_oss_lic_in_jar(val)
|
|
205
219
|
oss_name_found = False
|
|
206
220
|
|
|
221
|
+
sha1 = val.get("sha1", "")
|
|
222
|
+
|
|
207
223
|
all_evidence = val.get("evidenceCollected", {})
|
|
208
224
|
vulnerability = val.get("vulnerabilityIds", [])
|
|
209
225
|
all_pkg_info = val.get("packages", [])
|
|
@@ -259,31 +275,26 @@ def analyze_jar_file(path_to_find_bin, path_to_exclude):
|
|
|
259
275
|
# Get Vulnerability Info.
|
|
260
276
|
vulnerability_items = get_vulnerability_info(file_with_path, vulnerability, vulnerability_items, remove_vulnerability_items)
|
|
261
277
|
|
|
262
|
-
if oss_name
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
existing_oss = None
|
|
266
|
-
for item in oss_list_for_file:
|
|
267
|
-
if item.name == oss_name and item.version == oss_ver:
|
|
268
|
-
existing_oss = item
|
|
269
|
-
break
|
|
270
|
-
|
|
271
|
-
if not existing_oss:
|
|
272
|
-
oss = OssItem(oss_name, oss_ver, oss_license, oss_dl_url)
|
|
273
|
-
oss.comment = "OWASP result"
|
|
278
|
+
if oss_name or oss_license or oss_dl_url:
|
|
279
|
+
oss = OssItem(oss_name, oss_ver, oss_license, oss_dl_url)
|
|
280
|
+
oss.comment = "OWASP result"
|
|
274
281
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
282
|
+
if file_with_path in owasp_items:
|
|
283
|
+
owasp_items[file_with_path]["oss_list"].append(oss)
|
|
284
|
+
# Update sha1 if not already set or if current sha1 is empty
|
|
285
|
+
if not owasp_items[file_with_path]["sha1"] and sha1:
|
|
286
|
+
owasp_items[file_with_path]["sha1"] = sha1
|
|
287
|
+
else:
|
|
288
|
+
owasp_items[file_with_path] = {
|
|
289
|
+
"oss_list": [oss],
|
|
290
|
+
"sha1": sha1
|
|
291
|
+
}
|
|
279
292
|
except Exception as ex:
|
|
280
|
-
logger.debug(f"Error to get
|
|
281
|
-
success = False
|
|
293
|
+
logger.debug(f"Error to get dependency Info in jar_contents: {ex}")
|
|
282
294
|
|
|
283
295
|
try:
|
|
284
296
|
if os.path.isfile(json_file):
|
|
285
297
|
os.remove(json_file)
|
|
286
298
|
except Exception as ex:
|
|
287
299
|
logger.debug(f"Error - There is no .json file : {ex}")
|
|
288
|
-
|
|
289
300
|
return owasp_items, vulnerability_items, success
|
|
@@ -16,7 +16,7 @@ from fosslight_util.set_log import init_log
|
|
|
16
16
|
import fosslight_util.constant as constant
|
|
17
17
|
from fosslight_util.output_format import check_output_formats_v2, write_output_file
|
|
18
18
|
from ._binary_dao import get_oss_info_from_db
|
|
19
|
-
from ._binary import BinaryItem, TLSH_CHECKSUM_NULL
|
|
19
|
+
from ._binary import BinaryItem, TLSH_CHECKSUM_NULL, is_package_dir
|
|
20
20
|
from ._jar_analysis import analyze_jar_file, merge_binary_list
|
|
21
21
|
from ._simple_mode import print_simple_mode, filter_binary, init_simple
|
|
22
22
|
from fosslight_util.correct import correct_with_yaml
|
|
@@ -165,8 +165,15 @@ def get_file_list(path_to_find, abs_path_to_exclude):
|
|
|
165
165
|
bin_with_path = os.path.join(root, file)
|
|
166
166
|
bin_item = BinaryItem(bin_with_path)
|
|
167
167
|
bin_item.binary_name_without_path = file
|
|
168
|
-
bin_item.source_name_or_path = bin_with_path.replace(
|
|
169
|
-
|
|
168
|
+
bin_item.source_name_or_path = bin_with_path.replace(_root_path, '', 1)
|
|
169
|
+
|
|
170
|
+
is_pkg, pkg_path = is_package_dir(bin_with_path, _root_path)
|
|
171
|
+
if is_pkg:
|
|
172
|
+
bin_item.source_name_or_path = pkg_path
|
|
173
|
+
if not any(x.source_name_or_path == bin_item.source_name_or_path for x in bin_list):
|
|
174
|
+
bin_item.exclude = True
|
|
175
|
+
bin_list.append(bin_item)
|
|
176
|
+
continue
|
|
170
177
|
|
|
171
178
|
if any(dir_name in dir_path for dir_name in _EXCLUDE_DIR):
|
|
172
179
|
bin_item.exclude = True
|
|
File without changes
|
|
File without changes
|
{fosslight_binary-5.1.8 → fosslight_binary-5.1.9}/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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fosslight_binary-5.1.8 → fosslight_binary-5.1.9}/src/fosslight_binary.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{fosslight_binary-5.1.8 → fosslight_binary-5.1.9}/src/fosslight_binary.egg-info/entry_points.txt
RENAMED
|
File without changes
|
{fosslight_binary-5.1.8 → fosslight_binary-5.1.9}/src/fosslight_binary.egg-info/requires.txt
RENAMED
|
File without changes
|
{fosslight_binary-5.1.8 → fosslight_binary-5.1.9}/src/fosslight_binary.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|