Compare commits

..

1 Commits
v4.3.3 ... main

Author SHA1 Message Date
Mikhail Solovev
fedf7db8a4 Quote table and column identifiers using SQLAlchemy dialect preparer when adding missing columns to avoid SQL injection and syntax errors. (#1237)
Some checks failed
Mark stale issues and pull requests / stale (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Docker Build and Push / docker_build (push) Has been cancelled
Docker Build and Push / docker_scan (push) Has been cancelled
2026-04-16 20:56:16 +02:00

View File

@@ -146,7 +146,10 @@ class DashboardConfig:
if col_name not in existing_columns: if col_name not in existing_columns:
type_str = col_type().compile(dialect=self.engine.dialect) type_str = col_type().compile(dialect=self.engine.dialect)
current_app.logger.info(f"Adding missing column '{col_name}' to table '{table_name}'") current_app.logger.info(f"Adding missing column '{col_name}' to table '{table_name}'")
conn.execute(db.text(f'ALTER TABLE "{table_name}" ADD COLUMN "{col_name}" {type_str}')) preparer = self.engine.dialect.identifier_preparer
quoted_table = preparer.quote_identifier(table_name)
quoted_column = preparer.quote_identifier(col_name)
conn.execute(db.text(f"ALTER TABLE {quoted_table} ADD COLUMN {quoted_column} {type_str}"))
def getConnectionString(self, database) -> str or None: def getConnectionString(self, database) -> str or None:
sqlitePath = os.path.join(DashboardConfig.ConfigurationPath, "db") sqlitePath = os.path.join(DashboardConfig.ConfigurationPath, "db")