From 354231fc1dab895d43833703d1d7cc3f2aca8fa5 Mon Sep 17 00:00:00 2001 From: Matthew Brady Date: Fri, 30 Aug 2024 14:34:31 +0200 Subject: [PATCH] v1.0.9 - Minor semver check fix & SBOM encoding --- README.md | 2 +- pyproject.toml | 2 +- yocto_import_sbom/ConfigClass.py | 2 +- yocto_import_sbom/OEClass.py | 11 ++++++----- yocto_import_sbom/SBOMClass.py | 8 ++++---- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 10cadbb..c1e8671 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Synopsys Scan Yocto Script - bd_scan_yocto_via_sbom.py v1.0.8 +# Synopsys Scan Yocto Script - bd_scan_yocto_via_sbom.py v1.0.9 # PROVISION OF THIS SCRIPT This script is provided under the MIT license (see LICENSE file). diff --git a/pyproject.toml b/pyproject.toml index 9ba5b99..643bc71 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "bd_scan_yocto_via_sbom" -version = "1.0.8" +version = "1.0.9" authors = [ { name="Matthew Brady", email="mbrad@synopsys.com" }, ] diff --git a/yocto_import_sbom/ConfigClass.py b/yocto_import_sbom/ConfigClass.py index 884aa0a..223a657 100644 --- a/yocto_import_sbom/ConfigClass.py +++ b/yocto_import_sbom/ConfigClass.py @@ -132,7 +132,7 @@ def __init__(self): else: logging.basicConfig(level=loglevel) - logging.info("Black Duck Yocto scan via SBOM utility - v1.0.8") + logging.info("Black Duck Yocto scan via SBOM utility - v1.0.9") logging.info("SUPPLIED ARGUMENTS:") for arg in vars(args): logging.info(f"--{arg}={getattr(args, arg)}") diff --git a/yocto_import_sbom/OEClass.py b/yocto_import_sbom/OEClass.py index 2230d25..5b49273 100644 --- a/yocto_import_sbom/OEClass.py +++ b/yocto_import_sbom/OEClass.py @@ -261,7 +261,6 @@ def compare_recipes(self, conf, recipe, oe_recipe, best_oe_recipe): pref = False - ver = Recipe.filter_version_string(recipe.version) oe_ver = Recipe.filter_version_string(oe_recipe['pv']) if best_oe_recipe != {}: best_oe_ver = Recipe.filter_version_string(best_oe_recipe['pv']) @@ -271,17 +270,19 @@ def compare_recipes(self, conf, recipe, oe_recipe, best_oe_recipe): if oe_ver == best_oe_ver: oe_ver_equal = True - if ver != best_oe_ver: - if ver == oe_ver: + if recipe.version != best_oe_ver: + if recipe.version == oe_ver: pref = True else: - semver, rest = self.coerce_version(ver) + semver, rest = self.coerce_version(recipe.version) oe_semver, oe_rest = self.coerce_version(oe_ver) best_oe_semver, best_oe_rest = self.coerce_version(best_oe_ver) if semver is not None and oe_semver is not None and oe_semver <= semver: if self.check_semver_distance(conf, semver, oe_semver): if best_oe_semver is not None: if oe_semver == best_oe_semver: + if len(oe_ver) < len(best_oe_ver): + pref = True oe_ver_equal = True elif semver >= oe_semver > best_oe_semver: if (semver.major - best_oe_semver.major) > (semver.major - oe_semver.major): @@ -318,7 +319,7 @@ def compare_recipes(self, conf, recipe, oe_recipe, best_oe_recipe): pref = True if pref: - return True, (ver == oe_ver) + return True, (recipe.version == oe_ver) except Exception as e: logging.error(f"Error in compare_recipes(): {e}") return False, False diff --git a/yocto_import_sbom/SBOMClass.py b/yocto_import_sbom/SBOMClass.py index d40cb98..7b2c221 100644 --- a/yocto_import_sbom/SBOMClass.py +++ b/yocto_import_sbom/SBOMClass.py @@ -153,7 +153,7 @@ def output(self, output_file): @staticmethod def filter_special_chars(val): - return val - # newval = val.replace(':', '%3A') - # newval = newval.replace('+', '%2B') - # return newval + # return val + newval = val.replace(':', '%3A') + newval = newval.replace('+', '%2B') + return newval