容器化部署时,每次主机重启会在云控端新注册主机记录
- Dominant language
- C++
- Stars
- 3k
- Forks
- 622
- PR merge metrics
- No merged PRs in 30d
Description
# Bug report
我们容器化部署时,每次重新发布应用,会在云控端重新注册主机;
step 1. 现在容器上运行着应用 ssdlc,云控端看到主机 10.47.58.61 在线;
step 2. ssdlc重新发布,会重建容器,mac地址不一样,云控端发现新注册主机10.47.58.61;step1的记录变离线;
And please include the following information:
- centos 6.7
- tomcat 8.5.53
- jdk 1.8.0_181
- OpenRASP version 1.3.3
看文档,可以在 openrasp.yam文件里面设置 rasp.id参数,但是我们部署应用的时候,不知道该设置成什么值?
不如让应用程序首次启动时自动生成,并写入openrasp.yam或者另外的文件。
# Feature Request
现在Bypass方案,是rasp第一次启动的时候,自动生成rasp.id,后续应用重启直接读取第一次生成的rasp.id
修改了javaAgent的两个文件:
Config.java
-------------------------------------------------------------------
static final String CONFIG_RASP_ID = "rasp.id";
public String getRaspIdConfig() {
return this.configFileDir + File.separator + CONFIG_RASP_ID;
}
public void setRaspId(String raspId) {
this.raspId = raspId;
}
-------------------------------------------------------------------
OSUtil.java
-------------------------------------------------------------------
public static String getRaspId() throws Exception {
if (!StringUtils.isEmpty(Config.getConfig().getRaspId())) {
return Config.getConfig().getRaspId();
}
String raspId = getRaspIdFromFile();
Config.getConfig().setRaspId(raspId);
return raspId;
}
/**
* 每个Rasp首次启动生成一个Id后,序列化到rasp.id文件
* 防止Padis容器化部署重新生成Id
*/
private static String getRaspIdFromFile() {
try {
File file = new File(Config.getConfig().getRaspIdConfig());
if (file.exists()) {
return FileUtil.readFileByFile(file);
}
return produceRaspId(file);
} catch (Exception ex) {
LOGGER.info("set rasp.id error.", ex);
return "UNKNOWN";
}
}
private static String produceRaspId(File file) throws IOException, NoSuchAlgorithmException {
// ToDo: 文件操作 TRY-CATCH-FINALLY
FileWriter fw = new FileWriter(file);
LinkedList macs = OSUtil.getMacAddress();
String macString = "";
for (String mac : macs) {
macString += mac;
}
String raspId = getDigestMd5(macString + Config.getConfig().getBaseDirectory() + getHostName());
fw.write(raspId);
fw.close();
return raspId;
}
Contributor guide
Research direction
Start with the Java agent's Config.java and OSUtil.java, especially getRaspId() and the rasp.id configuration path, then trace where the ID is used during host registration. Verify how the ID file behaves across container recreation and define done as repeated deployments retaining one host identity instead of creating duplicate cloud records.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- centos, java
- Domain
- devops, security
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100