From 1b81962c03b12b454b6047df97c75397cdc343b6 Mon Sep 17 00:00:00 2001 From: Ari Date: Thu, 25 Aug 2022 11:30:40 -0400 Subject: [PATCH] fixed sec --- api/src/automations/db.py | 6 +++--- api/src/automations/manager.py | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/api/src/automations/db.py b/api/src/automations/db.py index 9b6ab82..6f40485 100644 --- a/api/src/automations/db.py +++ b/api/src/automations/db.py @@ -101,7 +101,7 @@ class AutomationDBConnection: def get_automation(self, automation_id: str) -> ExtenededAutomation: with self.get_cur() as cur: cur.execute( - f'SELECT rest, source_file, source_file_type, configuration_key FROM {automations_tbl} WHERE id = "{automation_id}"' + f'SELECT rest, source_file, source_file_type, configuration_key FROM {automations_tbl} WHERE id = "{automation_id}"' # nosec ) objs = cur.fetchone() if objs is None: @@ -112,10 +112,10 @@ class AutomationDBConnection: def list_automations(self, offset: int, limit: int) -> Iterable[ExtenededAutomation]: with self.get_cur() as cur: for [rest, source_file, source_file_type, configuration_key] in cur.execute( - f"SELECT rest, source_file, source_file_type, configuration_key FROM {automations_tbl} LIMIT {limit} OFFSET {offset}" + f"SELECT rest, source_file, source_file_type, configuration_key FROM {automations_tbl} LIMIT {limit} OFFSET {offset}" # nosec ): yield decode_auto(rest, source_file, source_file_type, configuration_key) def count_automations(self) -> int: with self.get_cur() as cur: - return cur.execute(f"SELECT count(id) FROM {automations_tbl}").fetchone()[0] + return cur.execute(f"SELECT count(id) FROM {automations_tbl}").fetchone()[0] # nosec diff --git a/api/src/automations/manager.py b/api/src/automations/manager.py index 04465db..68cf9aa 100644 --- a/api/src/automations/manager.py +++ b/api/src/automations/manager.py @@ -1,4 +1,3 @@ -from enum import auto from pathlib import Path from tempfile import mktemp from typing import Dict, Optional, Union @@ -32,7 +31,7 @@ class AutomationManager: db_path: Optional[Path] = None, ) -> None: if db_path is None: - db_path = Path(mktemp()) + db_path = Path(mktemp()) # nosec self.hass_config = hass_config self.db = AutomationDBConnection(db_path) self.tag_path = hass_config.get_automation_tags_path()