Hi,
I am using SonarQube (9.7-community docker container) have developed a simple plugin using the given example to register a simple rule and using a sensor to create some issues. I can see my code has executed on the logs both to register the rule as well as creating issues. But, I don’t see the rule or the issues on the dashboard. Can someone please give me some tips on what might be the issue here?
public class ExternalAnalyzerRulesDefinition implements RulesDefinition {
private static final Logger LOGGER = Loggers.get(ExternalAnalyzerRulesDefinition.class);
@Override
public void define(Context context) {
LOGGER.info("ExternalAnalyzerRulesDefinition: Start defining the rule set");
NewRepository repository = context.createRepository(Constants.REPOSITORY_KEY, Constants.LANGUAGE_KEY).setName("External Analyzer Rules");
createRule(repository);
repository.done();
LOGGER.info("ExternalAnalyzerRulesDefinition: Completed defininig the ruleset");
}
private NewRule createRule(NewRepository repo) {
LOGGER.info("ExternalAnalyzerRulesDefinition: Registering the rule");
NewRule rule = repo.createRule(Constants.RULE_KEY)
.setName("The dynamic value passed to the command execution should be validated.")
.addTags("cwe-78","owasp-a1")
.setSeverity(Severity.MAJOR)
.setStatus(RuleStatus.READY)
.addCwe(78)
.setHtmlDescription("The dynamic value passed to the command execution should be validated.")
.addDescriptionSection(descriptionSection(INTRODUCTION_SECTION_KEY, "If a malicious user controls either the FileName or Arguments, he might be able to execute unwanted commands.."))
.addDescriptionSection(descriptionSection(ROOT_CAUSE_SECTION_KEY, "The root cause of this issue is this and that."))
.addDescriptionSection(descriptionSection(HOW_TO_FIX_SECTION_KEY,"To fix an issue reported by this rule when using Hibernate do this and that."));
LOGGER.info("ExternalAnalyzerRulesDefinition: Completed registering the rule");
return rule;
}
private static RuleDescriptionSection descriptionSection(String sectionKey, String htmlContent) {
return RuleDescriptionSection.builder()
.sectionKey(sectionKey)
.htmlContent(htmlContent)
.build();
}
}
I can see below in the logs:
2022.11.03 05:51:13 INFO web[][o.s.s.r.RegisterRules] Register rules
2022.11.03 05:51:14 INFO web[][o.s.p.e.r.ExternalAnalyzerRulesDefinition] ExternalAnalyzerRulesDefinition: Start defining the rule set
2022.11.03 05:51:14 INFO web[][o.s.p.e.r.ExternalAnalyzerRulesDefinition] ExternalAnalyzerRulesDefinition: Registering the rule
2022.11.03 05:51:14 INFO web[][o.s.p.e.r.ExternalAnalyzerRulesDefinition] ExternalAnalyzerRulesDefinition: Completed registering the rule
2022.11.03 05:51:14 INFO web[][o.s.p.e.r.ExternalAnalyzerRulesDefinition] ExternalAnalyzerRulesDefinition: Completed defininig the ruleset
But in the dashboard, I don’t see any rules when I filter the list of rules by the repository.