Opened 3 years ago

Closed 3 years ago

#19285 closed enhancement (fixed)

Parse "package" lines in consensuses using method 19 or later

Reported by: karsten Owned by: karsten
Priority: Medium Milestone:
Component: Metrics/Library Version:
Severity: Normal Keywords:
Cc: iwakeh Actual Points:
Parent ID: #19398 Points:
Reviewer: Sponsor:

Description

From dir-spec.txt:

    "package" SP PackageName SP Version SP URL SP DIGESTS NL

        [Any number of times.]

        For this element:

        PACKAGENAME = NONSPACE
        VERSION = NONSPACE
        URL = NONSPACE
        DIGESTS = DIGEST | DIGESTS SP DIGEST
        DIGEST = DIGESTTYPE "=" DIGESTVAL
        NONSPACE = one or more non-space printing characters
        DIGESTVAL = DIGESTTYPE = one or more non-=, non-" " characters.

        Indicates that a package called "package" of version VERSION may be
        found at URL, and its digest as computed with DIGESTTYPE is equal to
        DIGESTVAL.  In consensuses, these lines are sorted lexically by
        "PACKAGENAME VERSION" pairs, and DIGESTTYPES must appear in ascending
        order.  A consensus must not contain the same "PACKAGENAME VERSION"
        more than once.  If a vote contains the same "PACKAGENAME VERSION"
        more than once, all but the last is ignored.

        Included in consensuses only for method 19 and later.

Found in the wild here, though looks mostly like testing:

$ grep -C1 "^package " 23/2016-04-23-03-00-00-vote-D586D18309DED4CD6D57C18FDB97EFA96D330566-BA14F96AB22EA5117C2D29B79BABD06ECAE451FF 
server-versions 0.2.4.23,0.2.4.24,0.2.4.25,0.2.4.26,0.2.4.27,0.2.5.8-rc,0.2.5.9-rc,0.2.5.10,0.2.5.11,0.2.5.12,0.2.6.5-rc,0.2.6.6,0.2.6.7,0.2.6.8,0.2.6.9,0.2.6.10,0.2.7.1-alpha,0.2.7.2-alpha,0.2.7.3-rc,0.2.7.4-rc,0.2.7.5,0.2.7.6,0.2.8.1-alpha,0.2.8.2-alpha
package shouldbesecond 0 http digest=digest
package outoforder 0 http digest=digest
known-flags Authority BadExit Exit Fast Guard HSDir Running Stable V2Dir Valid

We might get away by just providing package lines without parsing them, as in: getPackageLines().

Child Tickets

Change History (7)

comment:1 Changed 3 years ago by karsten

Cc: iwakeh added
Status: newneeds_review

Please review my branch task-19285.

comment:2 Changed 3 years ago by karsten

Parent ID: #19398

comment:3 Changed 3 years ago by iwakeh

All fine, only the @Override annotation is missing in the new (and old) methods.

And, out of curiosity: Is this if (line.length() > "package ".length()) a precaution? An incomplete line is not allowed according to the protocol above (afaict)?
There is no test with an incomplete line.

comment:4 Changed 3 years ago by karsten

Wow, that was quick. Thanks! I think I fixed the second issue by being a little stricter about the format and throwing an exception if a "package" line contains fewer than 4 arguments. Please take a look at the updated branch if you can.

I'd like to fix the @Override annotations for all code in metrics-lib at once. My Eclipse setup is currently broken, so I'd want to fix that first and then add annotations with Eclipse's help. I'll do that in a separate ticket. Sound okay?

comment:5 Changed 3 years ago by karsten

Please find another commit in the same branch with @Override annotations and some minor changes while putting them in.

comment:6 Changed 3 years ago by iwakeh

Status: needs_reviewmerge_ready

The clean-up looks good and checking for the number of parts is a good compromise between
checking nothing and parsing every field.
Great to have the @Override annotations! That really helps (me) when reading/adapting the code.

comment:7 Changed 3 years ago by karsten

Resolution: fixed
Status: merge_readyclosed

Great, thanks for looking! Squashed that fixup-commit and pushed to master. Closing.

Note: See TracTickets for help on using tickets.