Search in sources :

Example 1 with HotspotRuleDescription

use of org.sonar.server.rule.HotspotRuleDescription in project sonarqube by SonarSource.

the class ShowAction method formatRule.

private static void formatRule(ShowWsResponse.Builder responseBuilder, RuleDefinitionDto ruleDefinitionDto) {
    SecurityStandards securityStandards = SecurityStandards.fromSecurityStandards(ruleDefinitionDto.getSecurityStandards());
    SecurityStandards.SQCategory sqCategory = securityStandards.getSqCategory();
    Hotspots.Rule.Builder ruleBuilder = Hotspots.Rule.newBuilder().setKey(ruleDefinitionDto.getKey().toString()).setName(nullToEmpty(ruleDefinitionDto.getName())).setSecurityCategory(sqCategory.getKey()).setVulnerabilityProbability(sqCategory.getVulnerability().name());
    HotspotRuleDescription hotspotRuleDescription = HotspotRuleDescription.from(ruleDefinitionDto);
    hotspotRuleDescription.getVulnerable().ifPresent(ruleBuilder::setVulnerabilityDescription);
    hotspotRuleDescription.getRisk().ifPresent(ruleBuilder::setRiskDescription);
    hotspotRuleDescription.getFixIt().ifPresent(ruleBuilder::setFixRecommendations);
    responseBuilder.setRule(ruleBuilder.build());
}
Also used : HotspotRuleDescription(org.sonar.server.rule.HotspotRuleDescription) SecurityStandards(org.sonar.server.security.SecurityStandards)

Aggregations

HotspotRuleDescription (org.sonar.server.rule.HotspotRuleDescription)1 SecurityStandards (org.sonar.server.security.SecurityStandards)1