HXSecurity / DongTai-agent-java

Java Agent is a Java application probe of DongTai IAST, which collects method invocation data during runtime of Java application by dynamic hooks.
https://dongtai.io
Apache License 2.0
681 stars 191 forks source link

[Bug]: agent在wndows下运行时,无法注册,报错 #403

Closed a1576471428 closed 1 year ago

a1576471428 commented 1 year ago

Preflight Checklist

Version

latest

Installation Type

Official Kubernetes

Service Name

DongTai-Web

Describe the details of the bug and the steps to reproduce it

下载agent后在windows下运行(运行命令java -javaagent:dongtai-agent.jar -jar xxx.jar),报错注册失败: 2022-11-03 09:00:11 [io.dongtai.iast.agent] [ERROR] Register msg: {"status": 202, "msg": "\u63a2\u9488\u6ce8\u518c\u5931\u8d25"}

Additional Information

查看服务端日志,疑似编码问题。 相关日志: ERROR 2022-11-03 10:28:09,614 [agent_register.post:298] 探针注册失败,原因:'utf-8' codec can't decode byte 0xbb in position 480: invalid start byte Traceback (most recent call last): File "/opt/dongtai/./dongtai_protocol/views/agent_register.py", line 272, in post self.register_server( File "/opt/dongtai/./dongtai_protocol/views/agent_register.py", line 122, in register_server env = base64.b64decode(server_env).decode('utf-8') UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbb in position 480: invalid start byte [pid: 25|app: 0|req: 1/5] 10.42.178.223 () {42 vars in 643 bytes} [Thu Nov 3 10:28:08 2022] POST /api/v1/agent/register => generated 62

Logs

ERROR 2022-11-03 10:28:09,614 [agent_register.post:298] 探针注册失败,原因:'utf-8' codec can't decode byte 0xbb in position 480: invalid start byte
Traceback (most recent call last):
  File "/opt/dongtai/./dongtai_protocol/views/agent_register.py", line 272, in post
    self.register_server(
  File "/opt/dongtai/./dongtai_protocol/views/agent_register.py", line 122, in register_server
    env = base64.b64decode(server_env).decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbb in position 480: invalid start byte
[pid: 25|app: 0|req: 1/5] 10.42.178.223 () {42 vars in 643 bytes} [Thu Nov  3 10:28:08 2022] POST /api/v1/agent/register => generated 62
Bidaya0 commented 1 year ago

This is caused by the encoding problem of the runtime environment. The temporary solution can be changed from gbk to utf-8 encoding.