All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.codemodder.providers.sarif.semgrep.SemgrepRuleSarifFactory Maven / Gradle / Ivy

There is a newer version: 0.97.8
Show newest version
package io.codemodder.providers.sarif.semgrep;

import static io.codemodder.providers.sarif.semgrep.SemgrepProvider.semgrepToolNames;

import com.contrastsecurity.sarif.SarifSchema210;
import io.codemodder.CodeDirectory;
import io.codemodder.RuleSarif;
import io.codemodder.RuleSarifFactory;
import java.util.Optional;

/** A factory for building {@link SingleSemgrepRuleSarif}s. */
public class SemgrepRuleSarifFactory implements RuleSarifFactory {

  @Override
  public Optional build(
      final String toolName,
      final String rule,
      final String messageText,
      final SarifSchema210 sarif,
      final CodeDirectory codeDirectory) {

    if (semgrepToolNames.stream()
        .map(String::toLowerCase)
        .toList()
        .contains(toolName.toLowerCase())) {
      return Optional.of(new SingleSemgrepRuleSarif(rule, sarif, codeDirectory.asPath()));
    }
    return Optional.empty();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy