OBE-8859: ip whitelist source only (PART 1)#79
Conversation
|
test.toml:
also tried permit_origin ["127.0.0.1/32"] (message received), ["127.0.0.22/32"] (no messages received) |
|
comprehensive test. |
|
send request from another terminal. gRPC is skipped. need brew install grpcurl
test_requests.sh |
d43a89d to
470e464
Compare
| let address = next_addr(); | ||
|
|
||
| let mut config = UdpConfig::from_address(address.into()); | ||
| config.permit_origin = make_allowlist(&["127.0.0.1/32"]); |
There was a problem hiding this comment.
May be make one of these just the address (kill /32 suffix) just for completeness. Not everywhere, just one positive test and one negative test suffices.
| } | ||
|
|
||
| #[tokio::test] | ||
| async fn permit_origin_allows_matching_ip() { |
There was a problem hiding this comment.
Often it is possible to avoid so much duplication. One way I can think of is to create a helper that accepts permit-origin fragment (or in case of toml config-parsing tests, accepts the entire toml string) and returns the receive channel. Then the test can simply recv the message or assert timeout.
| .send() | ||
| .await; | ||
|
|
||
| assert!(response.is_ok(), "expected connection to be accepted for allowed IP"); |
There was a problem hiding this comment.
assert the message was received (don't ignore _recv).
| } | ||
|
|
||
| #[tokio::test] | ||
| async fn permit_origin_allows_matching_ip() { |
There was a problem hiding this comment.
try to dedup here and in other tests (should be a pretty quick thing with coding assistant)
|
|
||
| if let Some(ref allowlist) = origin_allowlist { | ||
| if !allowlist.iter().any(|net| net.contains(&address.ip())) { | ||
| continue; |
There was a problem hiding this comment.
Increment a metric (this can lead to a lot of confusion). Preferably also add a log-line.
| address, | ||
| headers: vec![], | ||
| encoding: None, | ||
| query_parameters: vec![], | ||
| response_code: StatusCode::OK, | ||
| tls: None, | ||
| auth: None, | ||
| strict_path: true, | ||
| path_key: OptionalValuePath::from(owned_value_path!("path")), | ||
| host_key: OptionalValuePath::from(owned_value_path!("host")), | ||
| path: "/".to_owned(), | ||
| method: HttpMethod::Post, | ||
| framing: None, | ||
| decoding: None, | ||
| acknowledgements: false.into(), | ||
| log_namespace: None, | ||
| keepalive: Default::default(), | ||
| permit_origin, |
There was a problem hiding this comment.
In these cases toml can make the test really short.
… heroku, prometheus pushgateway and remote_write
… allowlist, loop and wait
…e process after allowlist rejection
518eb00 to
d15e34e
Compare
left out
windows event forwarderfor now, may need change in dataplane_private.Sources implemented so far: tcp, splunk HEC, firehose, prometheus remote write, HTTP server (push), udp, datadog agent, OpenTelemetry