[tor-commits] [pluggable-transports/snowflake] branch main updated: change regexes for ipv6 addresses to catch url-encoded addresses

gitolite role git at cupani.torproject.org
Mon Nov 28 20:57:25 UTC 2022


This is an automated email from the git hooks/post-receive script.

cohosh pushed a commit to branch main
in repository pluggable-transports/snowflake.

The following commit(s) were added to refs/heads/main by this push:
     new 90d1a56  change regexes for ipv6 addresses to catch url-encoded addresses
90d1a56 is described below

commit 90d1a5671964564c27f95afbab22dbc031135516
Author: luciole <luciole at systemli.org>
AuthorDate: Mon Nov 14 17:30:36 2022 +0100

    change regexes for ipv6 addresses to catch url-encoded addresses
---
 common/safelog/log.go      | 7 +++++--
 common/safelog/log_test.go | 5 +++++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/common/safelog/log.go b/common/safelog/log.go
index 4c7c73b..b6f9190 100644
--- a/common/safelog/log.go
+++ b/common/safelog/log.go
@@ -11,8 +11,11 @@ import (
 )
 
 const ipv4Address = `\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}`
-const ipv6Address = `([0-9a-fA-F]{0,4}:){5,7}([0-9a-fA-F]{0,4})?`
-const ipv6Compressed = `([0-9a-fA-F]{0,4}:){0,5}([0-9a-fA-F]{0,4})?(::)([0-9a-fA-F]{0,4}:){0,5}([0-9a-fA-F]{0,4})?`
+
+// %3A and %3a are for matching : in URL-encoded IPv6 addresses
+const colon = `(:|%3a|%3A)`
+const ipv6Address = `([0-9a-fA-F]{0,4}` + colon + `){5,7}([0-9a-fA-F]{0,4})?`
+const ipv6Compressed = `([0-9a-fA-F]{0,4}` + colon + `){0,5}([0-9a-fA-F]{0,4})?(` + colon + `){2}([0-9a-fA-F]{0,4}` + colon + `){0,5}([0-9a-fA-F]{0,4})?`
 const ipv6Full = `(` + ipv6Address + `(` + ipv4Address + `))` +
 	`|(` + ipv6Compressed + `(` + ipv4Address + `))` +
 	`|(` + ipv6Address + `)` + `|(` + ipv6Compressed + `)`
diff --git a/common/safelog/log_test.go b/common/safelog/log_test.go
index 94ca6e5..bbbff8b 100644
--- a/common/safelog/log_test.go
+++ b/common/safelog/log_test.go
@@ -77,6 +77,11 @@ func TestLogScrubberMessages(t *testing.T) {
 			"2019/05/08 15:37:31 starting",
 			"2019/05/08 15:37:31 starting\n",
 		},
+		{
+			//Make sure ipv6 addresses where : are encoded as %3A or %3a are scrubbed
+			"error dialing relay: wss://snowflake.torproject.net/?client_ip=6201%3ac8%3A3004%3A%3A1234",
+			"error dialing relay: wss://snowflake.torproject.net/?client_ip=[scrubbed]\n",
+		},
 	} {
 		var buff bytes.Buffer
 		log.SetFlags(0) //remove all extra log output for test comparisons

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the tor-commits mailing list