我目前正在从一个.audit文件中填充一个列表,并将两部分信息提取到一个映射中。下面是文件的外观:
type : REGISTRY_SETTING
description : "1.9.56 Network security: Do not store LAN Manager hash value on next password change: Enabled"
info : "This control defines whether the LAN Manager (LM) hash value for the new password is stored when the password is changed."
solution : "Make sure 'Do not store LAN Manager hash value on next password change' is Enabled."
reference : "PCI-DSS|8.4,800-53|AC-3,800-53|SC-5,800-53|CM-7,800-53|CM-6,CCE|CCE-8937-5"
see_also : "https://benchmarks.cisecurity.org/tools2/windows/CIS_Microsoft_Windows_7_Benchmark_v1.2.0.pdf"
value_type : POLICY_DWORD
reg_key : "HKLM\System\CurrentControlSet\Control\Lsa"
reg_item : "NoLMHash"
value_data : 1
type : REGISTRY_SETTING
description : "1.13.3 Notify antivirus programs when opening attachments: Enabled"
info : "This control defines whether antivirus program to be notified when opening attachments."
solution : "Make sure 'Notify antivirus programs when opening attachments' is Enabled."
reference : "800-53|SI-3,PCI-DSS|5.1.1,CCE|CCE-10076-8,PCI-DSS|5.1"
see_also : "https://benchmarks.cisecurity.org/tools2/windows/CIS_Microsoft_Windows_7_Benchmark_v1.2.0.pdf"
value_type : POLICY_DWORD
reg_key : "HKU\Software\Microsoft\Windows\CurrentVersion\Policies\Attachments"
reg_item : "ScanWithAntiVirus"
value_data : 3
reg_ignore_hku_users : "S-1-5-18,S-1-5-19,S-1-5-20"我需要的地图是一个<description,value_data>格式,无论是否有任何东西在value_data之后,例如:
Key: "1.9.56 Network security: Do not store LAN Manager hash value on next password changed."
Value: 1 下面是我用Map的键值填充Map的当前代码:
String descriptionString = Pattern.quote("description") + "(.*?)" + Pattern.quote("info");
Pattern descriptionPattern = Pattern.compile(descriptionString);
Matcher descriptionMatcher = descriptionPattern.matcher(auditContentList.get(i));
while(descriptionMatcher.find())
{
System.out.println("Key found ");
customItemMap.put(descriptionMatcher.group(1),"");
}问题是我不能在任何给定的时间同时使用两个正则表达式来填充Map的相同索引。有没有更好的方法来做到这一点?
发布于 2016-06-20 19:46:34
https://stackoverflow.com/questions/37914003
复制相似问题