Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:[CO-793] fix UOE on ProxyConfGen #283

Merged
merged 1 commit into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2389,6 +2389,9 @@ private static void deleteObsoleteCertificateKeyPairFromDomainCertDir(
private static void deleteDomainCertbotConfiguration(
final List<DomainAttrItem> mDomainReverseProxyAttrs, final boolean dryRun) {
List<String> domainNames = Utils.getSubdirectoriesNames(CERTBOT_WORKING_DIR);
if (domainNames.isEmpty()) {
return;
}
for (DomainAttrItem entry : mDomainReverseProxyAttrs) {
domainNames.removeIf(domain -> domain.contains(entry.domainName));
}
Expand All @@ -2413,13 +2416,16 @@ private static void deleteDomainCertbotConfiguration(
* @since 23.7.0
*/
private static void executeCertbotDelete(final List<String> args) throws ProxyConfException {
if (args.isEmpty()) {
return;
}
args.forEach(domainName -> LOG.info("Deleting Let's Encrypt configuration for " + domainName));
List<String> mutableArgs = new ArrayList<>(args);
mutableArgs.add(0, CERTBOT);
mutableArgs.add(1, "delete");

args.add(0, CERTBOT);
args.add(1, "delete");

try {
new ProcessBuilder(mutableArgs).start();
new ProcessBuilder(args).start();
} catch (IOException e) {
throw new ProxyConfException("Unable to delete Let's Encrypt configurations", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,14 @@ public static void deleteFileIfExists(final String filePath) throws ProxyConfExc
*/
public static List<String> getFilesPathInDirectory(final String directoryPath) {
try (Stream<Path> paths = Files.walk(Paths.get(directoryPath), 1)) {
return paths.filter(Files::isRegularFile).map(Path::toString).collect(Collectors.toList());
return paths
.filter(Files::isRegularFile)
.map(Path::toString)
.collect(Collectors.toCollection(ArrayList::new));
} catch (IOException ignored) {
// ignore
}
return List.of();
return new ArrayList<>();
}

/**
Expand All @@ -109,6 +112,6 @@ public static List<String> getSubdirectoriesNames(final String directoryPath) {
} catch (IOException ignored) {
// ignore
}
return List.of();
return new ArrayList<>();
}
}