Skip to content

Commit 576e146

Browse files
authored
Merge pull request #8120 from chaen/9.0_fix_passwordQuote
fix: escape db password when passing to sqlalchemy
2 parents 1990037 + b4dcb63 commit 576e146

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

src/DIRAC/Core/Base/SQLAlchemyDB.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
44
Uses sqlalchemy
55
"""
6+
67
import datetime
78
from urllib import parse as urlparse
89
from sqlalchemy import create_engine, desc, exc

src/DIRAC/DataManagementSystem/DB/FTS3DB.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
""" Frontend to FTS3 MySQL DB. Written using sqlalchemy
2-
"""
1+
"""Frontend to FTS3 MySQL DB. Written using sqlalchemy"""
2+
33
# We disable the no-member error because
44
# they are constructed by SQLAlchemy for all
55
# the objects mapped to a table.
66
# pylint: disable=no-member
77

88
import datetime
99
import errno
10+
from urllib.parse import quote_plus
1011

1112
from sqlalchemy import (
1213
BigInteger,
@@ -184,7 +185,7 @@ def __getDBConnectionInfo(self, fullname):
184185
self.dbHost = dbParameters["Host"]
185186
self.dbPort = dbParameters["Port"]
186187
self.dbUser = dbParameters["User"]
187-
self.dbPass = dbParameters["Password"]
188+
self.dbPass = quote_plus(dbParameters["Password"])
188189
self.dbName = dbParameters["DBName"]
189190

190191
def __init__(self, pool_size=15, url=None, parentLogger=None):

src/DIRAC/RequestManagementSystem/DB/RequestDB.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
import errno
1717
import random
1818

19+
from urllib.parse import quote_plus
20+
1921
from sqlalchemy import (
2022
TEXT,
2123
BigInteger,
@@ -198,7 +200,7 @@ def __getDBConnectionInfo(self, fullname):
198200
self.dbHost = dbParameters["Host"]
199201
self.dbPort = dbParameters["Port"]
200202
self.dbUser = dbParameters["User"]
201-
self.dbPass = dbParameters["Password"]
203+
self.dbPass = quote_plus(dbParameters["Password"])
202204
self.dbName = dbParameters["DBName"]
203205

204206
def __init__(self, parentLogger=None):

0 commit comments

Comments
 (0)