From b07eef109a118506f9d1d67612f318db1cfc1629 Mon Sep 17 00:00:00 2001 From: Matthias Veit Date: Tue, 5 Dec 2023 15:29:39 +0100 Subject: [PATCH] [resotocore][fix] Quote account ids (#1847) --- resotocore/resotocore/db/graphdb.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/resotocore/resotocore/db/graphdb.py b/resotocore/resotocore/db/graphdb.py index bfe01c7dfc..4a8a2b08a7 100644 --- a/resotocore/resotocore/db/graphdb.py +++ b/resotocore/resotocore/db/graphdb.py @@ -473,7 +473,8 @@ async def update_security_section( model: Model, accounts: Optional[List[str]] = None, ) -> Tuple[int, int]: # inserted, updated - log.info(f"Update security section. run_id={report_run_id} for accounts={accounts}") + accounts_list = accounts or [] + log.info(f"Update security section. run_id={report_run_id} for accounts={accounts_list}") temp_collection = await self.get_tmp_collection(report_run_id) now = utc_str() nodes_vulnerable_new = 0 @@ -537,7 +538,8 @@ async def update_chunk(chunk: Dict[NodeId, Json]) -> None: async def move_security_temp_to_proper() -> None: temp_name = temp_collection.name - account_filter = ("and e.refs.account_id in [" + ",".join(accounts) + "]") if accounts else "" + accounts_quoted = ",".join(f'"{acc}"' for acc in accounts_list) + account_filter = f"and e.refs.account_id in [{accounts_quoted}]" if accounts else "" aql_updates = [ # Select all new or updated vulnerable nodes. Insert into history and update vertex. f'for e in {temp_name} filter e.action=="node_vulnerable" insert e.data in {self.node_history} update {{_key: e.node_id, security: e.data.security}} in {self.vertex_name} OPTIONS {{mergeObjects: false}}', # noqa