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

Fix for issue 96. #100

Merged
merged 12 commits into from
Dec 5, 2023
Merged

Fix for issue 96. #100

merged 12 commits into from
Dec 5, 2023

Conversation

LLITCHEV
Copy link
Contributor

@LLITCHEV LLITCHEV commented Sep 8, 2023

Added tests for all the types.

Related issue(s):

Fixes #96
Fixes #73

@LLITCHEV LLITCHEV requested a review from jasperpotts September 8, 2023 04:23
@LLITCHEV LLITCHEV self-assigned this Sep 8, 2023
@github-actions
Copy link

github-actions bot commented Sep 8, 2023

JUnit Test Report

     46 files  +  1       46 suites  +1   4m 45s ⏱️ + 1m 29s
   758 tests +21     757 ✔️ +21    1 💤 ±0  0 ±0 
5 808 runs  +21  5 790 ✔️ +21  18 💤 ±0  0 ±0 

Results for commit 958c8c4. ± Comparison against base commit 5ea94d1.

This pull request removes 2 and adds 22 tests. Note that renamed tests count towards both.
, 1
com.hedera.pbj.runtime.Utf8ToolsTest ‑ [4] 
com.hedera.pbj.runtime.ProtoParserToolsTest ‑ [1] 0
com.hedera.pbj.runtime.ProtoParserToolsTest ‑ [1] 1
com.hedera.pbj.runtime.ProtoParserToolsTest ‑ [2] 1
com.hedera.pbj.runtime.ProtoParserToolsTest ‑ [2] 2
com.hedera.pbj.runtime.ProtoParserToolsTest ‑ [3] 3
com.hedera.pbj.runtime.ProtoParserToolsTest ‑ testReadBytes()
com.hedera.pbj.runtime.ProtoParserToolsTest ‑ testReadBytes_incomplete()
com.hedera.pbj.runtime.ProtoParserToolsTest ‑ testReadDouble()
com.hedera.pbj.runtime.ProtoParserToolsTest ‑ testReadFixed64()
com.hedera.pbj.runtime.ProtoParserToolsTest ‑ testReadFixedInt32()
…

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Sep 8, 2023

Integration Test Report

     215 files  +    2       215 suites  +2   5m 36s ⏱️ + 1m 22s
86 997 tests +  34  86 997 ✔️ +  34  0 💤 ±0  0 ±0 
87 263 runs  +300  87 263 ✔️ +300  0 💤 ±0  0 ±0 

Results for commit 958c8c4. ± Comparison against base commit 5ea94d1.

♻️ This comment has been updated with latest results.

Copy link
Member

@jasperpotts jasperpotts left a comment

Choose a reason for hiding this comment

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

Think we still need to check at the end of parsing a sub-object that all the expected bytes were read. Anywhere there is length encoded data with a length, we should enforce we never read more or less bytes than specified in length.

@LLITCHEV
Copy link
Contributor Author

@jasperpotts I aded the extra check. I added the check to make sure we have enough limit (which is a fast fail - without having the actual read). It does make sense to do the check after the read as well, so added code there as well. Thanks!

@jasperpotts
Copy link
Member

We also need to check that all cases are covered. In protobuf there are a few core data types, fixed length, variant and length encoded. All length encoded data we need to make sure all of the specified length bytes are read or throw exception. Otherwise we can start processing the remaining data as a different field and get corrupt data. Length encoded includes, strings, bytes and sub-messages as maybe others.

@jasperpotts
Copy link
Member

We should also check anywhere we do a bulk read of bytes with int getBytes(byteArray) style method that we check the returned number of bytes read matches expected. We have choice to loop and keep reading till all bytes are read or throw exception.

Lubomir Litchev added 8 commits December 1, 2023 13:50
Added tests for all the types.

Signed-off-by: Lubomir Litchev <[email protected]>
Signed-off-by: Lubomir Litchev <[email protected]>
If the buffer is truncated on the boundary of the subObject, we still need to throw an exception.

Signed-off-by: Lubomir Litchev <[email protected]>
While strictParsing, we should make sure the buffer is not empty when parsing strictly a type from buffer. This can happen if the buffer is truncated to an empty one.

Signed-off-by: Lubomir Litchev <[email protected]>
Signed-off-by: Lubomir Litchev <[email protected]>
@imalygin imalygin force-pushed the lubo-issue-96 branch 2 times, most recently from 5f7a65a to 522e667 Compare December 4, 2023 16:54
Copy link
Contributor

codacy-production bot commented Dec 4, 2023

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+1.67% (target: -1.00%) 75.00%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (53391bd) 3766 1013 26.90%
Head commit (958c8c4) 3780 (+14) 1080 (+67) 28.57% (+1.67%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#100) 12 9 75.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

@poulok poulok assigned imalygin and unassigned LLITCHEV Dec 4, 2023
Signed-off-by: Ivan Malygin <[email protected]>
artemananiev
artemananiev previously approved these changes Dec 4, 2023
… Cleaned up redundand `throw IOException`

Signed-off-by: Ivan Malygin <[email protected]>
@imalygin imalygin merged commit f2933b2 into main Dec 5, 2023
@imalygin imalygin deleted the lubo-issue-96 branch December 5, 2023 18:30
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.

parseStrict() not throwing given partial message ProtoWriterTools methods throw IOException for no reason
4 participants