commit 725beac5437d85e8da5baa8a6fce90ce76fa9f9f Author: Damian Johnson atagar@torproject.org Date: Wed Apr 18 09:31:14 2012 -0700
Adding test for contact info with carriage return
Interesting use case spotted by Karsten on... https://trac.torproject.org/projects/tor/ticket/5637 --- test/integ/descriptor/data/cr_in_contact_line | 47 +++++++++++++++++++++++++ test/integ/descriptor/server_descriptor.py | 27 ++++++++++++++ 2 files changed, 74 insertions(+), 0 deletions(-)
diff --git a/test/integ/descriptor/data/cr_in_contact_line b/test/integ/descriptor/data/cr_in_contact_line new file mode 100644 index 0000000..f1d93fb --- /dev/null +++ b/test/integ/descriptor/data/cr_in_contact_line @@ -0,0 +1,47 @@ +router pogonip 75.5.248.48 9001 0 0 +platform Tor 0.1.2.17 on Darwin i386 +published 2007-09-03 10:15:53 +opt fingerprint 6DAB D62B C65D 4E6F E620 2931 57FC 7696 8DAB 9C9B +uptime 5423 +bandwidth 98304 196608 0 +onion-key +-----BEGIN RSA PUBLIC KEY----- +MIGJAoGBAO6pORBI9rGRCPSb2lLwzl2630eFMlBXLgLtwQvYLY2s58cWpKjhI+ZF +Q43+0e50pgC//JyS3Zac4O7MA5+BUfMvNOzKUdSIIGc6QjwST/larbDy14k9XalQ ++G8rdnKb7gDNLrHjxhw5tC0JSTSTXI08bNsFeN1MoY8sFBjRlyDxAgMBAAE= +-----END RSA PUBLIC KEY----- +signing-key +-----BEGIN RSA PUBLIC KEY----- +MIGJAoGBALL0zokdBKjVcZA1P0K2jWK7afkvmB2bpRAdx5x1KRPZtB0mRxyjvgwL +Tp0z3jLwhB4gzYY4LmS8p5RBH53gv4GsNW1rPSr99q4wjWyEY5AfjOdJZtFo/nhP +881leOraicfcXmqrgtfbXZ0Jj+G9Ko216yEv4vBN/UV87kZHb/4tAgMBAAE= +-----END RSA PUBLIC KEY----- +opt write-history 2007-09-03 10:01:27 (900 s) 471040,874496,354304,0,0,0,0,0,0,0,0,60416,1160192,2017280,3396608,1585152,5990400,5469184,10896384,20568064,23362560,43372544,36531200,43439104,47890432,54303744,38624256,40414208,26827776,0,0,0,0,50176,611328,3126272,2952192,33792,28672 +opt read-history 2007-09-03 10:01:27 (900 s) 6890496,2631680,2260992,0,0,0,0,0,0,0,0,1096704,1856512,1133568,1038336,1390592,3272704,2115584,6868992,13585408,13746176,30726144,25562112,28556288,36113408,35810304,25213952,30357504,13510656,0,0,0,0,964608,568320,966656,1991680,17408,140288 +opt hibernating 1 +contact jie1 at pacbell dot net -----BEGIN PGP PUBLIC KEY BLOCK-----Version: GnuPG v1 dot 4 dot 7 (Darwin)mQGiBEbb0rcRBADqBiUXsmtpJifh74irNnkHbhKMj8O4TqenaZYhdjLWouZsZd07mTQoP40G4zqOrVEOOcXpdSiRnHWJYfgTnkibNZrOZEZLn3H1ywpovEgESmoGEdAXoid3XuIYRpRnqoafbFg9sg+OofX/mJuntVuoIdHfkHYnHlcShfKYQX8x4wCgqVSLVrjINDUy9YRznpj+TeoflG8EALoM4xHmIAhSKhviZr6pd86OAYF5bB8iY+koiQtQ066Upypj+dUMKeYWKkWp3loY5KwtkA0rBd2+nhf/PRJyn387mfSiZ91NZ+Pph29dERida1naMWOgv+XZnqDH0bk9BD12QqM/btawGiyOf3fdtLLseNzuiHr9gO2NjKxR5jjgBACop3bFpx2nfELj/NzS/umtUaQJ139BI0BJOHrVeSffMAcuH3v5B3WJVJ5vJb5kvvD9L7fIZNkAicpLhMUG4Lz6zNXMNGSUlCAOvHoQzBUMz6EVE7Ip73qX9viuLARFMf25qi+SsZJB18l3t/I+UgW+VTimZZgoHmVtX0nVZL+yvbQWSklFIDxqaWUxQHBhY2JlbGwubmV0PohgBBMRAgAgBQJG29K3AhsjBgsJCAcDAgQVAggDBBYCAwECHgECF4AACgkQv5Dmts313gKv4ACcDggg0o/+ys4Djkbltvwoa9IGFoEAn1yjv8W1Kj5WkdrV8oZudjAq2zjNuQQNBEbb0rcQEAC6mKhgeRAQtJLI7JGEqjO6hOu5mq1+UYgpZnuQq8FxCkG2MQ0sqOjXcZP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Gnb6qCAzrfIpjjBHtwASIQ4IbJds7mjobiBQGC93mOt5sUNkplixY77kv8h9ZYgBITJryo719IPOTG6nXCcPfke5Jp1uAx7pYpqTZqWfrio0TCT0q6tP7+3ZGecFDN6xV3JQ4hICkTW4uOtfV3803NGM8bmZCV65EWRlzY7gOLM+Wat2G31soA5M7cAe/Q1ro7yqBDzAIAA3DFT58lRJY/BCXkJPDJ2ABFl/O3OHUD++pReISQQYEQIACQUCRtvStwIbDAAKCRC/kOa2zfXeAl9/AJ4lCZTgLIAwfh2Kgg8RowxlGrO+5ACfagQ9rlfx2oxCWijYwpYFRk3NhCY==Xaw3-----END PGP PUBLIC KEY BLOCK----- +reject 0.0.0.0/8:* +reject 169.254.0.0/16:* +reject 127.0.0.0/8:* +reject 192.168.0.0/16:* +reject 10.0.0.0/8:* +reject 172.16.0.0/12:* +reject *:25 +reject *:119 +reject *:135-139 +reject *:445 +reject *:465 +reject *:563 +reject *:587 +reject *:1214 +reject *:4661-4666 +reject *:6346-6429 +reject *:6699 +reject *:6881-6999 +accept *:* +router-signature +-----BEGIN SIGNATURE----- +PrL8cocQcTTmQp0wy0dxlFOczGv8s2/hZzAafOhjdM0QqLMLh9FW/4RqH0jcDz+P +t1QU3xIF3JV1fsW0rx4vFYKXG7WrLrrQp3gGuJvrXO+132UAsrs7eJKk3yxEi2lq +FNY26XGZqTDPY4WPl08/JgXXfckgFFg76E4Jcl5/tY8= +-----END SIGNATURE----- diff --git a/test/integ/descriptor/server_descriptor.py b/test/integ/descriptor/server_descriptor.py index ee099b4..815674a 100644 --- a/test/integ/descriptor/server_descriptor.py +++ b/test/integ/descriptor/server_descriptor.py @@ -241,6 +241,33 @@ Qlx9HNCqCY877ztFRC624ja2ql6A2hBcuoYMbkHjcQ4= self.assertEquals(["reject *:*"], desc.exit_policy) self.assertEquals([], desc.get_unrecognized_lines())
+ def test_cr_in_contact_line(self): + """ + Parses a descriptor with a huge contact line containing anomalous carriage + returns ('\r' entries). + """ + + descriptor_path = os.path.join(DESCRIPTOR_TEST_DATA, "cr_in_contact_line") + + descriptor_file = open(descriptor_path) + descriptor_contents = descriptor_file.read() + descriptor_file.close() + + desc = stem.descriptor.server_descriptor.RelayDescriptorV3(descriptor_contents) + + self.assertEquals("pogonip", desc.nickname) + self.assertEquals("6DABD62BC65D4E6FE620293157FC76968DAB9C9B", desc.fingerprint) + self.assertEquals("75.5.248.48", desc.address) + + # the contact info block is huge so just checking the start and end, + # including some of the embedded carriage returns + + contact_start = "jie1 at pacbell dot net -----BEGIN PGP PUBLIC KEY BLOCK-----\rVersion:" + contact_end = "YFRk3NhCY=\r=Xaw3\r-----END PGP PUBLIC KEY BLOCK-----" + + self.assertTrue(desc.contact.startswith(contact_start)) + self.assertTrue(desc.contact.endswith(contact_end)) + def test_bridge_descriptor(self): """ Parses a bridge descriptor.