Skip to content

Commit

Permalink
[resotocore][fix] Quote account ids (#1847)
Browse files Browse the repository at this point in the history
  • Loading branch information
aquamatthias authored Dec 5, 2023
1 parent b8fa776 commit b07eef1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions resotocore/resotocore/db/graphdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b07eef1

Please sign in to comment.