From ddae77d50c9751e4c4cfa35f46d925d9af06fafe Mon Sep 17 00:00:00 2001 From: fcomte Date: Wed, 18 Dec 2024 21:32:08 +0000 Subject: [PATCH] fix main --- .../service/HelmInstallService.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/helm-wrapper/src/main/java/io/github/inseefrlab/helmwrapper/service/HelmInstallService.java b/helm-wrapper/src/main/java/io/github/inseefrlab/helmwrapper/service/HelmInstallService.java index 2e03d8d0..839b7475 100644 --- a/helm-wrapper/src/main/java/io/github/inseefrlab/helmwrapper/service/HelmInstallService.java +++ b/helm-wrapper/src/main/java/io/github/inseefrlab/helmwrapper/service/HelmInstallService.java @@ -193,6 +193,12 @@ public HelmInstaller installChart( public int uninstaller(HelmConfiguration configuration, String name, String namespace) throws InvalidExitValueException, IOException, InterruptedException, TimeoutException { + if (name.length() > 53 || !rfc1123Pattern.matcher(name).matches()) { + throw new IllegalArgumentException( + "Invalid release " + + name + + ". Must be 53 or fewer characters and be a valid RFC 1123 string."); + } StringBuilder command = new StringBuilder("helm uninstall "); safeConcat(command, name); command.append(" -n "); @@ -229,6 +235,12 @@ public String getNotes(HelmConfiguration configuration, String id, String namesp public HelmReleaseInfo getAll(HelmConfiguration configuration, String id, String namespace) { StringBuilder command = new StringBuilder("helm get all "); + if (id.length() > 53 || !rfc1123Pattern.matcher(id).matches()) { + throw new IllegalArgumentException( + "Invalid release " + + id + + ". Must be 53 or fewer characters and be a valid RFC 1123 string."); + } safeConcat(command, id); command.append(" --namespace "); safeConcat(command, namespace); @@ -248,6 +260,12 @@ private String getReleaseInfo( throw new IllegalArgumentException( "Invalid info type " + infoType + ", should be manifest, notes or values"); } + if (id.length() > 53 || !rfc1123Pattern.matcher(id).matches()) { + throw new IllegalArgumentException( + "Invalid release " + + id + + ". Must be 53 or fewer characters and be a valid RFC 1123 string."); + } StringBuilder command = new StringBuilder("helm get " + infoType + " "); try { safeConcat(command, id); @@ -294,7 +312,6 @@ public HelmLs getAppById(HelmConfiguration configuration, String appId, String n + appId + ". Must be 53 or fewer characters and be a valid RFC 1123 string."); } - StringBuilder command = new StringBuilder("helm list --filter "); safeConcat(command, appId); command.append(" -n ");