diff options
author | Yaron Yogev <yaronyogev@gmail.com> | 2017-08-03 14:45:57 +0300 |
---|---|---|
committer | Yaron Yogev <yaronyogev@gmail.com> | 2017-08-03 14:45:57 +0300 |
commit | 1e8890209856ce68f4f0a6fd43b11a2aab8f8484 (patch) | |
tree | a24c73c98f3d84e5de99d172c2f5fb4506fbf891 | |
parent | cf3cf7a54e5c052521e04393afe7ff9b36eb4006 (diff) |
Fix OPNFV Anteater security warnings in DbAccess:
- rename _password --> _pwd in parameters of db_connect()
- rename exec() --> run_query()
- delete unused methods: set(), delete()
Change-Id: I87df078fb2c32f47976036f3ccacb6d6e743bde0
Signed-off-by: Yaron Yogev <yaronyogev@gmail.com>
-rw-r--r-- | app/discover/fetchers/db/db_access.py | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/app/discover/fetchers/db/db_access.py b/app/discover/fetchers/db/db_access.py index ffe539d..8d21bdd 100644 --- a/app/discover/fetchers/db/db_access.py +++ b/app/discover/fetchers/db/db_access.py @@ -37,7 +37,7 @@ class DbAccess(Fetcher): except (AttributeError, mysql.connector.errors.ProgrammingError): self.neutron_db = "ml2_neutron" - def db_connect(self, _host, _port, _user, _password, _database): + def db_connect(self, _host, _port, _user, _pwd, _database): if DbAccess.conn: return try: @@ -45,7 +45,7 @@ class DbAccess(Fetcher): DbAccess.conn = connector.connect(host=_host, port=_port, connection_timeout=self.TIMEOUT, user=_user, - password=_password, + password=_pwd, database=_database, raise_on_warnings=True) DbAccess.conn.ping(True) # auto-reconnect if necessary @@ -117,7 +117,7 @@ class DbAccess(Fetcher): } return jsonify(ret) - def exec(self, query, table, field, values): + def run_query(self, query, table, field, values): try: cursor = DbAccess.conn.cursor(dictionary=True) cursor.execute(query, [table, field, values]) @@ -133,10 +133,3 @@ class DbAccess(Fetcher): rows.append(row) return rows - def set(self, table, field, values): - query = """INSERT INTO %s %s VALUES %s""" - return self.exec(query, table, field, values) - - def delete(self, table, field, values): - query = """DELETE FROM %s WHERE %s=%s""" - return self.exec(query, table, field, values) |