Skip to content
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright 2021-2026 Open Text.
*
* The only warranties for products and services of Open Text
* and its affiliates and licensors ("Open Text") are as may
* be set forth in the express warranty statements accompanying
* such products and services. Nothing herein should be construed
* as constituting an additional warranty. Open Text shall not be
* liable for technical or editorial errors or omissions contained
* herein. The information contained herein is subject to change
* without notice.
*/
package com.fortify.cli.aviator._common.util;

import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;

import org.apache.commons.lang3.StringUtils;

import com.fortify.cli.common.exception.FcliSimpleException;

public final class AviatorIssueIdFilterUtils {
private AviatorIssueIdFilterUtils() {}

public static Set<String> normalizeIssueIds(List<String> issueIds) {
if (issueIds == null) {
return null;
}
Set<String> normalizedIssueIds = issueIds.stream()
.map(StringUtils::trimToNull)
.filter(StringUtils::isNotBlank)
.collect(LinkedHashSet::new, Set::add, Set::addAll);
if (normalizedIssueIds.isEmpty()) {
throw new FcliSimpleException("--issue-ids must contain at least one non-blank issue ID");
}
return normalizedIssueIds;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright 2021-2026 Open Text.
*
* The only warranties for products and services of Open Text
* and its affiliates and licensors ("Open Text") are as may
* be set forth in the express warranty statements accompanying
* such products and services. Nothing herein should be construed
* as constituting an additional warranty. Open Text shall not be
* liable for technical or editorial errors or omissions contained
* herein. The information contained herein is subject to change
* without notice.
*/
package com.fortify.cli.aviator._common.util;

import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;

import com.fortify.cli.aviator.util.FprHandle;
import com.fortify.cli.common.exception.FcliSimpleException;

public final class AviatorLocalFprHelper {
private AviatorLocalFprHelper() {}

public static void validateLocalFprs(List<Path> fprPaths) {
if (fprPaths == null || fprPaths.isEmpty()) {
throw new FcliSimpleException("--fpr must specify at least one FPR file");
}
for (Path fprPath : fprPaths) {
validateLocalFpr(fprPath);
}
}

private static void validateLocalFpr(Path fprPath) {
if (fprPath == null) {
throw new FcliSimpleException("--fpr must specify a valid FPR file path");
}
if (!Files.exists(fprPath)) {
throw new FcliSimpleException("FPR file specified by --fpr does not exist: " + fprPath);
}
if (!Files.isRegularFile(fprPath)) {
throw new FcliSimpleException("FPR file specified by --fpr is not a regular file: " + fprPath);
}
if (!Files.isReadable(fprPath)) {
throw new FcliSimpleException("FPR file specified by --fpr is not readable: " + fprPath);
}
try (FprHandle fprHandle = new FprHandle(fprPath)) {
fprHandle.validate();
} catch (FcliSimpleException e) {
throw e;
} catch (RuntimeException e) {
throw new FcliSimpleException("FPR file specified by --fpr is not a valid audited SAST FPR: " + fprPath, e);
} catch (java.io.IOException e) {
throw new FcliSimpleException("Failed to close FPR file specified by --fpr: " + fprPath, e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
*/
package com.fortify.cli.aviator.applyRemediation;

import java.util.Set;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -28,6 +30,12 @@ public class ApplyAutoRemediationOnSource {

public static RemediationMetric applyRemediations(FprHandle fprHandle, String sourceCodeDirectory, IAviatorLogger logger)
throws AviatorSimpleException, AviatorTechnicalException {
return applyRemediations(fprHandle, sourceCodeDirectory, logger, null);
}

public static RemediationMetric applyRemediations(FprHandle fprHandle, String sourceCodeDirectory, IAviatorLogger logger,
Set<String> issueIdFilter)
throws AviatorSimpleException, AviatorTechnicalException {

LOG.info("Starting apply auto-remediation process for file: {}", fprHandle.getFprPath());

Expand All @@ -37,7 +45,7 @@ public static RemediationMetric applyRemediations(FprHandle fprHandle, String so
}
LOG.info("FPR validation successful");

RemediationProcessor remediationProcessor = new RemediationProcessor(fprHandle, sourceCodeDirectory);
RemediationProcessor remediationProcessor = new RemediationProcessor(fprHandle, sourceCodeDirectory, issueIdFilter);
return remediationProcessor.processRemediationXML();

}
Expand Down
Loading
Loading