Skip to content

FIDES-1887 - Add sslmode to MySQL DB integration#6048

Merged
wadesdev merged 31 commits intomainfrom
wades/add-sslmode
Apr 18, 2025
Merged

FIDES-1887 - Add sslmode to MySQL DB integration#6048
wadesdev merged 31 commits intomainfrom
wades/add-sslmode

Conversation

@wadesdev
Copy link
Copy Markdown
Contributor

Closes FIDES-1887

Description Of Changes

Adds sslmode field for MySQL; does not permit passing certificates through for verify-ca and verify-full

Code Changes

  • Updates mysql to provide connect_args argument for SSL
  • Writes get_connect_args function for MySQL connector

Steps to Confirm

  1. For a MySQL DB configured for SSL with ssl: required field, providing required in sslmode field should result in a successful connection. Otherwise, connection will be unsuccessful.

Pre-Merge Checklist

  • Issue requirements met
  • All CI pipelines succeeded
  • CHANGELOG.md updated
    • Add a db-migration This indicates that a change includes a database migration label to the entry if your change includes a DB migration
    • Add a high-risk This issue suggests changes that have a high-probability of breaking existing code label to the entry if your change includes a high-risk change (i.e. potential for performance impact or unexpected regression) that should be flagged
  • Followup issues:
    • Followup issues created (include link)
    • No followup issues
  • Database migrations:
    • Ensure that your downrev is up to date with the latest revision on main
    • Ensure that your downgrade() migration is correct and works
      • If a downgrade migration is not possible for this change, please call this out in the PR description!
    • No migrations
  • Documentation:
    • Documentation complete, PR opened in fidesdocs
    • Documentation issue created in fidesdocs
    • If there are any new client scopes created as part of the pull request, remember to update public-facing documentation that references our scope registry
    • No documentation updates required

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Apr 15, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
fides-plus-nightly ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 18, 2025 0:51am
fides-privacy-center ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 18, 2025 0:51am

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 15, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.89%. Comparing base (400bb2e) to head (1a624fd).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6048      +/-   ##
==========================================
+ Coverage   86.88%   86.89%   +0.01%     
==========================================
  Files         419      419              
  Lines       25968    25978      +10     
  Branches     2828     2828              
==========================================
+ Hits        22561    22574      +13     
+ Misses       2788     2785       -3     
  Partials      619      619              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…nto wades/add-sslmode

Changelog merge conflict resolved
Copy link
Copy Markdown
Contributor

@galvana galvana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks good! Just recommending the use of an enum of sslmode and adding the missing tests we discussed offline

Comment on lines +43 to +48
sslmode: Optional[str] = Field(
None, # TODO: support for verify-ca and verify-full
title="SSL Mode",
description="The SSL mode to use for the connection. Valid values are 'required', 'preferred', and 'disabled'.",
pattern=r"required|preferred|disabled",
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could use an enum for this

class SSLMode(str, Enum):
    preferred = "preferred"
    required = "required"
    disabled = "disabled"

Then we could just do this

Suggested change
sslmode: Optional[str] = Field(
None, # TODO: support for verify-ca and verify-full
title="SSL Mode",
description="The SSL mode to use for the connection. Valid values are 'required', 'preferred', and 'disabled'.",
pattern=r"required|preferred|disabled",
)
sslmode: Optional[SSLMode] = Field(
None, # TODO: support for verify-ca and verify-full
title="SSL Mode",
description="The SSL mode to use for the connection. Valid values are 'required', 'preferred', and 'disabled'."
)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@galvana could I define that ENUM in connection_secrets_mysql.py?

"title": "SSL Mode",
"description": "The SSL mode to use for the connection. Valid values are 'required', 'preferred', and 'disabled'.",
"type": "string",
"pattern": "required|preferred|disabled",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might need to remove this line if we go with the enum approach

Comment on lines +61 to +67
def test_mysql_connector_build_uri_without_secrets(
connection_config_mysql, db: Session
):
connection_config_mysql.secrets = None
connection_config_mysql.save(db)
with pytest.raises(ValueError):
MySQLConnector(configuration=connection_config_mysql)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace this with the direct get_connect_args() tests to get that increase in code coverage

title="SSH required",
description="Indicates whether an SSH tunnel is required for the connection. Enable this option if your MySQL server is behind a firewall and requires SSH tunneling for remote connections.",
)
sslmode: Optional[MySQLSslMode] = Field(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be ssl_mode?

)


class MySQLSslMode(str, Enum):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we should upper case all acronyms

Note: When using acronyms in CapWords, capitalize all the letters of the acronym. Thus HTTPServerError is better than HttpServerError.

https://peps.python.org/pep-0008/#descriptive-naming-styles

Suggested change
class MySQLSslMode(str, Enum):
class MySQLSSLMode(str, Enum):

@galvana galvana self-requested a review April 17, 2025 23:49
@wadesdev wadesdev merged commit 58fd426 into main Apr 18, 2025
44 checks passed
@wadesdev wadesdev deleted the wades/add-sslmode branch April 18, 2025 01:29
@cypress
Copy link
Copy Markdown

cypress Bot commented Apr 18, 2025

fides    Run #12834

Run Properties:  status check passed Passed #12834  •  git commit 58fd4263f3: FIDES-1887 - Add ssl_mode to MySQL DB integration (#6048)
Project fides
Branch Review main
Run status status check passed Passed #12834
Run duration 00m 51s
Commit git commit 58fd4263f3: FIDES-1887 - Add ssl_mode to MySQL DB integration (#6048)
Committer wadesdev
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 5
View all changes introduced in this branch ↗︎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants