Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Continued interledger-packet fuzzability #720

Merged
merged 10 commits into from
May 10, 2021
Merged

Continued interledger-packet fuzzability #720

merged 10 commits into from
May 10, 2021

Conversation

koivunej
Copy link
Collaborator

@koivunej koivunej commented May 6, 2021

Cc: #705

This is a follow-up to #716 with:

  • interledger-packet/roundtrip-only feature for denying ILP timestamps which don't roundtrip 1
  • rejects trailing bytes on interledger-packet/strict for Prepare and Reject (continues disallow extra trailing bytes in Fulfillment packet #710 which did this for Fulfill) 2
  • stylistic refactoring around unifying the style (assert_eq order, .to_string() calls, if cfg!(...) { } else { })
  • moves the fuzz target verification to src/lib.rs where it can be used with tests as well
  • adds PartialEq derivation for interledger-packet::hex::HexString for use in assert_eq!(HexString(...), HexString(...));

Footnotes

  1. Unsure if this should be the default; it'd seem that the 60 as the %S field is accepted for every date, which might not match the idea in the RFCs. "Every date" as in best to my knowledge, 2000-05-31 was not any special day w.r.t. leap seconds.

  2. Changes include string changes for consistent "Unexpected {inner,outer} trailing bytes", where outer means outside the interledger-packet envelope and inner means inside the envelope.

Copy link
Contributor

@whalelephant whalelephant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only 1 question on error type and minor tests naming suggestions

.unwrap();

if roundtripped != read_expires_at {
return Err(ParseError::InvalidPacket(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question:
Not sure if we need to align error types / have roundtrip error. I used a different type in the stream crate.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the moment all of the code I've seen either depends on:

  • just any error value (or "non-ok") coming from methods which return Result<T, ParseError>
  • the string formatting (the tests, maybe some logs)

So I'd be inclined not to change this now but leave it for #708, since it's pretty much the same -- both will need that static string as allocated one which I'd very much prefer not to have!

It's a good point however. Perhaps we should just go ahead and add a #[cfg(feature = "roundtrip-only")] variant there, and maybe make the whole thing #[non_exhaustive]. But I'm hoping the #708 will end up with more than one single massive error type.

crates/interledger-packet/src/packet.rs Outdated Show resolved Hide resolved
crates/interledger-packet/src/packet.rs Outdated Show resolved Hide resolved
@koivunej
Copy link
Collaborator Author

koivunej commented May 7, 2021

Oh yeah, new stable rust! I'll do a separate PR for the clippy errors if possible.

@koivunej
Copy link
Collaborator Author

koivunej commented May 7, 2021

I accidentially dropped the last commit once as I failed to understand what did this mean:

$ git push --force-with-lease
To github.com:koivunej/interledger-rs.git
 ! [rejected]          packet_errorcode_debug_cont -> packet_errorcode_debug_cont (stale info)
error: failed to push some refs to 'git@github.com:koivunej/interledger-rs.git'

Maybe that error message should say that there are new commits or something :)

Last commit is now restored.

koivunej and others added 10 commits May 10, 2021 17:37
Signed-off-by: Joonas Koivunen <joonas.koivunen@gmail.com>
by temporarily bringing back the roundtrip check.

Signed-off-by: Joonas Koivunen <joonas.koivunen@gmail.com>
do this by moving the check from fuzz_target over to src/lib.rs.

Signed-off-by: Joonas Koivunen <joonas.koivunen@gmail.com>
not only the fulfill. this does allow a big simplification to the
lenient_packet_roundtrips, which can now check that the packet bytesmut
containers are equal instead of the per-component and hunting down the
trailing bytes position.

Signed-off-by: Joonas Koivunen <joonas.koivunen@gmail.com>
this allows it to be used in assert_eq for more uniform view into the
data.

Signed-off-by: Joonas Koivunen <joonas.koivunen@gmail.com>
that is, on "strict" reject the inner *and* outer bytes, similar to how
*outer* were already rejected when "strict". for fulfill this changes
how inner trailing bytes were always rejected back to rejecting when
"strict".

refactor out the "outer" bytes check as well, to have the "trailing
bytes" functionality together for more visibility into how this is done
consistently. following the refactor, messages are also unified with
inner/outer.

this follows change from trying to keep the "strict" as adhering as
strict as possible to the RFCs, and perhaps eventually enabling it by
default.

Signed-off-by: Joonas Koivunen <joonas.koivunen@gmail.com>
- prefer to_string over format!
- reorder added assert_eq args
- prefer cfg! macro with if/else

Signed-off-by: Joonas Koivunen <joonas.koivunen@gmail.com>
this follows from finding a case where the parsed timestamp doesn't
match the output timestamp, even with the fix made in #707. the strict
feature is included in the "rountrip-only".

Signed-off-by: Joonas Koivunen <joonas.koivunen@gmail.com>
Signed-off-by: Joonas Koivunen <joonas.koivunen@gmail.com>
fuzzed_0, fuzzed_1 instead of splitting the fuzzed_0 into two.

Co-authored-by: bwty <email-me@belsy.space>
Signed-off-by: Joonas Koivunen <joonas.koivunen@gmail.com>
@koivunej koivunej merged commit 405d88d into interledger:master May 10, 2021
@koivunej koivunej deleted the packet_errorcode_debug_cont branch May 10, 2021 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants