Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@

.venv/
venv/

.myclirc
uv.lock
3 changes: 2 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ Upcoming (TBD)

Features
--------
* Update query processing functions to allow automatic show_warnings to work for more code paths like DDL
* Update query processing functions to allow automatic show_warnings to work for more code paths like DDL.
* Update the default SSL value to connect securely by default. Add a --no-ssl option to disable it.

Bug Fixes
--------
Expand Down
4 changes: 3 additions & 1 deletion mycli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1343,7 +1343,9 @@ def get_last_query(self) -> str | None:
@click.option("--ssh-key-filename", help="Private key filename (identify file) for the ssh connection.")
@click.option("--ssh-config-path", help="Path to ssh configuration.", default=os.path.expanduser("~") + "/.ssh/config")
@click.option("--ssh-config-host", help="Host to connect to ssh server reading from ssh configuration.")
@click.option("--ssl", "ssl_enable", is_flag=True, help="Enable SSL for connection (automatically enabled with other flags).")
@click.option(
"--ssl/--no-ssl", "ssl_enable", is_flag=True, default=True, help="Enable SSL for connection (automatically enabled with other flags)."
)
@click.option("--ssl-ca", help="CA file in PEM format.", type=click.Path(exists=True))
@click.option("--ssl-capath", help="CA directory.")
@click.option("--ssl-cert", help="X509 cert in PEM format.", type=click.Path(exists=True))
Expand Down
31 changes: 28 additions & 3 deletions test/features/db_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# type: ignore

import ssl

import pymysql


Expand All @@ -14,8 +16,11 @@ def create_db(hostname="localhost", port=3306, username=None, password=None, dbn
:return:

"""
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.VerifyMode.CERT_NONE
cn = pymysql.connect(
host=hostname, port=port, user=username, password=password, charset="utf8mb4", cursorclass=pymysql.cursors.DictCursor
host=hostname, port=port, user=username, password=password, charset="utf8mb4", cursorclass=pymysql.cursors.DictCursor, ssl=ctx
)

with cn.cursor() as cr:
Expand All @@ -39,8 +44,18 @@ def create_cn(hostname, port, password, username, dbname):
:return: psycopg2.connection

"""
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.VerifyMode.CERT_NONE
cn = pymysql.connect(
host=hostname, port=port, user=username, password=password, db=dbname, charset="utf8mb4", cursorclass=pymysql.cursors.DictCursor
host=hostname,
port=port,
user=username,
password=password,
db=dbname,
charset="utf8mb4",
cursorclass=pymysql.cursors.DictCursor,
ssl=ctx,
)

return cn
Expand All @@ -56,8 +71,18 @@ def drop_db(hostname="localhost", port=3306, username=None, password=None, dbnam
:param dbname: string

"""
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.VerifyMode.CERT_NONE
cn = pymysql.connect(
host=hostname, port=port, user=username, password=password, db=dbname, charset="utf8mb4", cursorclass=pymysql.cursors.DictCursor
host=hostname,
port=port,
user=username,
password=password,
db=dbname,
charset="utf8mb4",
cursorclass=pymysql.cursors.DictCursor,
ssl=ctx,
)

with cn.cursor() as cr:
Expand Down