updateNetworkACLItem with partialupgrade=false leaves a rule broken when cidrlist or traffictype is left out, and drops an ICMP type given with tcp

未关闭
#14,642 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@bhouse-nexthop 已经在做这个了。

开始于 2026年11月9日。

  • #14643 来自 @bhouse-nexthop —— 未关闭

评估

难度
4/5
预计耗时
3-5 天
新手友好度
42/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
java

调研方向

Start by reading updateNetworkACLItem, transferDataToNetworkAclRulePojo(), NetworkACLItemDaoImpl.update() and NetworkACLItemCidrsDaoImpl.updateCidrs(); trace validation alongside createNetworkACL and the default partial upgrade path. Check the existing tests for network ACL rule updates and add coverage for missing required fields, invalid traffic type, ICMP parameters with another protocol, and rollback when CIDR updates fail. Done means invalid calls fail before leaving a partial update and valid calls preserve the documented behavior.

由索引模型根据 Issue 内容生成。

描述

problem

updateNetworkACLItem with partialupgrade=false replaces every field of the rule with what the call passes. Two cases go wrong.

1. A field left out is written as null, and the rule is left broken.

When cidrlist or traffictype is left out, transferDataToNetworkAclRulePojo() sets them to null. NetworkACLItemDaoImpl.update() then writes the rule row and only afterwards updates the CIDRs, outside a transaction:

  • with cidrlist left out, NetworkACLItemCidrsDaoImpl.updateCidrs() fails with Cannot invoke "java.util.List.size()" because "cidrs" is null. The call fails, but the row has already been committed with the null traffic type.
  • from then on listNetworkACLs for that list fails with Cannot invoke "...TrafficType.toString()" because ... getTrafficType() is null, and applying the list fails the same way in SetNetworkACLCommand, until the rule is updated again with every field.

When protocol is left out, the call fails earlier with a NullPointerException in updateIcmpCodeAndTypeFullUpgrade(). Nothing is written in that case, but the error is an NPE rather than a message. (#14046 removes that NPE; the rule would then be saved without a protocol, which createNetworkACL never allows.)

action left out is already handled: it becomes Allow, as on create.

2. An ICMP type or code given with another protocol is silently dropped.

partialupgrade=false protocol=tcp icmptype=8 is accepted, and the rule is saved as tcp without the ICMP type. createNetworkACL with the same parameters, and the same update with the default partialupgrade=true, both refuse it with "Can specify icmpCode and icmpType for ICMP protocol only".

versions

4.20 and later for the dropped ICMP type; the null fields since partialupgrade was added in 4.12. Seen on 4.22 and main.

The steps to reproduce the bug
  1. In a VPC, create an ACL list and a rule on it: createNetworkACL aclid=<list> protocol=tcp startport=80 endport=80 cidrlist=10.1.2.0/24 action=allow traffictype=ingress.
  2. updateNetworkACLItem id=<rule> partialupgrade=false protocol=udp startport=53 endport=53. It fails with the cidrs is null NPE.
  3. listNetworkACLs aclid=<list> now fails with the getTrafficType() is null NPE.
  4. updateNetworkACLItem id=<rule> partialupgrade=false protocol=tcp cidrlist=10.1.2.0/24 action=allow traffictype=ingress repairs it.
  5. On an ICMP rule, updateNetworkACLItem id=<rule> partialupgrade=false protocol=tcp icmptype=8 cidrlist=10.1.2.0/24 action=allow traffictype=ingress is accepted, and the rule is tcp with no ICMP type.
What to do about it?
  • With partialupgrade=false, refuse the call when protocol, cidrlist or traffictype is missing, before anything is written. Defaulting them as create does would silently widen a rule to every address, or turn an egress rule into an ingress rule.
  • Refuse an invalid traffictype on update, as create does, instead of ignoring it.
  • Keep an ICMP type or code given with another protocol, so that the existing validation refuses it.
  • Write the rule row and its CIDRs in one transaction, so that a failure on the CIDRs can't leave the rule half updated.
主要语言
Java
星标
3.1k
派生
1.4k
平均合并
7 天 16 小时
30 天内合并 PR
15

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

apache/cloudstack 的其他 Issue

查看 apache/cloudstack 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。