From c6b808fd334114ee12416e4361722ca123a349b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Weing=C3=A4rtner?= Date: Fri, 3 Nov 2017 16:05:33 +0100 Subject: [PATCH] CLOUDSTACK-10111: Fix validation for parameter "vm.password.length" (#2291) The description of the parameter was saying that the parameter has to be bigger than 6, however, in the code we were only accepting values bigger than 10. This PR changes the validation method to accept any number >= 6. We also change other inconsistencies in error messages presented to users. in near by validations. --- .../ConfigurationManagerImpl.java | 24 ++++--------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index 6af8723afe3..bf1c20e118c 100755 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -240,8 +240,6 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati VolumeDao _volumeDao; @Inject VMInstanceDao _vmInstanceDao; - //@Inject - //VmwareDatacenterZoneMapDao _vmwareDatacenterZoneMapDao; @Inject AccountVlanMapDao _accountVlanMapDao; @Inject @@ -282,7 +280,6 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati ClusterDao _clusterDao; @Inject AlertManager _alertMgr; - // @com.cloud.utils.component.Inject(adapter = SecurityChecker.class) List _secChecker; @Inject @@ -816,16 +813,15 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati if (val <= 0) { throw new InvalidParameterValueException("Please enter a positive value for the configuration parameter:" + name); } - //TODO - better validation for all password pamameters - if ("vm.password.length".equalsIgnoreCase(name) && val < 10) { - throw new InvalidParameterValueException("Please enter a value greater than 6 for the configuration parameter:" + name); + if ("vm.password.length".equalsIgnoreCase(name) && val < 6) { + throw new InvalidParameterValueException("Please enter a value greater than 5 for the configuration parameter:" + name); } if ("remote.access.vpn.psk.length".equalsIgnoreCase(name)) { if (val < 8) { - throw new InvalidParameterValueException("Please enter a value greater than 8 for the configuration parameter:" + name); + throw new InvalidParameterValueException("Please enter a value greater than 7 for the configuration parameter:" + name); } if (val > 256) { - throw new InvalidParameterValueException("Please enter a value less than 256 for the configuration parameter:" + name); + throw new InvalidParameterValueException("Please enter a value less than 257 for the configuration parameter:" + name); } } } catch (final NumberFormatException e) { @@ -1019,12 +1015,6 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati final String checkPodCIDRs = _configDao.getValue("check.pod.cidrs"); if (checkPodCIDRs == null || checkPodCIDRs.trim().isEmpty() || Boolean.parseBoolean(checkPodCIDRs)) { checkPodCidrSubnets(zoneId, podId, cidr); - /* - * Commenting out due to Bug 11593 - CIDR conflicts with zone when - * extending pod but not when creating it - * - * checkCidrVlanOverlap(zoneId, cidr); - */ } if (allocationStateStr != null && !allocationStateStr.isEmpty()) { @@ -1587,12 +1577,6 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati throw new InvalidParameterValueException( "Invalid Zone Detail specified, fields 'key' and 'value' cannot be null, please specify details in the form: details[0].key=XXX&details[0].value=YYY"); } - // validate the zone detail keys are known keys - /* - * if(!ZoneConfig.doesKeyExist(key)){ throw new - * InvalidParameterValueException - * ("Invalid Zone Detail parameter: "+ key); } - */ newDetails.put(key, value); } }