use of com.contrastsecurity.sarif.ReportingDescriptor in project bsl-language-server by 1c-syntax.
the class SarifReporter method createReportingDescriptor.
private static ReportingDescriptor createReportingDescriptor(DiagnosticInfo diagnosticInfo) {
var id = diagnosticInfo.getCode().getStringValue();
var name = diagnosticInfo.getName();
var fullDescription = new MultiformatMessageString().withText(diagnosticInfo.getDescription()).withMarkdown(diagnosticInfo.getDescription());
var helpUri = URI.create(diagnosticInfo.getDiagnosticCodeDescriptionHref());
var parameters = new PropertyBag();
diagnosticInfo.getParameters().forEach(parameterInfo -> parameters.withAdditionalProperty(parameterInfo.getName(), parameterInfo.getDefaultValue()));
var defaultConfiguration = new ReportingConfiguration().withEnabled(diagnosticInfo.isActivatedByDefault()).withLevel(severityToReportLevel.get(diagnosticInfo.getLSPSeverity())).withParameters(parameters);
var tags = diagnosticInfo.getTags().stream().map(Enum::name).collect(Collectors.toSet());
var properties = new PropertyBag().withTags(tags);
return new ReportingDescriptor().withId(id).withName(name).withFullDescription(fullDescription).withHelpUri(helpUri).withDefaultConfiguration(defaultConfiguration).withProperties(properties);
}
use of com.contrastsecurity.sarif.ReportingDescriptor in project aws-codeguru-cli by aws.
the class ResultsAdapter method createSarifRuleDescriptions.
private static Map<String, ReportingDescriptor> createSarifRuleDescriptions(final List<RecommendationSummary> recommendations) {
val rulesMap = new HashMap<String, ReportingDescriptor>();
for (val recommendation : recommendations) {
val metaData = recommendation.ruleMetadata();
if (metaData != null && !rulesMap.containsKey(metaData.ruleId())) {
val properties = new PropertyBag().withTags(new HashSet<>(metaData.ruleTags()));
MultiformatMessageString foo;
val descriptor = new ReportingDescriptor().withName(metaData.ruleName()).withId(metaData.ruleId()).withShortDescription(new MultiformatMessageString().withText(metaData.ruleName())).withFullDescription(new MultiformatMessageString().withText(metaData.shortDescription())).withHelp(new MultiformatMessageString().withText(metaData.longDescription())).withProperties(properties);
if (recommendation.severityAsString() != null) {
val level = ReportingConfiguration.Level.fromValue(getSarifSeverity(recommendation));
descriptor.setDefaultConfiguration(new ReportingConfiguration().withLevel(level));
}
rulesMap.put(metaData.ruleId(), descriptor);
}
}
return rulesMap;
}
Aggregations