Open csisl opened 1 year ago
@csisl, I like this idea!
Do you have any preference/suggestion for how this feature might be implemented?
I think adding a password
class attribute and a set_password(pwd)
method inside of the ZipUnpacker
class could work. The ZipUnpacker class could detect if subprocess is waiting for input. Then three scenarios could happen:
self.password
was set with one or more passwords before unpack()
was called. Attempt to unzip with the passwords provided, one at a timeIf the above was implemented in the core, I think the calling code could that users could write would look something like this:
...
await resource.identify()
if resource.has_tag(ZipArchive):
resource.set_password('dummy')
await resource.unpack()
or maybe you have to tell the resource which Component should have the password because there can be multiple Components for a single resource?
await resource.identify()
if resource.has_tag(ZipArchive):
resource.set_password(ZipArchive, 'dummy')
await resource.unpack()
Also, the zipfile
library provides the option to use a password when extracting and there is no consequence of using a password when it's not needed.
import zipfile
my_zip = zipfile.ZipFile(path)
pwd = 'dummy'.encode('utf-8')
my_zip.extractall('/tmp', pwd=pwd)
Things I'm not sure about that might affect implementation:
What is the use case for the feature?
When unpacking, if a zip file is password protected, the process will hang until the password is entered on the command line. This disrupts automated workflows when using the Python library +
unpack()
call.Does the feature contain any proprietary information about another company's intellectual property?
No.