-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
fix(misuse): Add validation to deserialization #504
fix(misuse): Add validation to deserialization #504
Conversation
Pull Request Test Coverage Report for Build 9523103389Details
💛 - Coveralls |
@duesee I just read once again through your reply in the issue and noticed that I overlooked your hint to (Also I will look into the strange non-diff the failing check is complaining about.) |
a253f8e
to
26e043e
Compare
Pull Request Test Coverage Report for Build 9527640958Details
💛 - Coveralls |
You are using |
26e043e
to
4877e0d
Compare
Pull Request Test Coverage Report for Build 9544457310Details
💛 - Coveralls |
@jakoschiko Thanks for pointing this out. I will try to address the issues in your comment one by one:
Hopefully, I only added deserialization through
I would agree that deserializing into However, if you are suggesting that previously, data was not copied, this seems not to be the case as deserialization into a
Where would you expect additional unicode checks? On the way to the first Rust string type in the conversion, there will always be a unicode check to ensure Rust's UTF-8 guarantees. However, when converting between string types, there should be no additional checks (e.g. when moving the
I tried using |
@duesee I'm a bit lost with the Coveralls failure. In the report, there seem to be arbitrarily sprinkled coverage misses in empty lines and comments. I first thought that might have something to do with mixing in old coverage information into the report, but even with the changes to the coverage report generation we merged today, this is still the case. Also, when I look at the coverage reports generated locally, the PR seems to only improve things in the files critizied by the tool and the report generated by For the base report of main, everything seems to be fine and comparable to the local report. Any ideas on this? |
My bad. I thought that types like
The previous serialization was also non-optimal (probably by accident). It should be possible to have an implementation that does not copy the bytes. E.g. the impl<'a> TryFrom<&'a str> for Atom<'a> {
type Error = ValidationError;
fn try_from(value: &'a str) -> Result<Self, Self::Error> {
Self::validate(value)?;
Ok(Self(Cow::Borrowed(value)))
}
}
Sure, if it's non-trivial to fix it, let's do it later.
Again, my bad. I'm a little bit surprised that @duesee decided to use
This confuses me. Because of the |
When writing the previous comment, I gave this some more thought and I'm actually also not sure if assuming this is correct. I have created #506 for discussing this further.
Unfortunately, your playground example simplifies things a bit by not using |
Regarding the coverage: Maybe, maaaybe, we screwed up the GitHub Actions cache when porting everything to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! This looks good to me. I'll file two issues:
- Check coverage in CI, and
- Fuzz-test serde (de)serialization (when serde feature is used)
@jakoschiko Do you think this can already be merged?
#511 should fix that. I am happy to wait for that one to be merged first and see this PR not reducing the coverage after rebasing. |
The non-doc-comment line inside the doc comment code block seemed to confuse rustfmt. Because of this, the nightly version was adding a trailing space while stable was removing it.
Previously, correctness through the existing validation functions was not enforced during deserialization. This is now achieved by going through `TryFrom` implementations or specific field deserialization functions. Thus, it should no longer be possible to create invalid instances by deserialization. This fixes duesee#502.
4877e0d
to
df477b7
Compare
Pull Request Test Coverage Report for Build 9568958583Details
💛 - Coveralls |
Awesome work! Thanks! :-) |
Previously, correctness through the existing validation functions was
not enforced during deserialization.
This is now achieved by going through
TryFrom
implementations orspecific field deserialization functions. Thus, it should no longer be
possible to create invalid instances by deserialization.
This fixes #502.