summaryrefslogtreecommitdiff
path: root/crates/tor-netdoc/src/parse2
Commit message (Collapse)AuthorAgeFilesLines
* tor-basic-utils: Add GloballyInternable::into_intern()Clara Engler2026-06-241-2/+2
| | | | As a shorthand for T::intern_cache().intern(value).
* tor-netdoc: Implement parse2 traits for Intern wrappersClara Engler2026-06-242-1/+18
| | | | | This commit implements ItemValueParseable and ItemArgumentParseable for Intern<T> types. This should be sufficient for the time being.
* Merge branch 'derive-depr' into 'main'Clara Engler2026-06-181-0/+4
|\ | | | | | | | | tor-netdoc: derives: allow handling deprecated fields See merge request tpo/core/arti!4118
| * tor-netdoc: parse2 derive: allow setting deprecated fieldsIan Jackson2026-06-161-0/+4
| | | | | | | | | | | | | | | | | | This makes it possible to derive from a struct with deprecated fields, without triggering the warning. This doesn't yet treat encoding as yet, because the only deprecated field I encountered was `skip` which means the derived encoder never mentions it.
* | tor-netdoc: votes: use EmbeddedCert for the authhcertIan Jackson2026-06-171-1/+5
| |
* | tor-netdoc: tests: Move ns poc tests to netstatus.rsIan Jackson2026-06-172-69/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We're going to turn these into full-on round-trip tests for both flavours of consensus. We must temporarily bodge the more comprehensive test, for plain con sensuses, to to still use the actual document type from poc. That allows us to avoid changing the arguments to verify() etc. (poc's verify is subtly different to the real NetworkStatus's.) When these tests were in poc, they were gated by the incomplete cfg on the whole of poc. Now they have one each. Almost entirely code motion; review with git show --color-moved --color-moved-ws=allow-indentation-change
* | tor-netdoc: tests: Move poc authcert test to authcert.rsIan Jackson2026-06-171-16/+0
| | | | | | | | | | | | | | | | There is no separate poc authcert type any more. This is a perfectly fine test case. Almost entirely code motion; review with git show --color-moved --color-moved-ws=allow-indentation-change
* | tor-netdoc: poc tests: drop some unneeded &'sIan Jackson2026-06-171-3/+3
| | | | | | | | | | | | | | | | | | clippy complains (clippy::needless_borrows_for_generic_args). In poc, we have an allow with a TODO asking for this to be done generally in the Arti codebase. Let's postpone shaving that yak.
* | tor-netdoc: poc tests: use normal names for authcertsIan Jackson2026-06-171-6/+4
| |
* | tor-netdoc: poc tests: simulate normal outside-poc variety module namesIan Jackson2026-06-171-2/+4
|/ | | | | | | | | We are going to reuse/move this test code. Ie, it is going to be testing the real network document types. The naming outside poc is different. To make future diffs a bit less noisy, change some type names in the test code and fudge it up with a use.
* tor-netdoc: Rename variants in VerifyGeneralTrustedAuthoritiesIan Jackson2026-06-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | In a wip branch I added a variant, and clippy complained. In this case, I agree with clippy. warning: all variants have the same postfix: `Authorities` --> crates/tor-netdoc/src/doc/netstatus.rs:2335:1 | 2335 | / pub(crate) enum VerifyGeneralTrustedAuthorities<'r> { 2336 | | /// Trust these authorities. 2337 | | TrustTheseAuthorities { 2338 | | /// The HKP_auth_id_rsa ... | 2357 | | }, 2358 | | } | |_^ | = help: remove the postfixes and use full paths to the variants instead of glob imports = help: for further information visit https://rust-lang.github.io/rust-clippy/beta/index.html#enum_variant_names note: the lint level is defined here --> crates/tor-netdoc/src/lib.rs:9:9 | 9 | #![warn(clippy::all)] | ^^^^^^^^^^^ = note: `#[warn(clippy::enum_variant_names)]` implied by `#[warn(clippy::all)]`
* tor-netdoc: consensuses: Introduce VerifyGeneralTrustedAuthorities (fmt)Ian Jackson2026-06-111-3/+2
|
* tor-netdoc: consensuses: Introduce VerifyGeneralTrustedAuthoritiesIan Jackson2026-06-112-6/+2
| | | | | | | | | | | | | | | | | This avoids passing the threshold around as a bare usize, separated out from the list of trusted authorities. Roughly as discussed in https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/4065#note_3423775 But, VGTA::HazardouslyAssumeAllAuthCertsAreRealAuthorities contains n_authorities, not the thtreshold. That's what its user has, and that allows us to centralise the threshold calculation somewhat. The situation with votes in poc is a bit odd now: we pass one cert and then there's one authority so the threshold of 1 is calculated rather than literal. That's OK, but also we perhaps aren't going to use verify_general for votes in the production.
* tor-netdoc: Apply deferred rustfmt import churnIan Jackson2026-06-111-1/+1
|
* tor-netdoc: ns verification: Allow "dry run" to just get missing certs infoIan Jackson2026-06-111-0/+1
| | | | No functional change with the existing caller.
* tor-netdoc: ns verification: verify_general, return ResultIan Jackson2026-06-111-1/+0
| | | | No functional change.
* tor-netdoc: poc: Abolish core of separate verification logicIan Jackson2026-06-111-50/+12
| | | | | | | | | | | In an attempt to check that the new verification code makes sense, we compare it with the freshly rewritten one in poc. To review this, compare the code being deleted with the body of verify_general (doc/netstatus.rs, line 2164 et seq). You'll also want to refer to the body of find_cert and check_signature (lines 2068-2086).
* tor-netdoc: poc: Skip duplicate signatures earlier.Ian Jackson2026-06-111-0/+4
| | | | | | | Like verify_general does. (This wasn't a bug before, because we could the length of ok, so all that would happen is we'd do some extra work.)
* tor-netdoc: poc: Reorder slightlyIan Jackson2026-06-111-4/+5
| | | | | | Obtain the hash first, like verify_general does. No significant functional change, and this is poc code anyway.
* tor-netdoc: poc: Use let else continue (fmt)Ian Jackson2026-06-111-18/+18
|
* tor-netdoc: poc: Use let else continueIan Jackson2026-06-111-2/+4
| | | | | | This makes the code more like that in verify_general. No functional change, and this is poc code anyway.
* tor-netcoc: NetdocParseableUnverified derive: forbid NetdocParseableIan Jackson2026-06-102-0/+12
|
* tor-netdoc: parse2: Add more docs about verificationIan Jackson2026-06-101-3/+26
| | | | | Prompted by https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/4070#note_3422636
* tor-netdoc: parse2: use TimeRangebound in exampleIan Jackson2026-06-101-3/+6
|
* tor-netdoc: parse2: Deprecate check_validity_timeIan Jackson2026-06-102-0/+4
| | | | | | | | As per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/4070#note_3422637 We must allow it in poc, but poc is a thing we're trying to abolish/replace, so that's OK.
* everywhere: Add #[allow(clippy::string_slice)]Clara Engler2026-06-092-0/+6
| | | | | | | | This commit adds #[allow(clippy::string_slice)] to all functions in the code where string slices are used, alongside a TODO comment. We do this add the function header to have it consistent, as things like expression based allow's are still experimental.
* maint: Run maint/add_warning to deny string slicesClara Engler2026-06-091-0/+1
| | | | | | | | | | | | This commit executes maint/add_warning with the just added change to deny string slices except in tests. I recommend auditing this by checking out the previous commit followed by running the script yourself and then verifying that the diff is identical to this commit. This commit makes cargo clippy fail. We will add exceptions in the next commit.
* tor-netdoc: fix a doc formatting typoIan Jackson2026-06-031-1/+1
|
* tor-netdoc: Add crate:: to docs xrefs to avoid broken linksIan Jackson2026-06-021-2/+2
| | | | | | | | | | | | | | | | Apparently, it is only correct to write [`NetdocParseableUnverified`](derive_deftly_template_NetdocParseableUnverified), *after* the definition of that template. Before then, the macro isn't in scope. Worse, rustdoc just treats it as a filename and doesn't spot the link, so you don't get any kind of warning. I think this is an upstream bug, https://github.com/rust-lang/rust/issues/157304 I found rustdoc's behaviour capricious. I don't intend to go through the arti tree right now looking for similar patterns. Instead let's hope the upstream bug gets fixed, and in the meantime do this crate:: thing when we notice we need it.
* tor-netdoc: Rename NetdocUnverified trait to NetdocParseableUnverified (fmt)Ian Jackson2026-06-021-3/+3
|
* tor-netdoc: Rename NetdocUnverified trait to NetdocParseableUnverifiedIan Jackson2026-06-024-12/+12
| | | | | | | | | | | | The NetdocParseableUnverified derive macro implements this trait (amongst other things). Traits and derive macros should have aligned names. This is only used for parsing, so let's keep the "Parseable" part of the name. I don't think the effort of deprecated alias, for downstream compatibility, is worth it, our compatibility policy notwithstanding.
* tor-netdoc: Fix two references to NetdocUnverified d-d templateIan Jackson2026-06-021-2/+2
| | | | | | | The trait is called NetdocUnverified, but the template is NetdocParseableUnverified. This fixes a dead docs link (which somehow isn't spotted by rustdoc, but is instead taken to refer to a nonexistent file).
* tor-netdoc: NetdocParseableFields: Pass ItemStream to finishIan Jackson2026-05-272-5/+18
|
* tor-netdoc: Properly replace parse2::lex::NoFurtherArgumentsIan Jackson2026-05-271-12/+2
| | | | | | | | | | | | | | | As pointed out in https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/3985#note_3413185 this was a duplicate. The new NoFurtherArguments * Implements encoding * Implements more traits * Is in the right module (types::misc - it's not just for parsing) * Has a slightly better name * Had an open-coded parsing impl (which we now replace) * Had minor differences to docs (so we add a line to NoFurtherArguments)
* tor-netdoc: introduce VoteStatusConsensus and VoteStatusVoteIan Jackson2026-05-272-36/+2
| | | | | Replacing poc's. The new define_fixed_string macro is really helping here.
* tor-netdoc: NetworkStatusVersionItem, replacing poc's tupleIan Jackson2026-05-272-7/+6
| | | | | Defining a struct gives us a place to hang the documentation, and avoids an accidentally-exhaustive tuple.
* tor-netdoc: VarietyKeyword, replacing poc's flavour typeIan Jackson2026-05-271-27/+8
| | | | | | | This is more code than the poc version but much of the extra is documentation, and it seems much less magical this way. We still need a handwritten parser for plain consensuses, sadly.
* tor-netdoc: Promote/adjust poc's NetworkStatusSignaturesIan Jackson2026-05-271-10/+7
| | | | | | | | The order of arguments of poc's ns_type macro is different to that of the real code. This is very confusing! However, the type is correct, once we've added the singleton signature for votes.
* tor-netdoc: Replace poc's NddDirectoryFooter with new FooterIan Jackson2026-05-271-9/+7
| | | | | This is the whole of the footer section, with docs, appropriate derives, and so on.
* tor-netdoc: NetworkStatusVersion, replacing poc's with FixedStringIan Jackson2026-05-271-11/+1
|
* tor-netdoc: Document that parse2 vs encode multiplicity match req'tIan Jackson2026-05-181-0/+15
|
* tor-netdoc: Parsing with `#[netdoc(flatten)]`: cope with non-path typesIan Jackson2026-05-131-1/+1
| | | | ns_type! is a non-path type.
* tor-netdoc: Apply deferred rustfmt churnIan Jackson2026-04-291-26/+29
|
* tor-netdoc: Fix signature of hash_slice_for_verificationIan Jackson2026-04-291-9/+2
| | | | | | | In order to handle marked vs unmarked SHA1 correctly, it needs the original DigestAlgoInSignature. The only call site is in poc's verification code.
* tor-netdoc: Abolish poc's netstatus signature typeIan Jackson2026-04-291-159/+16
| | | | | | | | | | | | | | Use prod's Signature instead. This gets rid of: * The old parsing code. We have a new approach based on ItemValueParseable, KeywordOrString and and DigestAlgoInSignature. * The duplicate DirectorySignaturesHashesAccu and its temporary conversions. poc's verify_timeless function needs a little adjustment for the new struct layout.
* tor-netdoc: Promote hash_slice_for_verification to prodIan Jackson2026-04-291-13/+1
| | | | | | This function is not right, yet. We're going to fix it later. Review with --color-moved.
* tor-netdoc: Introduce DirectorySignaturesHashesAccu::update_fromIan Jackson2026-04-291-13/+12
| | | | | | | | | | | | | | | | | | This now contains the hashing code that was in poc. In poc it was entangled with the signature type, mostly because once upon a time the hash was inside the signature. In the real code we can make it a standalone method. It takes DigestAlgoInSignature so that it will be able to handle the explicit vs implicit sha1 anomaly correctly - but it can't do that yet because the necessary field doesn't exist yet. Also, we are going to want to make it a bit lazier - preserve the MR-blocking todo for that. A handful of lines are being actually moved verbatim, so --color-moved may help a bit.
* tor-netdoc: Promote poc's DirectorySignaturesHashesAccu to prodIan Jackson2026-04-291-28/+2
| | | | | | | There are definitely some things wrong with this, but they all have MR-blocking TODOs so we can promote this type now. Largely code motion. Review with --color-moved.
* tor-netdoc: Make some items temporarily pub(crate)Ian Jackson2026-04-291-2/+4
|
* tor-netdoc: Temporary conversions between the two DirectorySignatureHashAlgosIan Jackson2026-04-291-0/+20
| | | | | | Because we have two DirectorySignatureHashAlgo types because of the macrology problem, we need to introduce temporary conversions, to let us move code from poc to prod.