如何在 STOMP CONNECTED 服务器 header 中隐藏 ActiveMQ 代理版本?

How to hide ActiveMQ broker version in STOMP CONNECTED server header?

我想满足 OWASP ASVS 14.3.3 要求,即:

14.3.3 Verify that the HTTP headers or any part of the HTTP response do not expose detailed version information of system components.

对于 ActiveMQ 代理。 STOMP 协议 CONNECTED 消息有问题,如下所示:

CONNECTED
server:ActiveMQ/5.15.9
heart-beat:0,10000
session:ID:localhost.local-36323-1578488170638-3:15
version:1.2
user-name:user@example.com

并向(假设的邪恶者)透露我的 ActiveMQ 经纪人版本 所以我的问题是如何隐藏整个 server header 或者如果不可能隐藏它的版本部分。

这可以通过一些小技巧来完成

  1. As header server 由代码中的常量BROKER_VERSION设置 here
  2. 并且从类路径位置 /org/apache/activemq/version.txt
  3. 读取 here 常量 BROKER_VERSION 的值
  4. 我们必须重写 /org/apache/activemq/version.txt 的内容,它令人惊讶地位于 activemq-client