io.codemodder.remediation.missingsecureflag.MissingSecureFlagRemediator Maven / Gradle / Ivy
package io.codemodder.remediation.missingsecureflag;
import com.github.javaparser.ast.CompilationUnit;
import com.github.javaparser.ast.expr.MethodCallExpr;
import io.codemodder.CodemodFileScanningResult;
import io.codemodder.codetf.DetectorRule;
import io.codemodder.remediation.*;
import java.util.Collection;
import java.util.Optional;
import java.util.function.Function;
public final class MissingSecureFlagRemediator implements Remediator {
private final SearcherStrategyRemediator searchStrategyRemediator;
public MissingSecureFlagRemediator() {
this.searchStrategyRemediator =
new SearcherStrategyRemediator.Builder()
.withSearcherStrategyPair(
new FixCandidateSearcher.Builder()
.withMatcher(
node ->
Optional.of(node)
.map(n -> n instanceof MethodCallExpr ? (MethodCallExpr) n : null)
.filter(mce -> "addCookie".equals(mce.getNameAsString()))
.filter(mce -> mce.getArguments().size() == 1)
.isPresent())
.build(),
new MissingSecureFlagFixStrategy())
.build();
}
@Override
public CodemodFileScanningResult remediateAll(
CompilationUnit cu,
String path,
DetectorRule detectorRule,
Collection findingsForPath,
Function findingIdExtractor,
Function findingStartLineExtractor,
Function> findingEndLineExtractor,
Function> findingColumnExtractor) {
return searchStrategyRemediator.remediateAll(
cu,
path,
detectorRule,
findingsForPath,
findingIdExtractor,
findingStartLineExtractor,
findingEndLineExtractor,
findingColumnExtractor);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy