aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJake Hunsaker <jhunsake@redhat.com>2022-11-15 09:34:08 -0500
committerJake Hunsaker <jhunsake@redhat.com>2022-11-21 14:19:17 -0500
commit41c36ff512a826cc078d4658423ec86da23a8d01 (patch)
tree1ee4e358f1c5e508f3c43d9ef6c2bff246870cce
parent4be5ad213c4c6e7602b9dee0c948dd706ef4676c (diff)
downloadsos-41c36ff512a826cc078d4658423ec86da23a8d01.tar.gz
[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 <jhunsake@redhat.com>
-rw-r--r--sos/report/plugins/openstack_instack.py11
1 files 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: