-
Notifications
You must be signed in to change notification settings - Fork 25
ROX-29500: Use stackrox protobufs instead of types.NetworkInfo #2189
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
base: master
Are you sure you want to change the base?
Changes from 11 commits
d3c4a64
037aa91
d9cc8be
b325c41
7871e22
3c27b20
67010b6
4bf0b9c
340510f
23de1bb
b465bf6
b285896
f04ed83
712c132
56cae48
1283ac1
f38392b
c0c605b
9952557
2fdd62b
1404d11
0e6a2eb
453bfdc
66f1706
2e99de6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ import ( | |
"strings" | ||
"testing" | ||
|
||
sensorAPI "github.com/stackrox/rox/generated/internalapi/sensor" | ||
|
||
"github.com/stretchr/testify/suite" | ||
|
||
"github.com/stackrox/collector/integration-tests/pkg/collector" | ||
|
@@ -166,13 +168,13 @@ func TestConnectionsAndEndpointsNormal(t *testing.T) { | |
Server: suites.Container{ | ||
Name: "socat-server-0", | ||
Cmd: "socat TCP4-LISTEN:40,reuseaddr,fork - &", | ||
ExpectedNetwork: []types.NetworkInfo{ | ||
ExpectedNetwork: []*sensorAPI.NetworkConnection{ | ||
{ | ||
LocalAddress: ":40", | ||
RemoteAddress: "CLIENT_IP", | ||
Role: "ROLE_SERVER", | ||
SocketFamily: "SOCKET_FAMILY_UNKNOWN", | ||
CloseTimestamp: types.NilTimestamp, | ||
LocalAddress: types.CreateNetworkAddress("", "", 40), | ||
RemoteAddress: types.CreateNetworkAddress("", "", 0), | ||
Role: sensorAPI.ClientServerRole_ROLE_SERVER, | ||
SocketFamily: sensorAPI.SocketFamily_SOCKET_FAMILY_UNKNOWN, | ||
CloseTimestamp: nil, | ||
}, | ||
}, | ||
ExpectedEndpoints: []types.EndpointInfo{ | ||
|
@@ -189,13 +191,13 @@ func TestConnectionsAndEndpointsNormal(t *testing.T) { | |
Client: suites.Container{ | ||
Name: "socat-client-0", | ||
Cmd: "echo hello | socat - TCP4:SERVER_IP:40", | ||
ExpectedNetwork: []types.NetworkInfo{ | ||
ExpectedNetwork: []*sensorAPI.NetworkConnection{ | ||
{ | ||
LocalAddress: "", | ||
RemoteAddress: "SERVER_IP:40", | ||
Role: "ROLE_CLIENT", | ||
SocketFamily: "SOCKET_FAMILY_UNKNOWN", | ||
CloseTimestamp: types.NilTimestamp, | ||
LocalAddress: types.CreateNetworkAddress("", "", 0), | ||
RemoteAddress: types.CreateNetworkAddress("", "", 40), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From what I understand the original implementation was replacing SERVER_IP with the real IP address. I see that it was done purely for testing, but maybe it makes sense to set the RemoteAddress here correctly as well? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The server IP is unknown at this point, and There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still find it could be better. Even if the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am now using |
||
Role: sensorAPI.ClientServerRole_ROLE_CLIENT, | ||
SocketFamily: sensorAPI.SocketFamily_SOCKET_FAMILY_UNKNOWN, | ||
CloseTimestamp: nil, | ||
}, | ||
}, | ||
ExpectedEndpoints: nil, | ||
|
@@ -211,13 +213,13 @@ func TestConnectionsAndEndpointsHighLowPorts(t *testing.T) { | |
Server: suites.Container{ | ||
Name: "socat-server-1", | ||
Cmd: "socat TCP4-LISTEN:40000,reuseaddr,fork - &", | ||
ExpectedNetwork: []types.NetworkInfo{ | ||
ExpectedNetwork: []*sensorAPI.NetworkConnection{ | ||
{ | ||
LocalAddress: ":40000", | ||
RemoteAddress: "CLIENT_IP", | ||
Role: "ROLE_SERVER", | ||
SocketFamily: "SOCKET_FAMILY_UNKNOWN", | ||
CloseTimestamp: types.NilTimestamp, | ||
LocalAddress: types.CreateNetworkAddress("", "", 40000), | ||
RemoteAddress: types.CreateNetworkAddress("", "", 0), | ||
Role: sensorAPI.ClientServerRole_ROLE_SERVER, | ||
SocketFamily: sensorAPI.SocketFamily_SOCKET_FAMILY_UNKNOWN, | ||
CloseTimestamp: nil, | ||
}, | ||
}, | ||
ExpectedEndpoints: []types.EndpointInfo{ | ||
|
@@ -234,13 +236,13 @@ func TestConnectionsAndEndpointsHighLowPorts(t *testing.T) { | |
Client: suites.Container{ | ||
Name: "socat-client-1", | ||
Cmd: "echo hello | socat - TCP4:SERVER_IP:40000,sourceport=10000", | ||
ExpectedNetwork: []types.NetworkInfo{ | ||
ExpectedNetwork: []*sensorAPI.NetworkConnection{ | ||
{ | ||
LocalAddress: "", | ||
RemoteAddress: "SERVER_IP:40000", | ||
Role: "ROLE_CLIENT", | ||
SocketFamily: "SOCKET_FAMILY_UNKNOWN", | ||
CloseTimestamp: types.NilTimestamp, | ||
LocalAddress: types.CreateNetworkAddress("", "", 0), | ||
RemoteAddress: types.CreateNetworkAddress("", "", 40000), | ||
Role: sensorAPI.ClientServerRole_ROLE_CLIENT, | ||
SocketFamily: sensorAPI.SocketFamily_SOCKET_FAMILY_UNKNOWN, | ||
CloseTimestamp: nil, | ||
}, | ||
}, | ||
ExpectedEndpoints: nil, | ||
|
@@ -256,13 +258,13 @@ func TestConnectionsAndEndpointsServerHigh(t *testing.T) { | |
Server: suites.Container{ | ||
Name: "socat-server-2", | ||
Cmd: "socat TCP4-LISTEN:60999,reuseaddr,fork - &", | ||
ExpectedNetwork: []types.NetworkInfo{ | ||
ExpectedNetwork: []*sensorAPI.NetworkConnection{ | ||
{ | ||
LocalAddress: ":60999", | ||
RemoteAddress: "CLIENT_IP", | ||
Role: "ROLE_SERVER", | ||
SocketFamily: "SOCKET_FAMILY_UNKNOWN", | ||
CloseTimestamp: types.NilTimestamp, | ||
LocalAddress: types.CreateNetworkAddress("", "", 60999), | ||
RemoteAddress: types.CreateNetworkAddress("", "", 0), | ||
Role: sensorAPI.ClientServerRole_ROLE_SERVER, | ||
SocketFamily: sensorAPI.SocketFamily_SOCKET_FAMILY_UNKNOWN, | ||
CloseTimestamp: nil, | ||
}, | ||
}, | ||
ExpectedEndpoints: []types.EndpointInfo{ | ||
|
@@ -279,13 +281,13 @@ func TestConnectionsAndEndpointsServerHigh(t *testing.T) { | |
Client: suites.Container{ | ||
Name: "socat-client-2", | ||
Cmd: "echo hello | socat - TCP4:SERVER_IP:60999", | ||
ExpectedNetwork: []types.NetworkInfo{ | ||
ExpectedNetwork: []*sensorAPI.NetworkConnection{ | ||
{ | ||
LocalAddress: "", | ||
RemoteAddress: "SERVER_IP:60999", | ||
Role: "ROLE_CLIENT", | ||
SocketFamily: "SOCKET_FAMILY_UNKNOWN", | ||
CloseTimestamp: types.NilTimestamp, | ||
LocalAddress: types.CreateNetworkAddress("", "", 0), | ||
RemoteAddress: types.CreateNetworkAddress("", "", 60999), | ||
Role: sensorAPI.ClientServerRole_ROLE_CLIENT, | ||
SocketFamily: sensorAPI.SocketFamily_SOCKET_FAMILY_UNKNOWN, | ||
CloseTimestamp: nil, | ||
}, | ||
}, | ||
ExpectedEndpoints: nil, | ||
|
@@ -301,13 +303,13 @@ func TestConnectionsAndEndpointsSourcePort(t *testing.T) { | |
Server: suites.Container{ | ||
Name: "socat-server-1", | ||
Cmd: "socat TCP4-LISTEN:10000,reuseaddr,fork - &", | ||
ExpectedNetwork: []types.NetworkInfo{ | ||
ExpectedNetwork: []*sensorAPI.NetworkConnection{ | ||
{ | ||
LocalAddress: ":10000", | ||
RemoteAddress: "CLIENT_IP", | ||
Role: "ROLE_SERVER", | ||
SocketFamily: "SOCKET_FAMILY_UNKNOWN", | ||
CloseTimestamp: types.NilTimestamp, | ||
LocalAddress: types.CreateNetworkAddress("", "", 10000), | ||
RemoteAddress: types.CreateNetworkAddress("", "", 0), | ||
Role: sensorAPI.ClientServerRole_ROLE_SERVER, | ||
SocketFamily: sensorAPI.SocketFamily_SOCKET_FAMILY_UNKNOWN, | ||
CloseTimestamp: nil, | ||
}, | ||
}, | ||
ExpectedEndpoints: []types.EndpointInfo{ | ||
|
@@ -324,13 +326,13 @@ func TestConnectionsAndEndpointsSourcePort(t *testing.T) { | |
Client: suites.Container{ | ||
Name: "socat-client-1", | ||
Cmd: "echo hello | socat - TCP4:SERVER_IP:10000,sourceport=40000", | ||
ExpectedNetwork: []types.NetworkInfo{ | ||
ExpectedNetwork: []*sensorAPI.NetworkConnection{ | ||
{ | ||
LocalAddress: "", | ||
RemoteAddress: "SERVER_IP:10000", | ||
Role: "ROLE_CLIENT", | ||
SocketFamily: "SOCKET_FAMILY_UNKNOWN", | ||
CloseTimestamp: types.NilTimestamp, | ||
LocalAddress: types.CreateNetworkAddress("", "", 0), | ||
RemoteAddress: types.CreateNetworkAddress("", "", 10000), | ||
Role: sensorAPI.ClientServerRole_ROLE_CLIENT, | ||
SocketFamily: sensorAPI.SocketFamily_SOCKET_FAMILY_UNKNOWN, | ||
CloseTimestamp: nil, | ||
}, | ||
}, | ||
ExpectedEndpoints: nil, | ||
|
@@ -362,13 +364,13 @@ func TestConnectionsAndEndpointsUDPNormal(t *testing.T) { | |
Client: suites.Container{ | ||
Name: "socat-client-udp", | ||
Cmd: "echo hello | socat - UDP:SERVER_IP:53", | ||
ExpectedNetwork: []types.NetworkInfo{ | ||
ExpectedNetwork: []*sensorAPI.NetworkConnection{ | ||
{ | ||
LocalAddress: "", | ||
RemoteAddress: "SERVER_IP:53", | ||
Role: "ROLE_CLIENT", | ||
SocketFamily: "SOCKET_FAMILY_UNKNOWN", | ||
CloseTimestamp: types.NilTimestamp, | ||
LocalAddress: types.CreateNetworkAddress("", "", 0), | ||
RemoteAddress: types.CreateNetworkAddress("", "", 53), | ||
Role: sensorAPI.ClientServerRole_ROLE_CLIENT, | ||
SocketFamily: sensorAPI.SocketFamily_SOCKET_FAMILY_UNKNOWN, | ||
CloseTimestamp: nil, | ||
}, | ||
}, | ||
ExpectedEndpoints: nil, | ||
|
@@ -400,13 +402,13 @@ func TestConnectionsAndEndpointsUDPNoReuseaddr(t *testing.T) { | |
Client: suites.Container{ | ||
Name: "socat-client-udp", | ||
Cmd: "echo hello | socat - UDP:SERVER_IP:53", | ||
ExpectedNetwork: []types.NetworkInfo{ | ||
ExpectedNetwork: []*sensorAPI.NetworkConnection{ | ||
{ | ||
LocalAddress: "", | ||
RemoteAddress: "SERVER_IP:53", | ||
Role: "ROLE_CLIENT", | ||
SocketFamily: "SOCKET_FAMILY_UNKNOWN", | ||
CloseTimestamp: types.NilTimestamp, | ||
LocalAddress: types.CreateNetworkAddress("", "", 0), | ||
RemoteAddress: types.CreateNetworkAddress("", "", 53), | ||
Role: sensorAPI.ClientServerRole_ROLE_CLIENT, | ||
SocketFamily: sensorAPI.SocketFamily_SOCKET_FAMILY_UNKNOWN, | ||
CloseTimestamp: nil, | ||
}, | ||
}, | ||
ExpectedEndpoints: nil, | ||
|
@@ -438,13 +440,13 @@ func TestConnectionsAndEndpointsUDPNoFork(t *testing.T) { | |
Client: suites.Container{ | ||
Name: "socat-client-udp", | ||
Cmd: "echo hello | socat - UDP:SERVER_IP:53", | ||
ExpectedNetwork: []types.NetworkInfo{ | ||
ExpectedNetwork: []*sensorAPI.NetworkConnection{ | ||
{ | ||
LocalAddress: "", | ||
RemoteAddress: "SERVER_IP:53", | ||
Role: "ROLE_CLIENT", | ||
SocketFamily: "SOCKET_FAMILY_UNKNOWN", | ||
CloseTimestamp: types.NilTimestamp, | ||
LocalAddress: types.CreateNetworkAddress("", "", 0), | ||
RemoteAddress: types.CreateNetworkAddress("", "", 53), | ||
Role: sensorAPI.ClientServerRole_ROLE_CLIENT, | ||
SocketFamily: sensorAPI.SocketFamily_SOCKET_FAMILY_UNKNOWN, | ||
CloseTimestamp: nil, | ||
}, | ||
}, | ||
ExpectedEndpoints: nil, | ||
|
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.
I think it's worth it here and in other similar cases to introduce a separate variable keeping the client port. This will explain why there is 40 here and few lines above.
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