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

Fixed MariaDB protocol handling issue #662

Merged
merged 17 commits into from
Aug 2, 2023

Conversation

Zhaars
Copy link
Contributor

@Zhaars Zhaars commented Jul 21, 2023

Fixed issue related to MariaDB protocol. What has been done in this PR:

  • fixed protocol issue related to tracking Column metadata in ColumnDefinition packet;
  • tracking MARIADB_CLIENT_EXTENDED_TYPE_INFO capability from the client and server sides;
  • extend updateFieldEncodedType func with updating specific type data as Charset, ColumnLength, etc;

Checklist

Zhaars added 7 commits July 17, 2023 15:17
Fixed inconsitency in protocol between MariaDB and MySQL
Removed unsused stuff
# Conflicts:
#	decryptor/mysql/packet_test.go
Extend integration tests
@Zhaars Zhaars requested a review from Lagovas July 21, 2023 12:23

// https://mariadb.com/kb/en/com_stmt_execute/#statement-id
// Since MariaDB server version 10.2, value -1 (0xFFFFFFFF) can be used to indicate to use the last
// statement prepared on current connection if no COM_STMT_PREPARE has fail since.
Copy link
Collaborator

Choose a reason for hiding this comment

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

hm.... we should handle it somehow too. reset lastStatementID

class TestMariaDBTextTypeAwareDecryptionWithCiphertext(test_common.AcraCatchLogsMixin, test_common.BaseBinaryMariaDBTestCase,
test_searchable_transparent_encryption.BaseTransparentEncryption):
# test table used for queries and data mapping into python types
test_table = sa.Table(
Copy link
Collaborator

Choose a reason for hiding this comment

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

I remember we had some problems with using shared metadata and registering tables with same names. And for that started to use def get_encryptor_table(self) methods and test_common.SeparateMetadataMixin mixin to use separate metadata if it can be used to avoid conflicts. please look at that, is it relevant 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.

We already have test_common.SeparateMetadataMixin inside test_searchable_transparent_encryption.BaseTransparentEncryption class. And this test inherits this class.

@Lagovas Lagovas mentioned this pull request Jul 26, 2023
7 tasks
@Zhaars Zhaars requested a review from Lagovas July 27, 2023 13:17
tests/test.py Outdated

def executePreparedStatement(self, query, args=None):
return MariaDBExecutor(
ConnectionArgs(host='127.0.0.1', port=self.ACRASERVER_PORT,
Copy link
Collaborator

Choose a reason for hiding this comment

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

let's use host from the configured variable

@@ -79,6 +82,13 @@ class MysqlExecutorMixin(ExecutorMixin):
executor_cls = base.MysqlExecutor


class MariaDBExecutorMixin(ExecutorMixin):
def get_db_host(self):
return '127.0.0.1'
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here, can we use value from the DB_HOST?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As we discussed, MariaDB expects 127.0.0.1 explicitly because it is using socket auth by default in the case of localhost

@Zhaars Zhaars requested a review from Lagovas July 28, 2023 09:04
row = self.executor1.execute(query)[0]
for column in columns:
self.assertEqual(data[column], row[column])
self.assertIsInstance(row[column], type(data[column]))
Copy link
Collaborator

Choose a reason for hiding this comment

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

yay, no hacks with type conversion, just simple comparison)


// if not (CLIENT_DEPRECATE_EOF capability set) EOF_Packet
// https://mariadb.com/kb/en/result-set-packets/#column-definition-packet
if eofPacket.data[0] != EOFPacket {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I hope we will never get empty slice and err=nil here ))

@Zhaars Zhaars merged commit c25d70f into master Aug 2, 2023
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.

[ISSUE] Tokenization in MariaDB
2 participants