-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
named-port bug fix and tests #412
Conversation
I agree with |
pkg/netpol/connlist/connlist.go
Outdated
@@ -349,8 +350,12 @@ func GetConnectionSetFromP2PConnection(c Peer2PeerConnection) *common.Connection | |||
protocolsToPortSetMap := make(map[v1.Protocol]*common.PortSet, len(c.ProtocolsAndPorts())) | |||
for protocol, portRageArr := range c.ProtocolsAndPorts() { | |||
protocolsToPortSetMap[protocol] = common.MakePortSet(false) | |||
for _, p := range portRageArr { | |||
protocolsToPortSetMap[protocol].AddPortRange(p.Start(), p.End()) | |||
for _, p := range portRageArr { // each single port range may contain either named port or an interval of start and end numbers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename portRageArr
to portRangeArr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
pkg/netpol/connlist/internal/ingressanalyzer/ingress_analyzer.go
Outdated
Show resolved
Hide resolved
reverted 1 & 3 |
remaining tests results fix :
output with bug included following line: (
output with bug would have following line: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add comment near each named port in the tests, if it is expected to be matched by network policy rule with named port or not.
also, do we need both tests? what is the difference between what they cover?
a comment with details about each test may help in the unit tests file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added comments to netpols files + connlist_test file.
although the tests cover same "issue"
(both tests contain a named-port with protocol that does not match the protocol in the pod's configuration (with same named-port)
and one test's netpol includes also a named-port that has no matching port name in the pod.)
the output of the tests differs,
- in one test since there is no matching port - we don't see any connection between the 2 pods in the connlist
- in the second tests, we see connection with the two ports that were successfully converted
#405
bug(s) description:
1. the analyzer ignored netpol rules withnamed ports
that didn't have a match in the dst pod's configuration(for example: if an ingress netpol captures
pod-a
with ingress rule that contains a named-portport-a
(TCP protocol) and the pod's specification does not has a containerPort/ Port with this name -- this rule was ignored, has no mention in the output)- fix: now we will see an ingress conn topod-a
on:TCP port-a
in the outputfor example: if a pod has containerPort with
name: newport
andprotocol: UDP port:90
and a netpol capturing that pod with ingress rule:
port: newport protocol:TCP
we saw on the output an ingress connection
TCP 90
which is not true since this is not the same port.TCP newport
)3.Peer2PeerConnection
(Connection
) assumed the ports will always contain a numbered interval only- fix: :PortRange
interface contains also aNamedPort
option; (the connection on a protocol may either be numbered or named; depends if we succeeded to convert it by from the pod's configuration or not)tests with examples of the above (with matched and unmatched named-ports) were added