Opened 5 years ago

Closed 5 years ago

#11257 closed defect (not a bug)

Stem believes that all bridge-extrainfo-descriptors have a 'router-digest' field

Reported by: isis Owned by: atagar
Priority: Medium Milestone:
Component: Core Tor/Stem Version:
Severity: Keywords: bridgedb-parsers
Cc: isis, atagar, sysrqb Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description (last modified by isis)

When parsing the following mock descriptor, which looks identical to a current real @type bridge-extrainfo descriptor, I get the following exception:

In [1]: import stem

In [2]: stem.__version__
Out[2]: '1.1.1'

In [3]: from stem.descriptor import extrainfo_descriptor

In [4]: raweidesc = """
extra-info LoneRevulsion E72E3DC5FAD5550DBCCB4429BBF0A7BB2FAD72E2
published 2014-03-12 20:56:50
write-history 2014-03-12 20:56:50 (900 s) 3188736,2226176,2866176
read-history 2014-03-12 20:56:50 (900 s) 3891200,2483200,2698240
dirreq-write-history 2014-03-12 20:56:50 (900 s) 1024,0,2048
dirreq-read-history 2014-03-12 20:56:50 (900 s) 0,0,0
geoip-db-digest D7D3AB5AF68AAC8F316BF9DEE7B7D0B0BC1238D7
geoip6-db-digest 76634AB48969832AA37F78F252726AB9803ECFB8
dirreq-stats-end 2014-03-12 20:56:50 (86400 s)
dirreq-v3-ips
dirreq-v3-reqs
dirreq-v3-resp ok=16,not-enough-sigs=0,unavailable=0,not-found=0,not-modified=0,busy=0
dirreq-v3-direct-dl complete=0,timeout=0,running=0
dirreq-v3-tunneled-dl complete=12,timeout=0,running=0
transport obfs3 254.99.16.232:31196
transport obfs2 254.99.16.232:31197
bridge-stats-end 2014-03-12 20:56:50 (86400 s)
bridge-ips ca=8
bridge-ip-versions v4=8,v6=0
bridge-ip-transports <OR>=8
router-signature
-----BEGIN SIGNATURE-----
duS1H+K32B3uKYA2sKcl+cKXL8PXKfJAQ+gnmsQ949qM85/8fWeX1j9xyUAlpN8q
5lUm0gSoNRLraTTtVg6jYA9BTlfcMlYz6hoyKjQRbFeT8OiU0Z3alQFCZl/qlVii
0juw8yjc6p4gNprm7gfP+h2VImm27kC/ZMNvloB5bEs=
-----END SIGNATURE-----
"""

In [5]: extrainfo_descriptor.BridgeExtraInfoDescriptor(raweidesc)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-3-0ed04607c709> in <module>()
----> 1 extrainfo_descriptor.BridgeExtraInfoDescriptor(raweidesc)

/home/isis/.virtualenvs/bridgedb/lib/python2.7/site-packages/stem/descriptor/extrainfo_descriptor.pyc in __init__(self, raw_contents, validate)
    904     self._digest = None
    905
--> 906     super(BridgeExtraInfoDescriptor, self).__init__(raw_contents, validate)
    907
    908   def digest(self):

/home/isis/.virtualenvs/bridgedb/lib/python2.7/site-packages/stem/descriptor/extrainfo_descriptor.pyc in __init__(self, raw_contents, validate)
    423       for keyword in self._required_fields():
    424         if not keyword in entries:
--> 425           raise ValueError("Extra-info descriptor must have a '%s' entry" % keyword)
    426
    427       for keyword in self._required_fields() + SINGLE_FIELDS:

ValueError: Extra-info descriptor must have a 'router-digest' entry


Atagar says this was done in this commit, because the sanitised bridge descriptors on the metrics server are supposed to have the 'router-digest' field, which is a SHA-1 of the corresponding @type bridge-server-descriptor.

BridgeDB needs an extrainfo parser which works with unsanitised descriptors (see #9380, #10725, and #11216). We probably need to create an UnsanitisedBridgeExtraInfoDescriptor class in Stem, if atagar is willing to take such a patch. :) If not, I can keep the Unsanitised classes in BridgeDB, since presently that is the only component which would actually be using these classes. (I can also maintain them, if they end up in Stem, since I'll likely be one of the only people to notice if something breaks/changes.)

Child Tickets

Change History (2)

comment:1 Changed 5 years ago by isis

Description: modified (diff)

comment:2 Changed 5 years ago by atagar

Resolution: not a bug
Status: newclosed

Hi Isis. As I've mentioned a few times on irc unsanitized bridge descriptors are simply normal relay descriptors. As such you can simply use the RelayDescriptor and RelayExtraInfoDescriptor classes. The BridgeDescriptor and BridgeExtraInfoDescriptor are for sanitized bridge descriptors

On a side note calling raw constructors like that is not the advised way of using Stem. Also, the '@type bridge-extrainfo' annotation does not exist. If you meant '@bridge-extra-info 1.1' then that is an annotation specifically for sanitized extrainfo bridge descriptors.

>>> import io

>>> from stem.descriptor import parse_file

>>> content = """
... extra-info LoneRevulsion E72E3DC5FAD5550DBCCB4429BBF0A7BB2FAD72E2
... published 2014-03-12 20:56:50
... write-history 2014-03-12 20:56:50 (900 s) 3188736,2226176,2866176
... read-history 2014-03-12 20:56:50 (900 s) 3891200,2483200,2698240
... dirreq-write-history 2014-03-12 20:56:50 (900 s) 1024,0,2048
... dirreq-read-history 2014-03-12 20:56:50 (900 s) 0,0,0
... geoip-db-digest D7D3AB5AF68AAC8F316BF9DEE7B7D0B0BC1238D7
... geoip6-db-digest 76634AB48969832AA37F78F252726AB9803ECFB8
... dirreq-stats-end 2014-03-12 20:56:50 (86400 s)
... dirreq-v3-ips
... dirreq-v3-reqs
... dirreq-v3-resp ok=16,not-enough-sigs=0,unavailable=0,not-found=0,not-modified=0,busy=0
... dirreq-v3-direct-dl complete=0,timeout=0,running=0
... dirreq-v3-tunneled-dl complete=12,timeout=0,running=0
... transport obfs3 254.99.16.232:31196
... transport obfs2 254.99.16.232:31197
... bridge-stats-end 2014-03-12 20:56:50 (86400 s)
... bridge-ips ca=8
... bridge-ip-versions v4=8,v6=0
... bridge-ip-transports <OR>=8
... router-signature
... -----BEGIN SIGNATURE-----
... duS1H+K32B3uKYA2sKcl+cKXL8PXKfJAQ+gnmsQ949qM85/8fWeX1j9xyUAlpN8q
... 5lUm0gSoNRLraTTtVg6jYA9BTlfcMlYz6hoyKjQRbFeT8OiU0Z3alQFCZl/qlVii
... 0juw8yjc6p4gNprm7gfP+h2VImm27kC/ZMNvloB5bEs=
... -----END SIGNATURE-----
... """

>>> desc = next(parse_file(io.BytesIO(content), 'extra-info 1.0'))

>>> type(desc)
<class 'stem.descriptor.extrainfo_descriptor.RelayExtraInfoDescriptor'>

>>> desc.nickname
u'LoneRevulsion'

Feel free to reopen if you run into any further issues.

Note: See TracTickets for help on using tickets.