Search in sources :

Example 1 with ReportingDescriptorReference

use of com.contrastsecurity.sarif.ReportingDescriptorReference 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());
}
Also used : Invocation(com.contrastsecurity.sarif.Invocation) PropertyBag(com.contrastsecurity.sarif.PropertyBag) MultiformatMessageString(com.contrastsecurity.sarif.MultiformatMessageString) ReportingDescriptorReference(com.contrastsecurity.sarif.ReportingDescriptorReference) ConfigurationOverride(com.contrastsecurity.sarif.ConfigurationOverride) Either(org.eclipse.lsp4j.jsonrpc.messages.Either) ArtifactLocation(com.contrastsecurity.sarif.ArtifactLocation) File(java.io.File) ReportingConfiguration(com.contrastsecurity.sarif.ReportingConfiguration) HashSet(java.util.HashSet)

Aggregations

ArtifactLocation (com.contrastsecurity.sarif.ArtifactLocation)1 ConfigurationOverride (com.contrastsecurity.sarif.ConfigurationOverride)1 Invocation (com.contrastsecurity.sarif.Invocation)1 MultiformatMessageString (com.contrastsecurity.sarif.MultiformatMessageString)1 PropertyBag (com.contrastsecurity.sarif.PropertyBag)1 ReportingConfiguration (com.contrastsecurity.sarif.ReportingConfiguration)1 ReportingDescriptorReference (com.contrastsecurity.sarif.ReportingDescriptorReference)1 File (java.io.File)1 HashSet (java.util.HashSet)1 Either (org.eclipse.lsp4j.jsonrpc.messages.Either)1