Skip to content

Conversation

namya28
Copy link
Contributor

@namya28 namya28 commented Mar 19, 2025

Description

This PR is for upgrading the mysql jar version to the latest version 9.2.0.
This fixes CVE-2023-22102.

Motivation and Context

Impact

Test Plan

Contributor checklist

  • Please make sure your submission complies with our contributing guide, in particular code style and commit standards.
  • PR description addresses the issue accurately and concisely. If the change is non-trivial, a GitHub Issue is referenced.
  • Documented new properties (with its default value), SQL syntax, functions, or other functionality.
  • If release notes are required, they follow the release notes guidelines.
  • Adequate tests were added if applicable.
  • CI passed.

Release Notes

Please follow release notes guidelines and fill in the release notes below.

== RELEASE NOTES ==

Security Changes

* Upgrade the MySQL to version 9.2.0 in response to `CVE-2023-22102 <https://github.com/advisories/GHSA-m6vm-37g8-gqvh>`_. :pr:`24754`

@prestodb-ci prestodb-ci added the from:IBM PR from IBM label Mar 19, 2025
@namya28 namya28 requested a review from agrawalreetika March 19, 2025 08:52
@namya28 namya28 changed the title Upgrading mysql in presto Upgrading mysql jar in presto Mar 19, 2025
@namya28 namya28 marked this pull request as ready for review March 19, 2025 14:35
@namya28 namya28 requested a review from a team as a code owner March 19, 2025 14:35
@namya28 namya28 requested a review from jaystarshot March 19, 2025 14:35
@prestodb-ci prestodb-ci requested review from a team and bibith4 and removed request for a team March 19, 2025 14:35
}
catch (SQLException e) {
catch (Exception e) {
Copy link
Member

Choose a reason for hiding this comment

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

Whats the specific exception here? Should we catch that here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @agrawalreetika , thank you for your feedback. Based on my research , The code is building fine without an exception as well. Since it is optional and if required , would you recommend me adding an IllegalArgumentException instead of Exception?

Copy link
Member

@agrawalreetika agrawalreetika Mar 24, 2025

Choose a reason for hiding this comment

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

Earlier code was throwing SQLException which is why it was added now in your current implementation I don't think try-catch is even needed.
Please check and update the code accordingly.

@agrawalreetika
Copy link
Member

Thanks for the changes, please squash your changes into 1 with the relevant commit message.

<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
</exclusion>
</exclusions>
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to exclude this or can we just pull up the dependency version through the dependencyManagement section? Or is it due to duplicate class conflicts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ZacBlanco, Excluding this as it is resulting in upper bound dependencies error.
Screenshot 2025-03-24 at 1 09 29 PM

Copy link
Member

Choose a reason for hiding this comment

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

Can't we try to just upgrade the dependency to the required version?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@agrawalreetika , thank you for your feedback! I tried removing the exclusions and tried upgrading the protobuf-java version to 4.29.0 using 2 approaches :

  1. upgraded the version to 4.29.0 in root pom. It is resulting in error in presto-main
Screenshot 2025-03-25 at 2 57 37 PM 2. Kept the earlier version as is in the root pom (3.25.5) and tried upgrading the version to 4.29.0 using dependency management in the module pom (presto-function-namespace-managers) and it is resulting in the same error in presto-main . (same in the case of presto-product-tests module as well). Screenshot 2025-03-25 at 3 05 20 PM 3. Also tried ignoring it under and under duplicate-finder-maven-plugin. Resulting in the same error.

Copy link
Member

@agrawalreetika agrawalreetika Mar 26, 2025

Choose a reason for hiding this comment

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

If with 4.29.0 version upgrade we are hitting duplicate class error then I am ok with excluding it from <artifactId>mysql-connector-j</artifactId> if the CI tests are passing.

@ZacBlanco Do you have any concern with exclusion? Or have any other approach to handle this?

Copy link
Contributor

Choose a reason for hiding this comment

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

I am not a fan of excluding random dependencies. The conflicts aren't even on Java classes, so this could potentially lead to runtime issues if we're excluding core protobuf classes. In this case I would rather add exceptions to the duplicate finder for the .proto files

Copy link
Contributor Author

@namya28 namya28 Mar 28, 2025

Choose a reason for hiding this comment

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

Upgraded the protobuf-java version in the root pom and ignored the dependency ratis-thirdparty-misc under duplicate-finder-maven-plugin since directly adding <ignoredResourcePattern>google/protobuf/*.proto</ignoredResourcePattern> was resulting in the same error.

agrawalreetika
agrawalreetika previously approved these changes Mar 27, 2025
Copy link
Contributor

@ZacBlanco ZacBlanco left a comment

Choose a reason for hiding this comment

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

Do we have a PR to upgrade the testing-mysql-server? I would prefer if we updated that + released a new version for Presto first before this gets merged in order to reduce the number of exclusions

import static java.lang.String.format;
import static java.util.Locale.ENGLISH;

public class MySqlClient
extends BaseJdbcClient
{
private static final String SQL_STATE_SYNTAX_ERROR = "42000";
private static final String SQL_STATE_ER_TABLE_EXISTS_ERROR = "42S01";
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these not defined/available in the new mysql client? Where is this documented?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are sql error codes corresponding to the mysql error code. https://dev.mysql.com/doc/connector-j/en/connector-j-reference-error-sqlstates.html.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think for the syntax error, we should instead catch the SQLSyntaxError exception from the client rather than catching and comparing the code. For the table exists error, there isn't a corresponding exception type, so we can keep the current approach. Though we should leave a comment with a link to the documentation of error codes for future developers to know where the code came from

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added the SQLSyntaxError exception as well. Had to keep the SQLException as well as I was getting the error Unhandled exception: java.sql.SQLException .

<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
</exclusion>
</exclusions>
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not a fan of excluding random dependencies. The conflicts aren't even on Java classes, so this could potentially lead to runtime issues if we're excluding core protobuf classes. In this case I would rather add exceptions to the duplicate finder for the .proto files

Copy link

linux-foundation-easycla bot commented Mar 27, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: namya28 / name: Namya Sehgal (0348d9b)

@namya28
Copy link
Contributor Author

namya28 commented Mar 28, 2025

Do we have a PR to upgrade the testing-mysql-server? I would prefer if we updated that + released a new version for Presto first before this gets merged in order to reduce the number of exclusions

There already is a release for testing mysql-server 8 for the version being used. https://repo.maven.apache.org/maven2/com/facebook/presto/testing-mysql-server-8/ .

@namya28
Copy link
Contributor Author

namya28 commented Apr 1, 2025

@ZacBlanco @agrawalreetika , I have addressed the review comments. Could you please help review once again whenever convenient.

agrawalreetika
agrawalreetika previously approved these changes Apr 1, 2025
Copy link
Member

@agrawalreetika agrawalreetika left a comment

Choose a reason for hiding this comment

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

LGTM. Please squash all your commits into one.

Copy link
Contributor

@ZacBlanco ZacBlanco left a comment

Choose a reason for hiding this comment

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

one minor nit

Copy link
Contributor

@ZacBlanco ZacBlanco left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for the upgrade!

@agrawalreetika agrawalreetika merged commit b0286c5 into prestodb:master Apr 2, 2025
97 checks passed
@prestodb-ci prestodb-ci requested review from a team and anandamideShakyan and removed request for a team April 3, 2025 04:02
@ZacBlanco ZacBlanco mentioned this pull request May 29, 2025
21 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants