You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Failed initializing postgresql database connector.
ERROR: Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/opmon_anonymizer/main.py", line 93, in setup_writer
writer = OpenDataWriter(settings, logger)
File "/usr/lib/python3/dist-packages/opmon_anonymizer/iio/opendata_writer.py", line 42, in __init__
self.db_manager = PostgreSqlManager(settings['postgres'], schema, index_columns, logger)
File "/usr/lib/python3/dist-packages/opmon_anonymizer/iio/postgresql_manager.py", line 43, in __init__
self._ensure_table(table_schema, index_columns)
File "/usr/lib/python3/dist-packages/opmon_anonymizer/iio/postgresql_manager.py", line 95, in _ensure_table
if not self._table_exists(cursor):
File "/usr/lib/python3/dist-packages/opmon_anonymizer/iio/postgresql_manager.py", line 112, in _table_exists
""", (cursor._table_name,))
AttributeError: 'psycopg2.extensions.cursor' object has no attribute '_table_name'
"GRANT SELECT ON %s TO %s;", (self._table_name, readonly_user)
Notation "%s" should be used for escaping data, not Identifiers like table names and user names. The constructed SQL just silently fails because of except Exception: pass:
GRANT USAGE ON SCHEMA public TO 'opendata_inst';
GRANT SELECT ON 'logs' TO 'opendata_inst';
The same problem with identifiers occurs in other places, for example it is not possible to display opendata due to SQL error because of the bug in code:
Currently anonymizer fails to initialize empty database because of typo made while refactoring code.
Software version:
1.1.0
Source:
https://github.com/nordic-institute/X-Road-Metrics/blob/develop/anonymizer_module/opmon_anonymizer/iio/postgresql_manager.py#L112
Error message:
Solution:
cursor._table_name
should be renamed back toself._table_name
as it was before change:65a1357#diff-2de518dd9301590a33d32a07fdcdf45bcaba485b18e61d65f29e5f8dcfd0b3e5L110
Additional problems:
Source:
X-Road-Metrics/anonymizer_module/opmon_anonymizer/iio/postgresql_manager.py
Line 134 in 9ed9e47
X-Road-Metrics/anonymizer_module/opmon_anonymizer/iio/postgresql_manager.py
Line 137 in 9ed9e47
Notation "%s" should be used for escaping data, not Identifiers like table names and user names. The constructed SQL just silently fails because of
except Exception: pass
:Solution:
Identifiers should be properly escaped: https://www.psycopg.org/docs/sql.html#module-usage
If possible exception should not "pass" on all errors.
The same problem with identifiers occurs in other places, for example it is not possible to display opendata due to SQL error because of the bug in code:
X-Road-Metrics/opendata_module/opmon_opendata/api/postgresql_manager.py
Line 91 in 9ed9e47
The text was updated successfully, but these errors were encountered: