From 07893828d8394a755ad4684c13c7741da0d1b16f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan-=C8=98tefan=20Neac=C5=9Fu?= Date: Wed, 3 Aug 2022 11:58:20 +0300 Subject: [PATCH 1/3] Fix NC filter for domains suffix-only domains (#1487) * Fix NC filter for domains suffix-only domains * Update CHANGELOG * Fix unit test for filter Some domains might be composed of the suffix only. There are no nonsense domains, as they can be defined even on the local machine. The underlying library doesn't resolve them, but rather uses a fixed list of public suffixes to assess the domains. * Fix clippy --- CHANGELOG.md | 2 ++ .../network-requester/src/allowed_hosts.rs | 14 +++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a789cbba5f..b12ec2d2a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ Post 1.0.0 release, the changelog format is based on [Keep a Changelog](https:// - native & socks5 clients: deduplicate big chunks of init logic - validator: fixed local docker-compose setup to work on Apple M1 ([#1329]) - explorer-api: listen out for SIGTERM and SIGQUIT too, making it play nicely as a system service ([#1482]). +- network-requester: fix filter for suffix-only domains ([#1487]) ### Changed @@ -75,6 +76,7 @@ Post 1.0.0 release, the changelog format is based on [Keep a Changelog](https:// [#1463]: https://github.com/nymtech/nym/pull/1463 [#1478]: https://github.com/nymtech/nym/pull/1478 [#1482]: https://github.com/nymtech/nym/pull/1482 +[#1487]: https://github.com/nymtech/nym/pull/1487 ## [nym-connect-v1.0.1](https://github.com/nymtech/nym/tree/nym-connect-v1.0.1) (2022-07-22) diff --git a/service-providers/network-requester/src/allowed_hosts.rs b/service-providers/network-requester/src/allowed_hosts.rs index 294a75edab..3746d9a706 100644 --- a/service-providers/network-requester/src/allowed_hosts.rs +++ b/service-providers/network-requester/src/allowed_hosts.rs @@ -109,9 +109,14 @@ impl OutboundRequestFilter { } /// Attempts to get the root domain, shorn of subdomains, using publicsuffix. + /// If the domain is itself a suffix, then just use the full address as root. fn get_domain_root(&self, host: &str) -> Option { match self.domain_list.parse_domain(host) { - Ok(d) => d.root().map(|root| root.to_string()), + Ok(d) => Some( + d.root() + .map(|root| root.to_string()) + .unwrap_or_else(|| d.full().to_string()), + ), Err(_) => { log::warn!("Error parsing domain: {:?}", host); None // domain couldn't be parsed @@ -348,9 +353,12 @@ mod tests { } #[test] - fn returns_none_on_nonsense_domains() { + fn returns_full_on_suffix_domains() { let filter = setup(); - assert_eq!(None, filter.get_domain_root("flappappa")); + assert_eq!( + Some("s3.amazonaws.com".to_string()), + filter.get_domain_root("s3.amazonaws.com") + ); } } From 9c19ae322d9f4265ea90ae6f6abc46bedc34e363 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan-=C8=98tefan=20Neac=C5=9Fu?= Date: Wed, 3 Aug 2022 12:45:21 +0300 Subject: [PATCH 2/3] Bump regex version to fix dependabot (#1488) --- contracts/Cargo.lock | 8 ++++---- nym-wallet/Cargo.lock | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/contracts/Cargo.lock b/contracts/Cargo.lock index 5438f45804..e0676f0832 100644 --- a/contracts/Cargo.lock +++ b/contracts/Cargo.lock @@ -1392,18 +1392,18 @@ dependencies = [ [[package]] name = "regex" -version = "1.5.4" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" +checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" dependencies = [ "regex-syntax", ] [[package]] name = "regex-syntax" -version = "0.6.25" +version = "0.6.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" +checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" [[package]] name = "rfc6979" diff --git a/nym-wallet/Cargo.lock b/nym-wallet/Cargo.lock index e365222be2..9f57f987f3 100644 --- a/nym-wallet/Cargo.lock +++ b/nym-wallet/Cargo.lock @@ -3996,9 +3996,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.5.4" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" +checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" dependencies = [ "aho-corasick", "memchr", @@ -4016,9 +4016,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.25" +version = "0.6.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" +checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" [[package]] name = "remove_dir_all" From b957b939cf6b1018158725e1620883ce015f194b Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Thu, 4 Aug 2022 11:01:23 +0100 Subject: [PATCH 3/3] Typo fix --- nym-connect/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nym-connect/README.md b/nym-connect/README.md index 5433a366d6..5a247235ab 100644 --- a/nym-connect/README.md +++ b/nym-connect/README.md @@ -32,7 +32,7 @@ yarn install ## Development mode -You can compile nym-connectin development mode by running the following command inside the `nym-connect` directory: +You can compile nym-connect in development mode by running the following command inside the `nym-connect` directory: ``` yarn dev