forked from elastic/beats
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix mysql parser handling of connection phase (elastic#8139)
The mysql protocol parser assumes that transactions can only be started by the client. This is true once the connection has been negotiated ("command phase"), but not during initial handshake ("connection phase"). This causes parsing problems when a connection is monitored from the start, as sometimes the connection phase leaves the parser confused on which side is client. This patch modifies how client-side is detected, which can only be done by looking at the destination port.
- Loading branch information
Showing
4 changed files
with
52 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
22 changes: 22 additions & 0 deletions
22
packetbeat/tests/system/test_0067_mysql_connection_phase.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from packetbeat import BaseTest | ||
|
||
""" | ||
Tests that the negotiation phase at the beginning of a mysql connection | ||
doesn't leave the parser in a broken state. | ||
""" | ||
|
||
|
||
class Test(BaseTest): | ||
|
||
def test_connection_phase(self): | ||
""" | ||
This tests that requests are still captured from a mysql stream that | ||
starts with the "connection phase" negotiation. | ||
""" | ||
self.render_config_template( | ||
mysql_ports=[3306], | ||
) | ||
self.run_packetbeat(pcap="mysql_connection.pcap") | ||
|
||
objs = self.read_output() | ||
assert len(objs) > 0 |