From 443030f45ad229fda45df20bd13309d31bf31390 Mon Sep 17 00:00:00 2001 From: jfuller Date: Mon, 22 Jan 2024 11:47:17 +0100 Subject: [PATCH] fix regex search --- griffon/output.py | 7 +------ griffon/services/core_queries.py | 5 ++--- scripts/smoke-tests.sh | 9 +++++++-- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/griffon/output.py b/griffon/output.py index 1bb74f7..803f8d6 100644 --- a/griffon/output.py +++ b/griffon/output.py @@ -440,12 +440,7 @@ def text_output_products_contain_component( ) ctx.exit() - # if -r option used we need to escape it - search_component_name = ( - re.escape(ctx.params["component_name"]) - if not ctx.obj["REGEX_NAME_SEARCH"] - else ctx.params["component_name"] - ) + search_component_name = ctx.params["component_name"] # handle multiple components if "results" in output and output["count"] > 0: diff --git a/griffon/services/core_queries.py b/griffon/services/core_queries.py index 58a7c4a..b66b4ce 100644 --- a/griffon/services/core_queries.py +++ b/griffon/services/core_queries.py @@ -339,9 +339,7 @@ def execute(self, status=None) -> List[Dict[str, Any]]: "include_fields": "purl,type,name,related_url,namespace,software_build,nvr,release,version,arch,product_streams.product_versions,product_streams.name,product_streams.ofuri,product_streams.active,product_streams.exclude_components,product_streams.relations", # noqa } - component_name = ( - re.escape(self.component_name) if not self.regex_name_search else self.component_name - ) + component_name = self.component_name if self.search_latest: search_latest_params = copy.deepcopy(params) @@ -427,6 +425,7 @@ def execute(self, status=None) -> List[Dict[str, Any]]: latest_components, ): results.append(processed_component) + if not self.no_community: status.update("searching latest community provided child component(s).") community_component_cnt = self.community_session.components.count( diff --git a/scripts/smoke-tests.sh b/scripts/smoke-tests.sh index 73582af..7be7283 100755 --- a/scripts/smoke-tests.sh +++ b/scripts/smoke-tests.sh @@ -16,9 +16,10 @@ griffon service product-manifest ansible_automation_platform-2.2 griffon service product-summary ansible_automation_platform-2.2 griffon service products-affected-by-flaw CVE-2023-25166 -griffon --format text service products-contain-component "^webkitgtk(\d)$" +griffon --format text service products-contain-component -r "^webkitgtk(\d)$" griffon --format text service components-affected-by-flaw CVE-2023-25166 -griffon --format text service products-contain-component nmap +griffon --format text service products-contain-component -s nmap +# should fail griffon service products-contain-component --purl "pkg:rpm/curl@7.29.0" griffon service products-contain-component webkitgtk --search-related-url --search-latest --search-all @@ -81,4 +82,8 @@ griffon service component-flaws python-marshmallow --affectedness AFFECTED griffon service products-contain-component --search-all --search-upstreams -s libxml2 -a griffon service products-contain-component -s grep -v --search-all griffon service products-contain-component -r 'webkit.tk' -vv +griffon service products-contain-component -r "webkitgtk(3|100)" --search-all griffon service products-contain-component webkitgtk4-jsc --include-product-streams-excluded-components --include-inactive-product-streams --no-community --no-filter-rh-naming -vv + +griffon service products-contain-component -s bind-libs-lite --search-all +griffon service products-contain-component v2v-conversion-host-ansible -vvv --include-container-roots --include-inactive-product-streams --include-product-streams-excluded-components --no-filter-rh-naming