use of com.contrastsecurity.sarif.PropertyBag 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.PropertyBag 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;
}
use of com.contrastsecurity.sarif.PropertyBag in project bsl-language-server by 1c-syntax.
the class SarifReporter method createInvocation.
private Invocation createInvocation() {
Set<ConfigurationOverride> ruleConfigurationOverrides = new HashSet<>();
var diagnosticsOptions = configuration.getDiagnosticsOptions();
diagnosticsOptions.getParameters().forEach((String key, Either<Boolean, Map<String, Object>> option) -> {
var descriptor = new ReportingDescriptorReference().withId(key);
var configurationOverride = new ConfigurationOverride().withDescriptor(descriptor);
var reportingConfiguration = new ReportingConfiguration();
if (option.isLeft()) {
reportingConfiguration.setEnabled(option.getLeft());
} else {
var parameters = new PropertyBag();
var diagnosticParameters = option.getRight();
diagnosticParameters.forEach(parameters::setAdditionalProperty);
reportingConfiguration.setParameters(parameters);
}
configurationOverride.withConfiguration(reportingConfiguration);
ruleConfigurationOverrides.add(configurationOverride);
});
ArtifactLocation workingDirectory = new ArtifactLocation().withUri(Absolute.uri(new File(".").toURI()).toString());
return new Invocation().withExecutionSuccessful(true).withRuleConfigurationOverrides(ruleConfigurationOverrides).withWorkingDirectory(workingDirectory).withProcessId((int) ProcessHandle.current().pid());
}
Aggregations