Repository navigation
Fixes #37552: Verify MySQL sslConfig certificates and reject invalid sslConfig - #37553
Conversation
…sslConfig SSLManager passed the sslConfig file paths to PyMySQL as ssl_ca/ssl_cert/ssl_key, keys the ssl dict ignores, so MySQL, Doris and StarRocks connected over TLS without verifying the server and without presenting client certificates. Use PyMySQL's ca/cert/key keys. sslConfig is a oneOf, so the converters kept any map they could not type and the server saved configs (e.g. sslMode on MySQL) that the ingestion runner refused to load. Reject them with a 400 on service create/update; reads stay lenient so already-stored configs can still be fixed.
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
Java DatabaseServiceType constants from Databricks onward carry the next service's value on main (javaEnums is missing Clickzetta), so the SDK sends MongoDB as SapSuccessFactors. The untyped-map case stays covered by SecretsUtilSslConfigTest.
Code Review ✅ Approved 🔴 High riskEnabling CA-backed certificate and hostname verification for MySQL, Doris, and StarRocks could reject connections with mismatched certificates or hostnames. Fixes MySQL, Doris, and StarRocks sslConfig handling by passing certificate paths under the VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
Main switched the PyMySQL ssl dict to ca/cert/key in open-metadata#37553 and added its own tests. Take main's text unchanged so the branch merges cleanly, keep the deep copy, move the top-level SSL option folding into _nest_pymysql_ssl_options, and move the branch tests main does not cover into test_ssl_manager_pymysql.py.
…sslConfig (#37553) (#37633) * Fixes #37552: Verify MySQL sslConfig certificates and reject invalid sslConfig SSLManager passed the sslConfig file paths to PyMySQL as ssl_ca/ssl_cert/ssl_key, keys the ssl dict ignores, so MySQL, Doris and StarRocks connected over TLS without verifying the server and without presenting client certificates. Use PyMySQL's ca/cert/key keys. sslConfig is a oneOf, so the converters kept any map they could not type and the server saved configs (e.g. sslMode on MySQL) that the ingestion runner refused to load. Reject them with a 400 on service create/update; reads stay lenient so already-stored configs can still be fixed. * Test valid sslConfig on MySQL only in the IT Java DatabaseServiceType constants from Databricks onward carry the next service's value on main (javaEnums is missing Clickzetta), so the SDK sends MongoDB as SapSuccessFactors. The untyped-map case stays covered by SecretsUtilSslConfigTest. (cherry picked from commit f28197e)
#36946) (#37359) * fix: use PyMySQL ssl dict keys (ca, cert, key) in SSLManager.setup_ssl (#36946) * fix(ingestion): preserve MySQL SSL options and certificate setup * fix(ingestion): preserve reusable SSL connection settings * fix(ingestion): call the SecretStr class, not its Annotated alias, in setup_ssl * fix(ingestion): build MySQL SSL setup on main's ca/cert/key fix Main switched the PyMySQL ssl dict to ca/cert/key in #37553 and added its own tests. Take main's text unchanged so the branch merges cleanly, keep the deep copy, move the top-level SSL option folding into _nest_pymysql_ssl_options, and move the branch tests main does not cover into test_ssl_manager_pymysql.py. --------- Co-authored-by: Ayush Shah <[email protected]> Co-authored-by: Mayur Singal <[email protected]>
Describe your changes:
Fixes #37552
Ingestion —
sslConfigcertificates were never used on MySQL / Doris / StarRocks.SSLManager.setup_sslput the temp-file paths underssl_ca/ssl_cert/ssl_keyinside thesslconnection argument. PyMySQL'sssldict readsca/cert/key; the prefixed names only exist as URL query params and top-level kwargs. With a CA configured, connections were encrypted butverify_mode=CERT_NONE, and client certificates were never sent. The keys are nowca/cert/key. Also corrects the RDS IAM comment inmysql/connection.py, which implied the default{"check_hostname": True}verifies the server (without a CA, PyMySQL verifies nothing).Server — an invalid
sslConfigwas saved, then crashed the runner.sslConfigis a JSON SchemaoneOf, so the POJO field isObject. When the converter can't type the value (e.g.{"sslMode": "require"}on MySQL), it keeps the raw map and the service is stored. The ingestion runner then failsextra_forbidden, and Test Connection dies with ~1.5k validation errors.ServiceEntityRepository.preparenow callsSecretsUtil.validateSslConfig, which returns a 400 naming the unrecognised field.SecretsManagerUpdateService. Failing there would make already-stored services unreadable, and impossible to fix by PATCH.getSslConfig()returnsObject, i.e. theverifySSLConfigoneOf. ES/OpenSearch use a typedSSLConfigand are skipped.ValidateSSLClientConfigrather than rejected because it is a map. Connectors with no class converter (MongoDB, Db2, Salesforce, …) carry valid configs as maps too.Behaviour change: a service that already has an invalid
sslConfigstored gets a 400 on its next PUT/PATCH untilsslConfigis fixed in that same request. GET and list are unaffected.Type of change:
High-level design:
N/A — small change.
Tests:
Use cases covered
sslConfig.caCertificate→ PyMySQL builds aCERT_REQUIREDcontext with hostname checkingcert/keysslConfig: {sslMode: require}→ 400unrecognized field 'sslMode'sslConfigstill accepted (MySQL in the IT; a connector without a class converter, MongoDB, in the unit test)Unit tests
ingestion/tests/unit/test_ssl_manager.py: runs the realpymysql.connections.Connection._create_ssl_ctxon the generated args, for all three connectors. Fails onmain(6 failed), passes here.ingestion/tests/unit/source/database/test_mysql_iam.py: fixture used the wrongssl_cakeyopenmetadata-service/.../secrets/SecretsUtilSslConfigTest.java: goes through the realSecretsUtil.convertpathpytest tests/unit/test_ssl_manager.py tests/unit/source/database/test_mysql_iam.py→ 59 passed.mvn test -pl openmetadata-service -Dtest=SecretsUtilSslConfigTest,ServiceEntitySecretsTest,ClassConverterFactoryTest→ 48 passed.Backend integration tests
DatabaseServiceResourceIT:post_mysqlServiceWithUnknownSslConfigField_400andpost_mysqlServiceWithValidSslConfig_200_OK. Both pass locally (mysql-elasticsearch lane), along with the existingpost_databaseServiceWithMysqlConnection_200_OK.DatabaseServiceResourceITlocally: one other failure,put_updateWithoutConnection_preservesExistingConnection_200. It also fails with this PR's Java changes reverted (same assertion), so it's unrelated.Ingestion integration tests
Playwright (UI) tests
Manual testing performed
End-to-end Test Connection against a TLS-only MySQL 8.0. Setup:
require_secure_transport=ON, a server cert from a private CA, one user withREQUIRE SSLand one withREQUIRE X509.The harness drives the same path as the hybrid runner:
AutomationWorkflow.model_validate(raw dict), thenrun_workflow, with the realMysql.testConnectionDefinitionsteps. Only the OM client is a mock (it receives status updates).mainsslConfig.caCertificate= correct CAsslConfig.caCertificate= rogue CACERTIFICATE_VERIFY_FAILEDsslCertificate+sslKeysslConfig: {sslMode: require}sslConfig,connectionArguments.ssl.ca= correct / rogue CAAlso checked on PyMySQL 1.2.3 / 1.2.4 (2.0.x pins
pymysql~=1.0):{"ssl_ca": p}and{"check_hostname": True}giveCERT_NONE;{"ca": p}givesCERT_REQUIRED.UI screen recording:
Not applicable — backend and ingestion only.
🤖 Generated with Claude Code