Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

Commit

Permalink
fix regex search
Browse files Browse the repository at this point in the history
  • Loading branch information
JimFuller-RedHat committed Jan 22, 2024
1 parent 5ddeafe commit 8e0c000
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
7 changes: 1 addition & 6 deletions griffon/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 4 additions & 3 deletions griffon/services/core_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,9 @@ 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 not self.strict_name_search and not self.regex_name_search:
component_name = re.escape(component_name)

if self.search_latest:
search_latest_params = copy.deepcopy(params)
Expand Down Expand Up @@ -427,6 +427,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(
Expand Down
12 changes: 10 additions & 2 deletions scripts/smoke-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]"

griffon service products-contain-component webkitgtk --search-related-url --search-latest --search-all
Expand Down Expand Up @@ -81,4 +82,11 @@ 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
griffon service products-contain-component 'compat-sap-c++-12'
griffon service products-contain-component -r 'compat-sap-c++-12'
griffon service products-contain-component -s 'compat-sap-c++-12'

0 comments on commit 8e0c000

Please sign in to comment.