mysql

package
v2.2.0-alpha21-rc3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

README

MySQL Package Documentation

The mysqlparser package encompasses the parser and mapping logic required to read MySql binary messages and capture and test the outputs. Utilized by the hooks package, it assists in redirecting outgoing calls for the purpose of recording or testing the outputs.

SSL Support

Please note that SSL is currently not supported in the MySQL package. To use the package without SSL, you can include the following parameters in your database URL like the following example:

jdbc:mysql://localhost:3306/db_name?useSSL=false&allowPublicKeyRetrieval=true

The following MySQL packet types are handled in the parser:

COM_PING: A ping command sent to the server to check if it's alive and responsive.

COM_STMT_EXECUTE: Executes a prepared statement that was prepared using the COM_STMT_PREPARE command.

COM_STMT_FETCH: Fetches rows from a statement which produced a result set. Used with cursors in server-side prepared statements.

COM_STMT_PREPARE: Prepares a SQL statement for execution.

COM_STMT_CLOSE: Closes a prepared statement, freeing up server resources associated with it.

COM_CHANGE_USER: Changes the user of the current connection and resets the connection state.

MySQLOK: A packet indicating a successful operation. It is usually received after commands like INSERT, UPDATE, DELETE, etc.

MySQLErr: An error packet sent from the server to the client, indicating an error occurred with the last command sent.

RESULT_SET_PACKET: Contains the actual result set data returned by a query. It's a series of packets containing rows and columns of data.

MySQLHandshakeV10: The initial handshake packet sent from the server to the client when a connection is established, containing authentication and connection details.

HANDSHAKE_RESPONSE: The response packet sent by the client in reply to MySQLHandshakeV10, containing client authentication data.

MySQLQuery: Contains a SQL query that is to be executed on the server.

AUTH_SWITCH_REQUEST: Sent by the server to request an authentication method switch during the connection process.

AUTH_SWITCH_RESPONSE: Sent by the client to respond to the AUTH_SWITCH_REQUEST, containing authentication data.

MySQLEOF: An EOF (End Of File) packet that marks the end of a result set or the end of the fields list.

AUTH_MORE_DATA: Sent by the server if it needs more data for authentication (used in plugins).

COM_STMT_SEND_LONG_DATA: Sends data for a column in a row to be inserted/updated in a table using a prepared statement.

COM_STMT_RESET: Resets the data of a prepared statement which was accumulated with COM_STMT_SEND_LONG_DATA commands.

COM_QUIT: Sent by the client to close the connection to the server gracefully.

Documentation

Overview

Package mysql provides integration with MySQL outgoing.

Index

Constants

View Source
const (
	// CLIENT_PLUGIN_AUTH indicates that the client supports plugin authentication.
	CLIENT_PLUGIN_AUTH = 0x00080000
	// CLIENT_CONNECT_WITH_DB indicates that client is connecting to server with database name.
	CLIENT_CONNECT_WITH_DB = 0x00000008
	// CLIENT_CONNECT_ATTRS indicates that the client supports connection attributes.
	CLIENT_CONNECT_ATTRS = 0x00100000
	// CLIENT_ZSTD_COMPRESSION_ALGORITHM indicates support for Zstandard compression algorithm
	CLIENT_ZSTD_COMPRESSION_ALGORITHM = 0x00010000
)

Variables

This section is empty.

Functions

func DecodeMySQLPacket

func DecodeMySQLPacket(logger *zap.Logger, packet models.Packet, clientConn net.Conn, mode models.Mode, lastCommand *lastCommandMap) (string, models.SQLPacketHeaderInfo, interface{}, error)

func Encode

func Encode(p *models.Packet) ([]byte, error)

func GetAuthMethod

func GetAuthMethod(packet *models.MySQLHandshakeV10Packet) string

func NewMySQL

func NewMySQL(logger *zap.Logger) integrations.Integrations

func ShouldUseSSL

func ShouldUseSSL(packet *models.MySQLHandshakeV10Packet) bool

func Uint24

func Uint24(data []byte) uint32

Types

type BoundParameter

type BoundParameter struct {
	Type     byte   `yaml:"type"`
	Unsigned byte   `yaml:"unsigned"`
	Value    []byte `yaml:"value,omitempty,flow"`
}

type CapabilityFlags

type CapabilityFlags uint32

type ComInitDbPacket

type ComInitDbPacket struct {
	Status byte
	DbName string
}

type MySQL

type MySQL struct {
	// contains filtered or unexported fields
}

func (*MySQL) MatchType

func (m *MySQL) MatchType(_ context.Context, _ []byte) bool

func (*MySQL) MockOutgoing

func (m *MySQL) MockOutgoing(ctx context.Context, src net.Conn, dstCfg *integrations.ConditionalDstCfg, mockDb integrations.MockMemDb, opts models.OutgoingOptions) error

func (*MySQL) RecordOutgoing

func (m *MySQL) RecordOutgoing(ctx context.Context, src net.Conn, dst net.Conn, mocks chan<- *models.Mock, opts models.OutgoingOptions) error

type PacketType2

type PacketType2 struct {
	Field1 byte `yaml:"field1"`
	Field2 byte `yaml:"field2"`
	Field3 byte `yaml:"field3"`
}

type PasswordData

type PasswordData struct {
	PayloadLength uint32 `yaml:"payload_length"`
	SequenceID    byte   `yaml:"sequence_id"`
	Payload       []byte `yaml:"payload,omitempty,flow"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL