Skip to content

Commit b99962d

Browse files
author
Jayapal
committed
CLOUDSTACK-4586 Added CIDR validation for SG Egress rules
1 parent 8c3986d commit b99962d

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

‎api/src/org/apache/cloudstack/api/command/user/securitygroup/AuthorizeSecurityGroupIngressCmd.java‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,6 @@ public String getEventDescription() {
207207

208208
@Override
209209
public void execute() {
210-
if(cidrList != null){
211-
for(String cidr : cidrList ){
212-
if (!NetUtils.isValidCIDR(cidr)){
213-
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, cidr + " is an Invalid CIDR ");
214-
}
215-
}
216-
}
217210
List<? extends SecurityRule> ingressRules = _securityGroupService.authorizeSecurityGroupIngress(this);
218211
if (ingressRules != null && !ingressRules.isEmpty()) {
219212
SecurityGroupResponse response = _responseGenerator.createSecurityGroupResponseFromSecurityGroupRule(ingressRules);

‎server/src/com/cloud/network/security/SecurityGroupManagerImpl.java‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,14 @@ private List<SecurityGroupRuleVO> authorizeSecurityGroupRule(Long securityGroupI
600600
protocol = NetUtils.ALL_PROTO;
601601
}
602602

603+
if(cidrList != null){
604+
for(String cidr : cidrList ){
605+
if (!NetUtils.isValidCIDR(cidr)){
606+
throw new InvalidParameterValueException("Invalid cidr " + cidr);
607+
}
608+
}
609+
}
610+
603611
if (!NetUtils.isValidSecurityGroupProto(protocol)) {
604612
throw new InvalidParameterValueException("Invalid protocol " + protocol);
605613
}

0 commit comments

Comments
 (0)