优化准则

wuhaoyang
wuhaoyang 10 months ago
parent 8dbb0daa4a
commit 395f16889e
  1. 4
      sonar-keyware-plugins-java/src/main/java/com/keyware/sonar/java/ConfigFileSquidSensor.java
  2. 2
      sonar-keyware-plugins-java/src/main/java/com/keyware/sonar/java/rules/checkers/DynamicCodeChecker.java
  3. 2
      sonar-keyware-plugins-java/src/main/java/com/keyware/sonar/java/rules/checkers/HashSaltPassWordChecker.java
  4. 2
      sonar-keyware-plugins-java/src/main/java/com/keyware/sonar/java/rules/checkers/Md5PassWordVerifyChecker.java
  5. 2
      sonar-keyware-plugins-java/src/main/java/com/keyware/sonar/java/rules/checkers/RedirectUrlChecker.java

@ -16,9 +16,12 @@ import org.sonar.api.batch.rule.Checks;
import org.sonar.api.batch.sensor.Sensor;
import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.batch.sensor.SensorDescriptor;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
public class ConfigFileSquidSensor implements Sensor {
private final Logger LOG = Loggers.get(ConfigFileSquidSensor.class);
private final Checks<ConfigCheck> checks;
private SensorContext context;
@ -39,6 +42,7 @@ public class ConfigFileSquidSensor implements Sensor {
@Override
public void execute(SensorContext context) {
FilePredicates p = context.fileSystem().predicates();
LOG.info("ConfigFileSquidSensor FileSystem class is: {}", context.fileSystem().getClass().getName());
for (InputFile inputFile : context.fileSystem().inputFiles(p.hasLanguages(ConfigurationFileLanguage.KEY))) {
checks.all().forEach(check -> {
check.execute(context, inputFile, checks.ruleKey(check));

@ -35,7 +35,7 @@ public class DynamicCodeChecker extends IssuableSubscriptionVisitor {
@Override
public void visitNode(Tree tree) {
MethodInvocationTree node = (MethodInvocationTree) tree;
System.out.println(node);
var expressionTree = node.methodSelect();
if (expressionTree instanceof MemberSelectExpressionTree) {
var exprTree = (MemberSelectExpressionTree) expressionTree;

@ -71,6 +71,8 @@ public class HashSaltPassWordChecker extends IssuableSubscriptionVisitor {
if(!identifierTree.name().equals(strPassWord)){
checker.context.reportIssue(checker, identifierTree, "应使用盐值计算口令");
}
}else {
checker.context.reportIssue(checker, expressionTree1, "应使用盐值计算口令");
}
}
}

@ -71,6 +71,8 @@ public class Md5PassWordVerifyChecker extends IssuableSubscriptionVisitor {
if(!identifierTree.name().equals(strPassWord)){
checker.context.reportIssue(checker, identifierTree, "应使用单向不可逆的加密算法");
}
}else {
checker.context.reportIssue(checker, expressionTree1, "应使用单向不可逆的加密算法");
}
}
}

@ -138,7 +138,7 @@ public class RedirectUrlChecker extends IssuableSubscriptionVisitor {
ExpressionTree expressionTree = invocationTree.methodSelect();
if (expressionTree instanceof MemberSelectExpressionTree) {
MemberSelectExpressionTree member = (MemberSelectExpressionTree) expressionTree;
if (member.expression().symbolType().is("RedirectView")
if (member.expression().symbolType().is("org.springframework.web.servlet.view.RedirectView")
&& "setUrl".equals(member.identifier().name())) {
ExpressionTree argNode = invocationTree.arguments().get(0);
checkArgs(argNode, invocationTree);

Loading…
Cancel
Save