io.codemodder.remediation.sqlinjection.SQLInjectionRemediator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of codemodder-base Show documentation
Show all versions of codemodder-base Show documentation
Base framework for writing codemods in Java
package io.codemodder.remediation.sqlinjection;
import com.github.javaparser.ast.CompilationUnit;
import io.codemodder.CodemodFileScanningResult;
import io.codemodder.codetf.DetectorRule;
import io.codemodder.remediation.*;
import java.util.*;
import java.util.function.Function;
/**
* A Remediator for SQL injection issues. This class provides the logic to visit a CompilationUnit
* and process findings for potential SQL injections.
*/
public final class SQLInjectionRemediator implements Remediator {
private final SearcherStrategyRemediator searchStrategyRemediator;
public SQLInjectionRemediator() {
this.searchStrategyRemediator =
new SearcherStrategyRemediator.Builder()
.withSearcherStrategyPair(
new FixCandidateSearcher.Builder()
.withMatcher(
n ->
Optional.empty()
// is the call itself
.or(() -> Optional.of(n).filter(SQLInjectionFixComposer::match))
.isPresent())
.build(),
new SQLInjectionFixComposer())
.build();
}
@Override
public CodemodFileScanningResult remediateAll(
CompilationUnit cu,
String path,
DetectorRule detectorRule,
Collection findingsForPath,
Function findingIdExtractor,
Function findingStartLineExtractor,
Function> findingEndLineExtractor,
Function> findingStartColumnExtractor) {
return searchStrategyRemediator.remediateAll(
cu,
path,
detectorRule,
findingsForPath,
findingIdExtractor,
findingStartLineExtractor,
findingEndLineExtractor,
findingStartColumnExtractor);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy