From 68f4767449dee429964ac8f1a1f7bbaba709169a Mon Sep 17 00:00:00 2001 From: Wonjae Park Date: Mon, 25 Mar 2024 13:21:27 +0900 Subject: [PATCH] Check notice file name for scancode Signed-off-by: Wonjae Park --- src/fosslight_source/_parsing_scancode_file_item.py | 3 ++- src/fosslight_source/_scan_item.py | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/fosslight_source/_parsing_scancode_file_item.py b/src/fosslight_source/_parsing_scancode_file_item.py index 5cdb31e..930bf0c 100755 --- a/src/fosslight_source/_parsing_scancode_file_item.py +++ b/src/fosslight_source/_parsing_scancode_file_item.py @@ -12,6 +12,7 @@ from ._scan_item import is_exclude_dir from ._scan_item import is_exclude_file from ._scan_item import replace_word +from ._scan_item import is_notice_file logger = logging.getLogger(constant.LOGGER_NAME) _exclude_directory = ["test", "tests", "doc", "docs"] @@ -265,7 +266,7 @@ def parsing_scancode_32_later(scancode_file_list, has_error=False): result_item.comment = license_expression result_item.exclude = is_exclude_file(file_path) - result_item.is_license_text = file.get("percentage_of_license_text", 0) > 90 + result_item.is_license_text = file.get("percentage_of_license_text", 0) > 90 or is_notice_file(file_path) scancode_file_item.append(result_item) except Exception as ex: msg.append(f"Error Parsing item: {ex}") diff --git a/src/fosslight_source/_scan_item.py b/src/fosslight_source/_scan_item.py index 5a42db3..5ccac7c 100644 --- a/src/fosslight_source/_scan_item.py +++ b/src/fosslight_source/_scan_item.py @@ -5,10 +5,14 @@ import os import logging +import re import fosslight_util.constant as constant logger = logging.getLogger(constant.LOGGER_NAME) replace_word = ["-only", "-old-style", "-or-later", "licenseref-scancode-", "licenseref-"] +_notice_filename = ['licen[cs]e[s]?', 'notice[s]?', 'legal', 'copyright[s]?', 'copying*', 'patent[s]?', 'unlicen[cs]e', 'eula', + '[a,l]?gpl[-]?[1-3]?[.,-,_]?[0-1]?', 'mit', 'bsd[-]?[0-4]?', 'bsd[-]?[0-4][-]?clause[s]?', + 'apache[-,_]?[1-2]?[.,-,_]?[0-2]?'] _exclude_filename = ["changelog", "config.guess", "config.sub", "changes", "ltmain.sh", "configure", "configure.ac", "depcomp", "compile", "missing", "makefile"] _exclude_extension = [".m4", ".in", ".po"] @@ -119,3 +123,10 @@ def is_exclude_file(file_path, prev_dir=None, prev_dir_exclude_value=None): else: # running SCANOSS return is_exclude_dir(dir_path) return False + + +def is_notice_file(file_path): + pattern = r"({})(?