Program: 15004
Project: 15004
Buggy source:
public AuthorizeSecurityGroupIngressResponseType authorize(final AuthorizeSecurityGroupIngressType request) throws Exception {
  final Context ctx=Contexts.lookup();
  final AuthorizeSecurityGroupIngressResponseType reply=(AuthorizeSecurityGroupIngressResponseType)request.getReply();
  final NetworkGroup ruleGroup=NetworkGroupUtil.getUserNetworkRulesGroup(ctx.getUserFullName(),request.getGroupName());
  if (!ctx.hasAdministrativePrivileges() && !Permissions.isAuthorized(PolicySpec.VENDOR_EC2,PolicySpec.EC2_RESOURCE_SECURITYGROUP,request.getGroupName(),ctx.getAccount(),PolicySpec.requestToAction(request),ctx.getUser())) {
    throw new EucalyptusCloudException("String_Node_Str" + request.getGroupName() + "String_Node_Str"+ ctx.getUser());
  }
  final List<NetworkRule> ruleList=Lists.newArrayList();
  for (  final IpPermissionType ipPerm : request.getIpPermissions()) {
    try {
      ruleList.addAll(NetworkGroupUtil.getNetworkRules(ipPerm));
    }
 catch (    final IllegalArgumentException ex) {
      LOG.error(ex.getMessage());
      reply.set_return(false);
      return reply;
    }
  }
  if (Iterables.any(ruleGroup.getNetworkRules(),new Predicate<NetworkRule>(){
    @Override public boolean apply(    final NetworkRule rule){
      for (      final NetworkRule r : ruleList) {
        if (r.equals(rule) && r.getNetworkPeers().equals(rule.getNetworkPeers()) && r.getIpRanges().equals(rule.getIpRanges())) {
          return true || !r.isValid();
        }
      }
      return false;
    }
  }
)) {
    reply.set_return(false);
    return reply;
  }
 else {
    ruleGroup.getNetworkRules().addAll(ruleList);
    EntityWrapper.get(ruleGroup).mergeAndCommit(ruleGroup);
    reply.set_return(true);
  }
  return reply;
}

Fixed version (ground truth):
public AuthorizeSecurityGroupIngressResponseType authorize(final AuthorizeSecurityGroupIngressType request) throws Exception {
  final Context ctx=Contexts.lookup();
  final AuthorizeSecurityGroupIngressResponseType reply=(AuthorizeSecurityGroupIngressResponseType)request.getReply();
  final NetworkGroup ruleGroup=NetworkGroups.lookup(ctx.getUserFullName(),request.getGroupName());
  if (!ctx.hasAdministrativePrivileges() && !Permissions.isAuthorized(PolicySpec.VENDOR_EC2,PolicySpec.EC2_RESOURCE_SECURITYGROUP,request.getGroupName(),ctx.getAccount(),PolicySpec.requestToAction(request),ctx.getUser())) {
    throw new EucalyptusCloudException("String_Node_Str" + request.getGroupName() + "String_Node_Str"+ ctx.getUser());
  }
  final List<NetworkRule> ruleList=Lists.newArrayList();
  for (  final IpPermissionType ipPerm : request.getIpPermissions()) {
    try {
      ruleList.addAll(NetworkGroupUtil.getNetworkRules(ipPerm));
    }
 catch (    final IllegalArgumentException ex) {
      LOG.error(ex.getMessage());
      reply.set_return(false);
      return reply;
    }
  }
  if (Iterables.any(ruleGroup.getNetworkRules(),new Predicate<NetworkRule>(){
    @Override public boolean apply(    final NetworkRule rule){
      for (      final NetworkRule r : ruleList) {
        if (r.equals(rule) && r.getNetworkPeers().equals(rule.getNetworkPeers()) && r.getIpRanges().equals(rule.getIpRanges())) {
          return true || !r.isValid();
        }
      }
      return false;
    }
  }
)) {
    reply.set_return(false);
    return reply;
  }
 else {
    ruleGroup.getNetworkRules().addAll(ruleList);
    EntityWrapper.get(ruleGroup).mergeAndCommit(ruleGroup);
    reply.set_return(true);
  }
  return reply;
}