Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Security Fix] Upgrade mysql connector to 8.2.0 #15408

Closed
wants to merge 3 commits into from

Conversation

mustajibmk
Copy link

@mustajibmk mustajibmk commented Nov 21, 2023

Description

Upgrade MySql connector to 8.2.0 to fix security vulnerabilities.

Release note


Key changed/added classes in this PR
  • Upgrade version
  • Replace deprecated classes with the new ones - https://dev.mysql.com/doc/connectors/en/connector-j-upgrading-to-8.0.html
  • The upgraded version of MySQL connector does not have the parseURL method in com.mysql.jdbc.NonRegisteringDriver previously used. Instead, we use the com.mysql.cj.conf.ConnectionUrlParser which only checks if the schema of the string matches the prescribed format. The test cases related to string parsing are hence removed.

This PR has:

  • been self-reviewed.

Comment on lines 192 to 193
if (entry.getKey() != null) {
if(entry.getValue() == null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

is this actually possible?

Copy link
Author

@mustajibmk mustajibmk Dec 18, 2023

Choose a reason for hiding this comment

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

Yes, it is possible. Like in this case where keyonly doesn't have any value associated with it.

}
}
}
if (properties.isEmpty()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why would you throw an error if there are no properties associated with the connection string? Instead you should throw an error if properties is null for some reason.

Copy link
Author

Choose a reason for hiding this comment

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

With the initialisation of properties. It cannot be null anymore, hence empty remains the only possible scenario when nothing could be extracted from the connection string.

@mustajibmk mustajibmk marked this pull request as draft November 30, 2023 08:28
@mustajibmk mustajibmk changed the title [Security Fix] Upgrade mysql connector to 8.0.28 [Security Fix] Upgrade mysql connector to 8.2.0 Dec 16, 2023
@mustajibmk mustajibmk force-pushed the upgrade-mysql-connector branch from ea2e267 to cdfc075 Compare December 17, 2023 13:39
@mustajibmk mustajibmk marked this pull request as ready for review December 18, 2023 09:44
@@ -159,46 +159,6 @@ public boolean isEnforceAllowedProperties()
}
);
}

@Test
public void testWhenInvalidUrlFormat()
Copy link
Contributor

Choose a reason for hiding this comment

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

is this no longer an invalid url format?

Copy link
Author

Choose a reason for hiding this comment

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

The parser no longer checks if every component is in the expected format it only checks if the URL starts with one of the required schema i.e jdbc:mysql,jdbc:mysql:loadbalancer, etc. So we will not be able to determine if this is a valid/invalid URL just by using the parser.

The way to determine if the URL is valid is by creating a connection with the DB.

extensions-core/mysql-metadata-storage/pom.xml Outdated Show resolved Hide resolved
connectionUri,
null
);
Class<?> connectionUrlClass = Class.forName(MYSQL_CONNECTION_URL);
Copy link
Contributor

Choose a reason for hiding this comment

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

can you describe your logic in a bit more detail?

Copy link
Author

@mustajibmk mustajibmk Dec 25, 2023

Choose a reason for hiding this comment

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

Now the method

  • Checks if the string is in acceptable schema
  • Get the list<hostInfo> obtained from the string
  • From the hostInfo obtain the properties and return the key of each property

@mustajibmk mustajibmk force-pushed the upgrade-mysql-connector branch from 8048694 to 32d5c7a Compare December 28, 2023 18:28
@AlbericByte
Copy link
Contributor

@mustajibmk are you still working on this, i have similar work: #16024 (comment), my bad, i did not know you have already work on this.
if you do not work on this any more, i can continue to work on this base on my pr.
cc @abhishekagarwal87 and @cryptoe

@AlbericByte
Copy link
Contributor

@abhishekagarwal87 and @cryptoe may i continue to work on this, seems there is no response from 3 months ago.
and i have a similar pr : #16024 (comment)
cc:@mustajibmk

@abhishekagarwal87
Copy link
Contributor

abhishekagarwal87 commented Mar 16, 2024 via email

@FrankChen021
Copy link
Member

@AlbericByte let's continue

@FrankChen021
Copy link
Member

@abhishekagarwal87 Let's shift to #16024 since @AlbericByte has also finished the work and I see all the CI checks are green.

Still thanks the work from @mustajibmk

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

Successfully merging this pull request may close these issues.

4 participants