提交 868822a5 authored 作者: 马晨俊's avatar 马晨俊

mcj:新增文件名称匹配,修改kmp匹配bug

上级 54d56c08
...@@ -306,6 +306,7 @@ public class Inspector { ...@@ -306,6 +306,7 @@ public class Inspector {
if (path1.toAbsolutePath().toString().endsWith("jar") || path1.toAbsolutePath().toString().endsWith("class")) { if (path1.toAbsolutePath().toString().endsWith("jar") || path1.toAbsolutePath().toString().endsWith("class")) {
continue; continue;
} }
valiWarn(rules, path1, path1.getFileName().toString(), 0);
//将文件的每一行都与规则匹配 //将文件的每一行都与规则匹配
List<String> strings = Files.readAllLines(path1); List<String> strings = Files.readAllLines(path1);
for (int i = 0; i < strings.size(); i++) { for (int i = 0; i < strings.size(); i++) {
...@@ -446,15 +447,13 @@ public class Inspector { ...@@ -446,15 +447,13 @@ public class Inspector {
rule.setTechnologyId(techJavaSupport.getId()); rule.setTechnologyId(techJavaSupport.getId());
rule.setTarget(dependency.getGroupId()); rule.setTarget(dependency.getGroupId());
rule.setTechnologyName(techJavaSupport.getTechnologyName()); rule.setTechnologyName(techJavaSupport.getTechnologyName());
//?
rule.setSuffix("*"); rule.setSuffix("*");
rule.setId(UUIDUtil.getUUID()); rule.setId(UUIDUtil.getUUID());
Rule rule1 = new Rule(); Rule rule1 = new Rule();
rule1.setTechnologyId(techJavaSupport.getId()); rule1.setTechnologyId(techJavaSupport.getId());
rule1.setTarget(dependency.getArtifactId()); rule1.setTarget(dependency.getArtifactId());
rule.setTechnologyName(techJavaSupport.getTechnologyName()); rule1.setTechnologyName(techJavaSupport.getTechnologyName());
//?
rule1.setSuffix("*"); rule1.setSuffix("*");
rule1.setId(UUIDUtil.getUUID()); rule1.setId(UUIDUtil.getUUID());
...@@ -495,7 +494,7 @@ public class Inspector { ...@@ -495,7 +494,7 @@ public class Inspector {
//匹配字符串 //匹配字符串
int index = KmpUtil.kmpMatch(data, rule.getTarget()); int index = KmpUtil.kmpMatch(data, rule.getTarget());
//当index>0时代表data中有当前规则 //当index>0时代表data中有当前规则
if (index > 0) { if (index > -1) {
//判断当前规则是否是不支持规则 //判断当前规则是否是不支持规则
Warn warn = new Warn(); Warn warn = new Warn();
//如果是不支持规则则需要保存匹配信息 //如果是不支持规则则需要保存匹配信息
...@@ -529,4 +528,9 @@ public class Inspector { ...@@ -529,4 +528,9 @@ public class Inspector {
return i; return i;
} }
} }
public static void main(String[] args) {
int vue = KmpUtil.kmpMatch("vue.js", "vue");
System.out.println(vue);
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论