新增:安全设计准则质量配置

wuhaoyang
Guo XIn 11 months ago
parent 918bd7a7a1
commit 0aa4c3b7ae
  1. 2
      sonar-keyware-plugins-cxx/src/main/java/com/keyware/sonar/cxx/CxxPlugin.java
  2. 5
      sonar-keyware-plugins-cxx/src/main/java/com/keyware/sonar/cxx/rules/SecurityDesignRuleRepository.java
  3. 27
      sonar-keyware-plugins-cxx/src/main/java/com/keyware/sonar/cxx/rules/SecurityDesignWayProfile.java

@ -7,6 +7,7 @@
package com.keyware.sonar.cxx;
import com.keyware.sonar.cxx.rules.SecurityDesignRuleRepository;
import com.keyware.sonar.cxx.rules.SecurityDesignWayProfile;
import org.sonar.api.Plugin;
import org.sonar.cxx.AggregateMeasureComputer;
import org.sonar.cxx.DensityMeasureComputer;
@ -65,6 +66,7 @@ public final class CxxPlugin implements Plugin {
l.add(CxxSonarWayProfile.class);
l.add(CxxRuleRepository.class);
l.add(SecurityDesignRuleRepository.class);
l.add(SecurityDesignWayProfile.class);
// reusable elements
l.addAll(getSensorsImpl());

@ -21,14 +21,15 @@ import java.util.List;
* @date 2024/1/9
*/
public class SecurityDesignRuleRepository implements RulesDefinition {
private final String REPOSITORY_NAME = "C++信息安全性设计准则";
public final static String REPOSITORY_KEY = "cxx-security-design-rules";
public final static String REPOSITORY_NAME = "C++信息安全性设计准则";
// 规则检查器的集合,当有新的规则开发完毕后,需要添加到下面的集合中
private final List<Class> RULE_CHECKERS = Arrays.asList(ABCVarNameChecker.class);
@Override
public void define(Context context) {
var repository = context.createRepository("cxx-security-design-rules", CxxLanguage.KEY).
var repository = context.createRepository(REPOSITORY_KEY, CxxLanguage.KEY).
setName(REPOSITORY_NAME);
new AnnotationBasedRulesDefinition(repository, CxxLanguage.KEY).addRuleClasses(false, RULE_CHECKERS);
repository.done();

@ -0,0 +1,27 @@
/*
* Copyright (c) 2023 - 2024. KeyWare.Co.Ltd All rights reserved.
* 项目名称C++ 信息安全性设计准则
* 项目描述用于检查C++源代码的安全性设计准则的Sonarqube插件
* 版权说明本软件属北京关键科技股份有限公司所有在未获得北京关键科技股份有限公司正式授权情况下任何企业和个人不能获取阅读安装传播本软件涉及的任何受知识产权保护的内容
*/
package com.keyware.sonar.cxx.rules;
import com.keyware.sonar.cxx.CxxLanguage;
import org.sonar.api.server.profile.BuiltInQualityProfilesDefinition;
import org.sonarsource.api.sonarlint.SonarLintSide;
/**
* TODO SecurityDesignWayProfile
*
* @author GuoXin
* @date 2024/1/12
*/
@SonarLintSide
public class SecurityDesignWayProfile implements BuiltInQualityProfilesDefinition {
@Override
public void define(Context context) {
var way = context.createBuiltInQualityProfile("C++信息安全性设计准则", CxxLanguage.KEY);
way.activateRule(SecurityDesignRuleRepository.REPOSITORY_KEY, "ABCVarNameChecker");
way.done();
}
}
Loading…
Cancel
Save