From 41c36ff512a826cc078d4658423ec86da23a8d01 Mon Sep 17 00:00:00 2001 From: Jake Hunsaker Date: Tue, 15 Nov 2022 09:34:08 -0500 Subject: [openstack_instack] Refine regex matching for stack ids CodeQL highlighted on a potential issue on the regex used to extract stack IDs for collection iterations. Resolve this by refining the regex pattern to better match the stack IDs in the output. Related: #3066 Signed-off-by: Jake Hunsaker --- sos/report/plugins/openstack_instack.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sos/report/plugins/openstack_instack.py b/sos/report/plugins/openstack_instack.py index 5b4f7d41..582ced7b 100644 --- a/sos/report/plugins/openstack_instack.py +++ b/sos/report/plugins/openstack_instack.py @@ -81,16 +81,17 @@ class OpenStackInstack(Plugin): # capture all the possible stack uuids get_stacks = "openstack stack list" stacks = self.collect_cmd_output(get_stacks)['output'] - stack_ids = re.findall(r'(\s(\w+-\w+)+\s)', stacks) + stack_ids = re.findall(r'(\|\s(((\w+-){4})\w+)\s\|)', stacks) # get status of overcloud stack and resources - for sid in stack_ids: + for _sid in stack_ids: + sid = _sid[1] self.add_cmd_output([ - "openstack stack show %s" % sid[0], - "openstack stack resource list -n 10 %s" % sid[0] + "openstack stack show %s" % sid, + "openstack stack resource list -n 10 %s" % sid ]) # get details on failed deployments - cmd = "openstack stack resource list -f value -n 5 %s" % sid[0] + cmd = "openstack stack resource list -f value -n 5 %s" % sid deployments = self.exec_cmd(cmd) for deployment in deployments['output'].splitlines(): if 'FAILED' in deployment: -- cgit