Skip to content

Commit

Permalink
Fix clickhouse password leak (#4078)
Browse files Browse the repository at this point in the history
* Fix clickhouse password leak

* Fix after review
  • Loading branch information
vv-p authored and arikfr committed Aug 18, 2019
1 parent e5e926b commit b426e4f
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions redash/query_runner/clickhouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,29 @@ def _get_tables(self, schema):
return schema.values()

def _send_query(self, data, stream=False):
r = requests.post(
self.configuration.get('url', "http://127.0.0.1:8123"),
data=data.encode("utf-8"),
stream=stream,
timeout=self.configuration.get('timeout', 30),
params={
'user': self.configuration.get('user', "default"),
'password': self.configuration.get('password', ""),
'database': self.configuration['dbname']
}
)
if r.status_code != 200:
raise Exception(r.text)
# logging.warning(r.json())
return r.json()
url = self.configuration.get('url', "http://127.0.0.1:8123")
try:
r = requests.post(
url,
data=data.encode("utf-8"),
stream=stream,
timeout=self.configuration.get('timeout', 30),
params={
'user': self.configuration.get('user', "default"),
'password': self.configuration.get('password', ""),
'database': self.configuration['dbname']
}
)
if r.status_code != 200:
raise Exception(r.text)
# logging.warning(r.json())
return r.json()
except requests.RequestException as e:
if e.response:
details = "({}, Status Code: {})".format(e.__class__.__name__, e.response.status_code)
else:
details = "({})".format(e.__class__.__name__)
raise Exception("Connection error to: {} {}.".format(url, details))

@staticmethod
def _define_column_type(column):
Expand Down

0 comments on commit b426e4f

Please sign in to comment.