adorsys / secure-storage-android

Store strings & credentials securely encrypted on your device
Apache License 2.0
367 stars 58 forks source link

Add support for ordered collections of strings. #92

Open gmale opened 4 years ago

gmale commented 4 years ago

While using this library with ordered sets, I encountered a critical bug that would silently permute values because sets would be saved in order but loaded in random order! This was particularly bad for storing large keys, broken down into chunks. When restored, the values would change!! What made it so bad is that it would often work because sometimes the random order would match the initial order. So it got through several layers of testing, unnoticed.

This PR addresses the root issue by adding support for storing lists. Since Lists are inherently ordered, they are a more attractive option for developers who are breaking down large strings for storage. Also, the getStringSetValue function has been modified to use a LinkedHashSet under the hood, which is a non-breaking change but also makes it compatible with ordered sets.

Along the way, I encountered other bugs that I documented as github issues and fixed, as well. Lastly, I added unit tests in the style of existing tests to verify all new functionality.

All tests pass.

gmale commented 4 years ago

It's unclear why that check fails. All tests pass locally. @drilonrecica any ideas?

Screenshot from 2020-09-30 21-27-25

gmale commented 3 years ago

Is there anyone who can review this?

Linlinthu1991 commented 3 years ago

[gmale:bugfix/ordered-sets]()

``