File tree Expand file tree Collapse file tree
helm-wrapper/src/main/java/io/github/inseefrlab/helmwrapper/service Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ public class HelmInstallService {
3131 private final Pattern semverPattern =
3232 Pattern .compile (
3333 "^(0|[1-9]\\ d*)\\ .(0|[1-9]\\ d*)\\ .(0|[1-9]\\ d*)(?:-((?:0|[1-9]\\ d*|\\ d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\ .(?:0|[1-9]\\ d*|\\ d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\ +([0-9a-zA-Z-]+(?:\\ .[0-9a-zA-Z-]+)*))?$" );
34+ private final Pattern rfc1123Pattern = Pattern .compile ("^[a-z0-9][a-z0-9-]{0,61}[a-z0-9]$" );
3435
3536 private final HelmReleaseInfoParser helmReleaseInfoParser = new HelmReleaseInfoParser ();
3637 private static final String VALUES_INFO_TYPE = "values" ;
@@ -299,6 +300,13 @@ private String buildEnvVar(Map<String, String> env) {
299300 */
300301 public HelmLs getAppById (HelmConfiguration configuration , String appId , String namespace )
301302 throws MultipleServiceFound {
303+ if (appId .length () > 53 || !rfc1123Pattern .matcher (appId ).matches ()) {
304+ throw new IllegalArgumentException (
305+ "Invalid app id "
306+ + appId
307+ + ". Must be 53 or fewer characters and be a valid RFC 1123 string." );
308+ }
309+
302310 StringBuilder command = new StringBuilder ("helm list --filter " );
303311 safeConcat (command , appId );
304312 command .append (" -n " );
You can’t perform that action at this time.
0 commit comments