From 2c13fc5f6df704989a36573e582252a58278a330 Mon Sep 17 00:00:00 2001 From: Pascal Dengler Date: Mon, 27 Feb 2023 12:37:43 +0100 Subject: [PATCH] Make sure list is not empty --- CybORG/Agents/Wrappers/RedTableWrapper.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CybORG/Agents/Wrappers/RedTableWrapper.py b/CybORG/Agents/Wrappers/RedTableWrapper.py index 3988136b..12931265 100644 --- a/CybORG/Agents/Wrappers/RedTableWrapper.py +++ b/CybORG/Agents/Wrappers/RedTableWrapper.py @@ -128,7 +128,9 @@ def _process_exploit(self, obs): def _process_priv_esc(self, obs, hostname): if obs['success'] == False: - [info for info in self.red_info.values() if info[2] == hostname][0][4] = 'None' + red_info = [info for info in self.red_info.values() if info[2] == hostname] + if len(red_info) > 0: + red_info[0][4] = 'None' else: for hostid in obs: if hostid == 'success':