Skip to content

Commit 907d01d

Browse files
authored
Merge branch 'main' into develop
2 parents 8bc9408 + 87f5b81 commit 907d01d

File tree

13 files changed

+185
-166
lines changed

13 files changed

+185
-166
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
commit = True
33
tag = False
44
message = Bump version: {current_version} → {new_version}
5-
current_version = 1.6.9
5+
current_version = 1.6.10
66

77
[bumpversion:file:setup.py]
88
search = '{current_version}'

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
# Changelog
22

3+
## v1.6.10 (02/06/2022)
4+
## Changes
5+
- Amend how to handle path without files to scan for SCANOSS @JustinWonjaePark (#73)
6+
- Refine license name on SCANOSS results @JustinWonjaePark (#74)
7+
8+
## 🚀 Features
9+
10+
- Print SCANOSS info in a separate sheet @JustinWonjaePark (#72)
11+
- Add Dockerfile to build on ubuntu @soimkim (#69)
12+
13+
## 🐛 Hotfixes
14+
15+
- Fix cli.py to remove redundant report @JustinWonjaePark (#71)
16+
17+
---
18+
319
## v1.6.9 (06/04/2022)
420
## Changes
521
## 🐛 Hotfixes

Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright (c) 2021 LG Electronics Inc.
2+
# SPDX-License-Identifier: Apache-2.0
3+
FROM ubuntu:20.04
4+
5+
RUN apt-get update && apt-get install sudo -y
6+
RUN ln -sf /bin/bash /bin/sh
7+
8+
COPY . /app
9+
WORKDIR /app
10+
11+
ENV DEBIAN_FRONTEND=noninteractive
12+
13+
RUN apt-get -y install build-essential
14+
RUN apt-get -y install python3 python3-distutils python3-pip python3-dev
15+
RUN apt-get -y install python3-intbitset python3-magic
16+
RUN apt-get -y install libxml2-dev
17+
RUN apt-get -y install libxslt1-dev
18+
RUN apt-get -y install libhdf5-dev
19+
RUN apt-get -y install bzip2 xz-utils zlib1g libpopt0
20+
RUN apt-get -y install gcc-10 g++-10
21+
RUN pip3 install --upgrade pip
22+
RUN pip3 install .
23+
RUN pip3 install dparse
24+
25+
ENTRYPOINT ["/usr/local/bin/fosslight_source"]

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pyparsing<=3.0.4;python_full_version<"3.6.8"
22
scancode-toolkit
3-
typecode_libmagic
43
XlsxWriter
4+
typecode-libmagic-from-sources
55
fosslight_util>=1.3.21
66
PyYAML
77
wheel

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
if __name__ == "__main__":
1515
setup(
1616
name='fosslight_source',
17-
version='1.6.9',
17+
version='1.6.10',
1818
package_dir={"": "src"},
1919
packages=find_packages(where='src'),
2020
description='FOSSLight Source Scanner',

src/fosslight_source/_help.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
-h\t\t\t\t Print help message
2222
-v\t\t\t\t Print FOSSLight Source Scanner version
2323
-j\t\t\t\t Generate raw result of scanners in json format
24-
-m\t\t\t\t Print the Matched text for each license on a separate sheet (Scancode Only)
24+
-m\t\t\t\t Print additional information for scan result on separate sheets
2525
-o <output_path>\t\t Output path
2626
\t\t\t\t (If you want to generate the specific file name, add the output path with file name.)
2727
-f <format>\t\t\t Output file format (excel, csv, opossum, yaml)

src/fosslight_source/_parsing_scancode_file_item.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ def parsing_file_item(scancode_file_list, has_error, need_matched_license=False)
7474
error_msg = file["scan_errors"]
7575
if len(error_msg) > 0:
7676
logger.debug(f"Test_msg {file_path}:{error_msg}")
77-
result_item.set_comment(",".join(error_msg))
77+
result_item.comment = ",".join(error_msg)
7878
scancode_file_item.append(result_item)
7979
continue
8080

8181
copyright_value_list = [x["value"] for x in copyright_list]
82-
result_item.set_copyright(copyright_value_list)
82+
result_item.copyright = copyright_value_list
8383

8484
# Set the license value
8585
license_detected = []
@@ -137,19 +137,18 @@ def parsing_file_item(scancode_file_list, has_error, need_matched_license=False)
137137

138138
matched_rule = lic_item["matched_rule"]
139139
if matched_rule["is_license_text"]:
140-
result_item.set_is_license_text(True)
140+
result_item.is_license_text = True
141141

142142
if len(license_detected) > 0:
143-
result_item.set_licenses(license_detected)
143+
result_item.licenses = license_detected
144144

145145
if len(license_expression_list) > 0:
146146
license_expression_list = list(
147147
set(license_expression_list))
148-
result_item.set_comment(
149-
','.join(license_expression_list))
148+
result_item.comment = ','.join(license_expression_list)
150149

151150
if is_exclude_file(file_path, prev_dir, prev_dir_value):
152-
result_item.set_exclude(True)
151+
result_item.exclude = True
153152
scancode_file_item.append(result_item)
154153

155154
except Exception as ex:

src/fosslight_source/_parsing_scanoss_file.py

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,28 @@
77
import fosslight_util.constant as constant
88
from ._scan_item import ScanItem
99
from ._scan_item import is_exclude_file
10+
from ._scan_item import replace_word
1011

1112
logger = logging.getLogger(constant.LOGGER_NAME)
13+
SCANOSS_INFO_HEADER = ['No', 'Source Name or Path', 'Component Declared', 'SPDX Tag',
14+
'File Header', 'License File', 'Scancode',
15+
'scanoss_matched_lines', 'scanoss_fileURL']
16+
17+
18+
def parsing_extraInfo(scanned_result):
19+
scanoss_extra_info = []
20+
for scan_item in scanned_result:
21+
license_w_source = scan_item.scanoss_reference
22+
if license_w_source:
23+
extra_item = [scan_item.file, ','.join(license_w_source['component_declared']),
24+
','.join(license_w_source['file_spdx_tag']),
25+
','.join(license_w_source['file_header']),
26+
','.join(license_w_source['license_file']),
27+
','.join(license_w_source['scancode']),
28+
scan_item.matched_lines, scan_item.fileURL]
29+
scanoss_extra_info.append(extra_item)
30+
scanoss_extra_info.insert(0, SCANOSS_INFO_HEADER)
31+
return scanoss_extra_info
1232

1333

1434
def parsing_scanResult(scanoss_report):
@@ -21,39 +41,49 @@ def parsing_scanResult(scanoss_report):
2141
continue
2242

2343
if 'component' in findings[0]:
24-
result_item.set_oss_name(findings[0]['component'])
44+
result_item.oss_name = findings[0]['component']
2545
if 'version' in findings[0]:
26-
result_item.set_oss_version(findings[0]['version'])
46+
result_item.oss_version = findings[0]['version']
2747
if 'url' in findings[0]:
28-
result_item.set_download_location(findings[0]['url'])
48+
result_item.download_location = findings[0]['url']
2949

3050
license_detected = []
51+
license_w_source = {"component_declared": [], "file_spdx_tag": [],
52+
"file_header": [], "license_file": [], "scancode": []}
3153
copyright_detected = []
3254
if 'licenses' in findings[0]:
3355
for license in findings[0]['licenses']:
34-
license_detected.append(license['name'].lower())
56+
57+
license_lower = license['name'].lower()
58+
for word in replace_word:
59+
if word in license_lower:
60+
license_lower = license_lower.replace(word, "")
61+
license_detected.append(license_lower)
62+
63+
if license['source'] not in license_w_source:
64+
license_w_source[license['source']] = []
65+
license_w_source[license['source']].append(license['name'])
3566
if len(license_detected) > 0:
36-
result_item.set_licenses(license_detected)
67+
result_item.licenses = license_detected
68+
result_item.scanoss_reference = license_w_source
3769
if 'copyrights' in findings[0]:
3870
for copyright in findings[0]['copyrights']:
3971
copyright_detected.append(copyright['name'])
4072
if len(copyright_detected) > 0:
41-
result_item.set_copyright(copyright_detected)
73+
result_item.copyright = copyright_detected
4274

4375
if is_exclude_file(file_path):
44-
result_item.set_exclude(True)
76+
result_item.exclude = True
4577

46-
if 'vendor' in findings[0]:
47-
result_item.set_vendor(findings[0]['vendor'])
4878
if 'file_url' in findings[0]:
49-
result_item.set_fileURL(findings[0]['file_url'])
79+
result_item.fileURL = findings[0]['file_url']
5080
if 'matched' in findings[0]:
5181
if 'lines' in findings[0]:
52-
result_item.set_matched_lines(f"{findings[0]['matched']} ({findings[0]['lines']})")
82+
result_item.matched_lines = f"{findings[0]['matched']} ({findings[0]['lines']})"
5383
else:
54-
result_item.set_matched_lines(f"{findings[0]['matched']}")
84+
result_item.matched_lines = f"{findings[0]['matched']}"
5585
elif 'lines' in findings[0]:
56-
result_item.set_matched_lines(f"({findings[0]['lines']})")
86+
result_item.matched_lines = f"({findings[0]['lines']})"
5787

5888
scanoss_file_item.append(result_item)
5989

src/fosslight_source/_scan_item.py

Lines changed: 23 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -22,71 +22,46 @@
2222

2323
class ScanItem:
2424
file = ""
25-
licenses = []
26-
copyright = ""
25+
scanoss_reference = {}
2726
exclude = False
2827
is_license_text = False
2928
oss_name = ""
3029
oss_version = ""
3130
download_location = ""
3231
matched_lines = ""
3332
fileURL = ""
34-
vendor = ""
3533
license_reference = ""
3634

3735
def __init__(self, value):
3836
self.file = value
39-
self.copyright = []
40-
self.licenses = []
37+
self._copyright = []
38+
self._licenses = []
4139
self.comment = ""
4240
self.exclude = False
4341
self.is_license_text = False
4442

4543
def __del__(self):
4644
pass
4745

48-
def set_comment(self, value):
49-
self.comment = value
46+
@property
47+
def copyright(self):
48+
return self._copyright
5049

51-
def set_file(self, value):
52-
self.file = value
53-
54-
def set_copyright(self, value):
55-
self.copyright.extend(value)
56-
if len(self.copyright) > 0:
57-
self.copyright = list(set(self.copyright))
58-
59-
def set_licenses(self, value):
60-
self.licenses.extend(value)
61-
if len(self.licenses) > 0:
62-
self.licenses = list(set(self.licenses))
63-
64-
def set_exclude(self, value):
65-
self.exclude = value
66-
67-
def set_is_license_text(self, value):
68-
self.is_license_text = value
50+
@copyright.setter
51+
def copyright(self, value):
52+
self._copyright.extend(value)
53+
if len(self._copyright) > 0:
54+
self._copyright = list(set(self._copyright))
6955

70-
def set_oss_name(self, value):
71-
self.oss_name = value
56+
@property
57+
def licenses(self):
58+
return self._licenses
7259

73-
def set_oss_version(self, value):
74-
self.oss_version = value
75-
76-
def set_download_location(self, value):
77-
self.download_location = value
78-
79-
def set_matched_lines(self, value):
80-
self.matched_lines = value
81-
82-
def set_fileURL(self, value):
83-
self.fileURL = value
84-
85-
def set_vendor(self, value):
86-
self.vendor = value
87-
88-
def set_license_reference(self, value):
89-
self.license_reference = value
60+
@licenses.setter
61+
def licenses(self, value):
62+
self._licenses.extend(value)
63+
if len(self._licenses) > 0:
64+
self._licenses = list(set(self._licenses))
9065

9166
def get_row_to_print(self):
9267
print_rows = [self.file, self.oss_name, self.oss_version, ','.join(self.licenses), self.download_location, "",
@@ -98,15 +73,13 @@ def get_row_to_print(self):
9873
def get_row_to_print_for_scanoss(self):
9974
print_rows = [self.file, self.oss_name, self.oss_version, ','.join(self.licenses), self.download_location, "",
10075
','.join(self.copyright),
101-
"Exclude" if self.exclude else "",
102-
self.comment, self.matched_lines, self.fileURL, self.vendor]
76+
"Exclude" if self.exclude else "", self.comment]
10377
return print_rows
10478

10579
def get_row_to_print_for_all_scanner(self):
10680
print_rows = [self.file, self.oss_name, self.oss_version, ','.join(self.licenses), self.download_location, "",
10781
','.join(self.copyright),
108-
"Exclude" if self.exclude else "",
109-
self.comment, self.license_reference, self.matched_lines, self.fileURL, self.vendor]
82+
"Exclude" if self.exclude else "", self.comment, self.license_reference]
11083
return print_rows
11184

11285
def merge_scan_item(self, other):
@@ -136,8 +109,8 @@ def merge_scan_item(self, other):
136109
self.matched_lines = other.matched_lines
137110
if not self.fileURL:
138111
self.fileURL = other.fileURL
139-
if not self.vendor:
140-
self.vendor = other.vendor
112+
if not self.scanoss_reference:
113+
self.scanoss_reference = other.scanoss_reference
141114

142115
def __eq__(self, other):
143116
return self.file == other.file

0 commit comments

Comments
 (0)