Skip to content

Commit 9b544ba

Browse files
committed
feat: parse web_sphere_mq TSH message
1 parent c9d390b commit 9b544ba

File tree

7 files changed

+108
-5
lines changed

7 files changed

+108
-5
lines changed

agent/crates/enterprise-utils/src/lib.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,14 +334,21 @@ pub mod l7 {
334334
pub struct WebSphereMqParser {
335335
pub base: L7LogBase,
336336
pub orig_send_time: String,
337+
pub skip_frame: bool,
337338
}
338339

339340
impl WebSphereMqParser {
340-
pub fn check_payload(&mut self, _: &[u8]) -> Option<LogMessageType> {
341+
pub fn check_payload(&mut self, _: &[u8], _: bool) -> Option<LogMessageType> {
341342
unimplemented!()
342343
}
343344

344-
pub fn parse_payload(&mut self, _: &[u8], _: PacketDirection, _: bool) -> usize {
345+
pub fn parse_payload(
346+
&mut self,
347+
_: &[u8],
348+
_: PacketDirection,
349+
_: bool,
350+
_: bool,
351+
) -> usize {
345352
unimplemented!()
346353
}
347354
}

agent/src/config/config.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1834,12 +1834,14 @@ impl Default for Iso8583Config {
18341834
#[serde(default)]
18351835
pub struct WebSphereMqConfig {
18361836
pub parse_xml_enabled: bool,
1837+
pub decompress_enabled: bool,
18371838
}
18381839

18391840
impl Default for WebSphereMqConfig {
18401841
fn default() -> Self {
18411842
Self {
18421843
parse_xml_enabled: true,
1844+
decompress_enabled: true,
18431845
}
18441846
}
18451847
}
@@ -3641,12 +3643,14 @@ impl Default for Iso8583ParseConfig {
36413643
#[derive(Clone, Debug, PartialEq, Eq)]
36423644
pub struct WebSphereMqParseConfig {
36433645
pub parse_xml_enabled: bool,
3646+
pub decompress_enabled: bool,
36443647
}
36453648

36463649
impl Default for WebSphereMqParseConfig {
36473650
fn default() -> Self {
36483651
Self {
36493652
parse_xml_enabled: true,
3653+
decompress_enabled: true,
36503654
}
36513655
}
36523656
}

agent/src/config/handler.rs

100755100644
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,13 @@ impl From<&UserConfig> for FlowConfig {
768768
.protocol_special_config
769769
.web_sphere_mq
770770
.parse_xml_enabled,
771+
decompress_enabled: conf
772+
.processors
773+
.request_log
774+
.application_protocol_inference
775+
.protocol_special_config
776+
.web_sphere_mq
777+
.decompress_enabled,
771778
},
772779
obfuscate_enabled_protocols: L7ProtocolBitmap::from(
773780
conf.processors

agent/src/flow_generator/protocol_logs/mq/web_sphere_mq.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,9 @@ pub struct WebSphereMqLog {
291291
}
292292

293293
impl L7ProtocolParserInterface for WebSphereMqLog {
294-
fn check_payload(&mut self, payload: &[u8], _param: &ParseParam) -> Option<LogMessageType> {
295-
self.parser.check_payload(payload)
294+
fn check_payload(&mut self, payload: &[u8], param: &ParseParam) -> Option<LogMessageType> {
295+
self.parser
296+
.check_payload(payload, param.web_sphere_mq_parse_conf.decompress_enabled)
296297
}
297298

298299
fn parse_payload(&mut self, payload: &[u8], param: &ParseParam) -> Result<L7ParseResult> {
@@ -303,6 +304,8 @@ impl L7ProtocolParserInterface for WebSphereMqLog {
303304

304305
let custom_policies =
305306
config.get_custom_field_policies(L7Protocol::WebSphereMq.into(), param);
307+
let parse_xml_enabled = param.web_sphere_mq_parse_conf.parse_xml_enabled;
308+
let decompress_enabled = param.web_sphere_mq_parse_conf.decompress_enabled;
306309
let mut pos = 0;
307310
let mut loop_count = 0;
308311
let mut results: Vec<L7ProtocolInfo> = Vec::with_capacity(Self::INIT_L7_RESULT_CAPACITY);
@@ -311,11 +314,16 @@ impl L7ProtocolParserInterface for WebSphereMqLog {
311314
let parsed_size = self.parser.parse_payload(
312315
&payload[pos..],
313316
param.direction,
314-
param.web_sphere_mq_parse_conf.parse_xml_enabled,
317+
parse_xml_enabled,
318+
decompress_enabled,
315319
);
316320
if parsed_size == 0 {
317321
break;
318322
}
323+
if self.parser.skip_frame {
324+
pos += parsed_size;
325+
continue;
326+
}
319327
let mut info = WebSphereMqInfo::default();
320328
info.is_tls = param.is_tls();
321329
info.base.is_async = true;

server/agent_config/README-CH.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8114,6 +8114,36 @@ processors:
81148114

81158115
是否解析 XML 数据内容。
81168116

8117+
###### 解压数据包 {#processors.request_log.application_protocol_inference.protocol_special_config.web_sphere_mq.decompress_enabled}
8118+
8119+
**标签**:
8120+
8121+
<mark>agent_restart</mark>
8122+
<mark>ee_feature</mark>
8123+
8124+
**FQCN**:
8125+
8126+
`processors.request_log.application_protocol_inference.protocol_special_config.web_sphere_mq.decompress_enabled`
8127+
8128+
**默认值**:
8129+
```yaml
8130+
processors:
8131+
request_log:
8132+
application_protocol_inference:
8133+
protocol_special_config:
8134+
web_sphere_mq:
8135+
decompress_enabled: true
8136+
```
8137+
8138+
**模式**:
8139+
| Key | Value |
8140+
| ---- | ---------------------------- |
8141+
| Type | bool |
8142+
8143+
**详细描述**:
8144+
8145+
部分 web_sphere_mq 的消息中使用 zlib 压缩,开启此选项后,agent 在解析时会对数据包进行解压。
8146+
81178147
##### MySQL {#processors.request_log.application_protocol_inference.protocol_special_config.mysql}
81188148

81198149
###### 解压 MySQL 数据包 {#processors.request_log.application_protocol_inference.protocol_special_config.mysql.decompress_payload}

server/agent_config/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8297,6 +8297,37 @@ processors:
82978297

82988298
Whether to parse XML.
82998299

8300+
###### Decompress Payload {#processors.request_log.application_protocol_inference.protocol_special_config.web_sphere_mq.decompress_enabled}
8301+
8302+
**Tags**:
8303+
8304+
<mark>agent_restart</mark>
8305+
<mark>ee_feature</mark>
8306+
8307+
**FQCN**:
8308+
8309+
`processors.request_log.application_protocol_inference.protocol_special_config.web_sphere_mq.decompress_enabled`
8310+
8311+
**Default value**:
8312+
```yaml
8313+
processors:
8314+
request_log:
8315+
application_protocol_inference:
8316+
protocol_special_config:
8317+
web_sphere_mq:
8318+
decompress_enabled: true
8319+
```
8320+
8321+
**Schema**:
8322+
| Key | Value |
8323+
| ---- | ---------------------------- |
8324+
| Type | bool |
8325+
8326+
**Description**:
8327+
8328+
Some web_sphere_mq messages use zlib compression. When this option is enabled,
8329+
the agent will decompress the data packets during parsing.
8330+
83008331
##### MySQL {#processors.request_log.application_protocol_inference.protocol_special_config.mysql}
83018332

83028333
###### Decompress MySQL Payload {#processors.request_log.application_protocol_inference.protocol_special_config.mysql.decompress_payload}

server/agent_config/template.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5898,6 +5898,22 @@ processors:
58985898
# ch: |-
58995899
# 是否解析 XML 数据内容。
59005900
parse_xml_enabled: true
5901+
# type: bool
5902+
# name:
5903+
# en: Decompress Payload
5904+
# ch: 解压数据包
5905+
# unit:
5906+
# range: []
5907+
# enum_options: []
5908+
# modification: agent_restart
5909+
# ee_feature: true
5910+
# description:
5911+
# en: |-
5912+
# Some web_sphere_mq messages use zlib compression. When this option is enabled,
5913+
# the agent will decompress the data packets during parsing.
5914+
# ch: |-
5915+
# 部分 web_sphere_mq 的消息中使用 zlib 压缩,开启此选项后,agent 在解析时会对数据包进行解压。
5916+
decompress_enabled: true
59015917
# type: section
59025918
# name: MySQL
59035919
# description:

0 commit comments

Comments
 (0)