use of org.sonar.db.rule.RuleDefinitionDto in project sonarqube by SonarSource.
the class HotspotRuleDescriptionTest method parse_with_noncompliant_section_not_removed.
@Test
public void parse_with_noncompliant_section_not_removed() {
RuleDefinitionDto dto = RuleTesting.newRule().setDescription(DESCRIPTION + NONCOMPLIANTCODE + COMPLIANTCODE);
HotspotRuleDescription result = HotspotRuleDescription.from(dto);
assertThat(result.getRisk()).contains(DESCRIPTION);
assertThat(result.getVulnerable()).contains(NONCOMPLIANTCODE);
assertThat(result.getFixIt()).contains(COMPLIANTCODE);
}
use of org.sonar.db.rule.RuleDefinitionDto in project sonarqube by SonarSource.
the class HotspotRuleDescriptionTest method parse_moved_noncompliant_code.
@Test
public void parse_moved_noncompliant_code() {
RuleDefinitionDto dto = RuleTesting.newRule().setDescription(DESCRIPTION + RECOMMENTEDCODINGPRACTICE + NONCOMPLIANTCODE + SEE);
HotspotRuleDescription result = HotspotRuleDescription.from(dto);
assertThat(result.getRisk()).contains(DESCRIPTION);
assertThat(result.getVulnerable()).contains(NONCOMPLIANTCODE);
assertThat(result.getFixIt()).contains(RECOMMENTEDCODINGPRACTICE + SEE);
}
use of org.sonar.db.rule.RuleDefinitionDto in project sonarqube by SonarSource.
the class HotspotRuleDescriptionTest method parse_return_null_fixIt_when_desc_has_no_Recommended_Secure_Coding_Practices_title.
@Test
public void parse_return_null_fixIt_when_desc_has_no_Recommended_Secure_Coding_Practices_title() {
RuleDefinitionDto dto = RuleTesting.newRule().setDescription(DESCRIPTION + ASKATRISK);
HotspotRuleDescription result = HotspotRuleDescription.from(dto);
assertThat(result.getRisk()).contains(DESCRIPTION);
assertThat(result.getVulnerable()).contains(ASKATRISK);
assertThat(result.getFixIt()).isEmpty();
}
use of org.sonar.db.rule.RuleDefinitionDto in project sonarqube by SonarSource.
the class RuleIndexerTest method log_debug_when_hotspot_rule_description_is_missing_vulnerable_tab_content.
@Test
public void log_debug_when_hotspot_rule_description_is_missing_vulnerable_tab_content() {
RuleDefinitionDto rule = dbTester.rules().insert(RuleTesting.newRule().setType(RuleType.SECURITY_HOTSPOT).setDescription("bar\n" + "<h2>Recommended Secure Coding Practices</h2>\n" + "foo"));
underTest.commitAndIndex(dbTester.getSession(), rule.getUuid());
assertThat(logTester.getLogs()).hasSize(1);
assertThat(logTester.logs(LoggerLevel.DEBUG).get(0)).isEqualTo(format("Description of Security Hotspot Rule %s can't be fully parsed: What is the risk?=ok, Are you vulnerable?=missing, How to fix it=ok", rule.getKey()));
}
use of org.sonar.db.rule.RuleDefinitionDto in project sonarqube by SonarSource.
the class RuleIndexerTest method index_long_rule_description.
@Test
public void index_long_rule_description() {
String description = IntStream.range(0, 100000).map(i -> i % 100).mapToObj(Integer::toString).collect(joining(" "));
RuleDefinitionDto rule = dbTester.rules().insert(r -> r.setDescription(description));
underTest.commitAndIndex(dbTester.getSession(), rule.getUuid());
assertThat(es.countDocuments(TYPE_RULE)).isOne();
}
Aggregations