This is an automated email from the ASF dual-hosted git repository.

zhangxiaowei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozhera.git


The following commit(s) were added to refs/heads/master by this push:
     new 32ce7a87 fix: verify whether the Agent request body is in valid JSON 
format (#642)
32ce7a87 is described below

commit 32ce7a87ddee7657e723ffdb7019a221d9aa6fe3
Author: wtt <[email protected]>
AuthorDate: Mon Mar 16 17:21:00 2026 +0800

    fix: verify whether the Agent request body is in valid JSON format (#642)
    
    * fix: solve the blocking problem caused by serverless startup
    
    * fix: fix pipeline execution logic error
    
    * fix: verify whether the Agent request body is in valid JSON format
    
    * fix: fix json request parsing logic
---
 ozhera-log/log-agent-server/pom.xml                  |  3 ++-
 .../porcessor/AgentCollectProgressProcessor.java     | 20 +++++++++++++-------
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/ozhera-log/log-agent-server/pom.xml 
b/ozhera-log/log-agent-server/pom.xml
index 8e660cc7..f81737c8 100644
--- a/ozhera-log/log-agent-server/pom.xml
+++ b/ozhera-log/log-agent-server/pom.xml
@@ -26,7 +26,8 @@ http://www.apache.org/licenses/LICENSE-2.0
         <version>2.2.6-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
-    <version>2.2.11-SNAPSHOT</version>
+<!--    <version>2.2.11-SNAPSHOT</version>-->
+    <version>2.2.12-SNAPSHOT</version>
 
     <artifactId>log-agent-server</artifactId>
 
diff --git 
a/ozhera-log/log-agent-server/src/main/java/org/apache/ozhera/log/server/porcessor/AgentCollectProgressProcessor.java
 
b/ozhera-log/log-agent-server/src/main/java/org/apache/ozhera/log/server/porcessor/AgentCollectProgressProcessor.java
index b9c91f5f..3732dd10 100644
--- 
a/ozhera-log/log-agent-server/src/main/java/org/apache/ozhera/log/server/porcessor/AgentCollectProgressProcessor.java
+++ 
b/ozhera-log/log-agent-server/src/main/java/org/apache/ozhera/log/server/porcessor/AgentCollectProgressProcessor.java
@@ -18,6 +18,7 @@
  */
 package org.apache.ozhera.log.server.porcessor;
 
+import cn.hutool.json.JSONUtil;
 import com.google.common.util.concurrent.RateLimiter;
 import com.xiaomi.data.push.rpc.common.CompressionUtil;
 import com.xiaomi.data.push.rpc.netty.NettyRequestProcessor;
@@ -91,18 +92,23 @@ public class AgentCollectProgressProcessor implements 
NettyRequestProcessor {
 
         try {
             bodyStr = new String(bodyBytes, StandardCharsets.UTF_8);
-            UpdateLogProcessCmd cmd = GSON.fromJson(bodyStr, 
UpdateLogProcessCmd.class);
-            if (StringUtils.isBlank(cmd.getIp())) {
-                log.warn("Invalid agent request, ip={}, body={}", getIp(ctx), 
brief(bodyStr));
-                return null;
+            if (JSONUtil.isTypeJSON(bodyStr)) {
+                UpdateLogProcessCmd cmd = GSON.fromJson(bodyStr, 
UpdateLogProcessCmd.class);
+                if (StringUtils.isBlank(cmd.getIp())) {
+                    log.warn("Invalid agent request, ip={}, body={}", 
getIp(ctx), brief(bodyStr));
+                    return null;
+                }
+                log.debug("Parsed request from agent: ip={}", cmd.getIp());
+                return cmd;
             }
-            log.debug("Parsed request from agent: ip={}", cmd.getIp());
-            return cmd;
         } catch (Exception ignored) {
         }
-
         try {
             bodyStr = new String(CompressionUtil.decompress(bodyBytes), 
StandardCharsets.UTF_8);
+            if (!JSONUtil.isTypeJSON(bodyStr)) {
+                log.warn("Invalid agent request, ip={}, body={}", getIp(ctx), 
brief(bodyStr));
+                return null;
+            }
             UpdateLogProcessCmd cmd = GSON.fromJson(bodyStr, 
UpdateLogProcessCmd.class);
             log.debug("Parsed decompressed request from agent: ip={}", 
cmd.getIp());
             return cmd;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to