Skip to content

Commit 25ab5e2

Browse files
committed
removing function AnalyzeNACLRules and fix tests
1 parent 2ec517c commit 25ab5e2

File tree

2 files changed

+299
-137
lines changed

2 files changed

+299
-137
lines changed

pkg/commonvpc/nacl_analysis.go

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -256,51 +256,6 @@ func getConnStr(src, dst, conn string) string {
256256
return fmt.Sprintf("%s => %s : %s\n", src, dst, conn)
257257
}
258258

259-
// AnalyzeNACLRules todo: this is used only in testing. Did not expand for deny.
260-
func (na *NACLAnalyzer) AnalyzeNACLRules(rules []*NACLRule, subnet *netset.IPBlock,
261-
isIngress bool, subnetDisjointTarget *netset.IPBlock,
262-
) (string, *ConnectivityResult) {
263-
res := []string{}
264-
connResult := &ConnectivityResult{IsIngress: isIngress}
265-
connResult.AllowedConns = map[*netset.IPBlock]*netset.TransportSet{}
266-
connResult.DeniedConns = map[*netset.IPBlock]*netset.TransportSet{}
267-
if subnetDisjointTarget == nil {
268-
connResult = nil
269-
}
270-
if isIngress {
271-
disjointSrcPeers, disjointDstPeers := getDisjointPeersForIngressAnalysis(rules, subnet)
272-
// ingress
273-
for _, src := range disjointSrcPeers {
274-
allowedIngressConns, _, allowRules, _ := GetAllowedXgressConnections(rules, src, subnet, disjointDstPeers, true)
275-
for dst, conn := range allowedIngressConns {
276-
res = append(res, getConnStr(src.ToIPRanges(), dst, common.LongString(conn)))
277-
dstIP, err := netset.IPBlockFromIPRangeStr(dst)
278-
if err == nil && subnetDisjointTarget != nil && subnetDisjointTarget.IsSubset(dstIP) {
279-
connResult.AllowedConns[src] = conn
280-
// the indexing of allowedIngressConns and allowRules are identical
281-
connResult.AllowRules[src] = allowRules[dst]
282-
}
283-
}
284-
}
285-
return strings.Join(res, ""), connResult
286-
}
287-
// egress
288-
disjointSrcPeers, disjointDstPeers := getDisjointPeersForEgressAnalysis(rules, subnet)
289-
for _, dst := range disjointDstPeers {
290-
allowedEgressConns, _, allowRules, _ := GetAllowedXgressConnections(rules, dst, subnet, disjointSrcPeers, false)
291-
for src, conn := range allowedEgressConns {
292-
res = append(res, getConnStr(src, dst.ToIPRanges(), common.LongString(conn)))
293-
srcIP, err := netset.IPBlockFromIPRangeStr(src)
294-
if err == nil && subnetDisjointTarget != nil && subnetDisjointTarget.IsSubset(srcIP) {
295-
connResult.AllowedConns[dst] = conn
296-
// the indexing of allowedEgressConns and allowRules are identical
297-
connResult.AllowRules[dst] = allowRules[src]
298-
}
299-
}
300-
}
301-
return strings.Join(res, ""), connResult
302-
}
303-
304259
// TODO: return a map from each possible subnetDisjointTarget to its ConnectivityResult, instead of a specific ConnectivityResult
305260
// get allowed and denied connections (ingress and egress) for a certain subnet to which this nacl is applied
306261
func (na *NACLAnalyzer) AnalyzeNACL(subnet *netset.IPBlock) (

0 commit comments

Comments
 (0)