Skip to content

Commit

Permalink
Add TLSH, Checksum column at report
Browse files Browse the repository at this point in the history
  • Loading branch information
bjk7119 committed Mar 26, 2024
1 parent f9ad084 commit c8cf1e9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
fosslight_util>=1.4.28
fosslight_util>=1.4.38
binaryornot
openpyxl
pandas
Expand Down
7 changes: 5 additions & 2 deletions src/fosslight_yocto/_package_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
const_other_proprietary_license = 'other proprietary license'
EXCLUDE_TRUE_VALUE = "Exclude"
IGNORE_COPYRIGHT = "NOASSERTION"
_TLSH_CHECKSUM_NULL = "0"


class PackageItem(OssItem):
Expand All @@ -32,6 +33,8 @@ def __init__(self):
self._yocto_package = []
self.relative_path = ""
self.additional_data = {}
self.tlsh = _TLSH_CHECKSUM_NULL
self.checksum = _TLSH_CHECKSUM_NULL

def __eq__(self, value):
return self.spdx_id == value
Expand Down Expand Up @@ -188,8 +191,8 @@ def get_print_item(self, bin_android_format=False, additional_column=[]):
license_to_print = self.declared_licenses
if bin_android_format: # BIN(Yocto) Sheet
row = [self.parent_package_name, self.oss_name, "", self.name, self.version,
','.join(license_to_print),
self.download_location, self.homepage, self.copyright, exclude, self.comment]
','.join(license_to_print), self.download_location, self.homepage,
self.copyright, exclude, self.comment, self.tlsh, self.checksum]
for column_name in additional_column:
row.append(self.additional_data.get(column_name, ''))
print_items.append(row)
Expand Down
7 changes: 5 additions & 2 deletions src/fosslight_yocto/_write_result_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@
import logging
import fosslight_util.constant as constant
from fosslight_util.output_format import write_output_file
from fosslight_util.write_excel import hide_column


logger = logging.getLogger(constant.LOGGER_NAME)
OUTPUT_FILE_EXTENSION = ".xlsx"
HIDDEN_HEADER = ['TLSH', 'SHA1']


def write_result_from_bom(out_file_name, installed_packages_src, installed_packages_bin,
bin_android_mode=False, output_extension="", additional_column=[]):
SHEET_HEADER = {'BIN (Yocto)': ['ID', 'Binary Name', 'Source Code Path',
'NOTICE.html', 'OSS Name', 'OSS Version',
'License', 'Download Location', 'Homepage',
'Copyright Text', 'Exclude', 'Comment'],
'Copyright Text', 'Exclude', 'Comment', 'TLSH', 'SHA1'],
'SRC': ['ID', 'Source Name or Path', 'OSS Name', 'OSS Version',
'License', 'Download Location', 'Homepage', 'Copyright Text',
'Exclude', 'Comment'],
Expand All @@ -43,7 +45,8 @@ def write_result_from_bom(out_file_name, installed_packages_src, installed_packa
sheet_list["BIN"] = list_bin_to_print

logger.debug(f"FILE:{out_file_name}{output_extension}")
success_to_write, writing_msg, result_file = write_output_file(out_file_name, output_extension, sheet_list, SHEET_HEADER)
success_to_write, writing_msg, result_file = write_output_file(out_file_name, output_extension, sheet_list,
SHEET_HEADER, HIDDEN_HEADER)

if success_to_write:
logger.info(f"Output file :{result_file}")
Expand Down
2 changes: 2 additions & 0 deletions src/fosslight_yocto/create_oss_report_for_yocto.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,8 @@ def get_binary_list(buildhistory_package_files, path_to_find, output_txt):
pkg_item = PackageItem()
pkg_item = update_package_name(pkg_item, pkg_name, _nested_pkg_name)
pkg_item.source_name_or_path = file_rel_path
pkg_item.tlsh = tlsh
pkg_item.checksum = checksum
if pkg_name != "" and pkg_name in bom_pkg_data:
for key, value in bom_pkg_data[pkg_name].items():
set_value_switch(pkg_item, key, value, _nested_pkg_name)
Expand Down

0 comments on commit c8cf1e9

Please sign in to comment.