b2-sdk-python
b2-sdk-python copied to clipboard
Missing null check when parsing unverified SHA1
https://github.com/Backblaze/b2-sdk-python/blob/4aa3d3c09cc0b847d4baad1f8247a68b3b606c66/b2sdk/_internal/file_version.py#L99
This function is invoked in context where content_sha1 is typed as str | None. This code will crash on None input.
https://github.com/Backblaze/b2-sdk-python/blob/4aa3d3c09cc0b847d4baad1f8247a68b3b606c66/b2sdk/v2/file_version.py#L47
Simple test output with just related code copypasta into my own test runner.
Traceback (most recent call last):
File "/Users/mikes/PycharmProjects/account-api/tests/testing.py", line 147, in wrapper
return self.loop.run_until_complete(coro)
File "/Users/mikes/.pyenv/versions/3.6.12/lib/python3.6/asyncio/base_events.py", line 488, in run_until_complete
return future.result()
File "/Users/mikes/PycharmProjects/account-api/tests/test_storage_providers.py", line 84, in test_b2_object_attr_sha1_unset
result = await self.b2_provider.get_object_metadata('key', photo)
File "/Users/mikes/PycharmProjects/account-api/accounts/files/v4_1/providers.py", line 167, in get_object_metadata
if sha1.startswith(UNVERIFIED_CHECKSUM_PREFIX):
AttributeError: 'NoneType' object has no attribute 'startswith'