Skip to content

Commit 25ab1ff

Browse files
committed
Replaced gzip back-end with pygzipf
1 parent 3678944 commit 25ab1ff

12 files changed

Lines changed: 46 additions & 11 deletions

File tree

.github/workflows/test_docker.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Install dependencies
1818
run: |
1919
dnf copr -y enable @gift/dev
20-
dnf install -y python3 libbde-python3 libewf-python3 libfsapfs-python3 libfsext-python3 libfshfs-python3 libfsntfs-python3 libfsxfs-python3 libfvde-python3 libfwnt-python3 libluksde-python3 libqcow-python3 libsigscan-python3 libsmdev-python3 libsmraw-python3 libvhdi-python3 libvmdk-python3 libvshadow-python3 libvslvm-python3 python3-cffi python3-cryptography python3-dfdatetime python3-dtfabric python3-idna python3-mock python3-pbr python3-pytsk3 python3-pyyaml python3-setuptools python3-six
20+
dnf install -y python3 libbde-python3 libewf-python3 libfsapfs-python3 libfsext-python3 libfshfs-python3 libfsntfs-python3 libfsxfs-python3 libfvde-python3 libfwnt-python3 libgzipf-python3 libluksde-python3 libqcow-python3 libsigscan-python3 libsmdev-python3 libsmraw-python3 libvhdi-python3 libvmdk-python3 libvshadow-python3 libvslvm-python3 python3-cffi python3-cryptography python3-dfdatetime python3-dtfabric python3-idna python3-mock python3-pbr python3-pytsk3 python3-pyyaml python3-setuptools python3-six
2121
- name: Run tests
2222
env:
2323
LANG: C.utf8
@@ -57,7 +57,7 @@ jobs:
5757
run: |
5858
add-apt-repository -y ppa:gift/dev
5959
apt-get update -q
60-
apt-get install -y python3 libbde-python3 libewf-python3 libfsapfs-python3 libfsext-python3 libfshfs-python3 libfsntfs-python3 libfsxfs-python3 libfvde-python3 libfwnt-python3 libluksde-python3 libqcow-python3 libsigscan-python3 libsmdev-python3 libsmraw-python3 libvhdi-python3 libvmdk-python3 libvshadow-python3 libvslvm-python3 python3-cffi-backend python3-cryptography python3-dfdatetime python3-distutils python3-dtfabric python3-idna python3-mock python3-pbr python3-pytsk3 python3-setuptools python3-six python3-yaml
60+
apt-get install -y python3 libbde-python3 libewf-python3 libfsapfs-python3 libfsext-python3 libfshfs-python3 libfsntfs-python3 libfsxfs-python3 libfvde-python3 libfwnt-python3 libgzipf-python3 libluksde-python3 libqcow-python3 libsigscan-python3 libsmdev-python3 libsmraw-python3 libvhdi-python3 libvmdk-python3 libvshadow-python3 libvslvm-python3 python3-cffi-backend python3-cryptography python3-dfdatetime python3-distutils python3-dtfabric python3-idna python3-mock python3-pbr python3-pytsk3 python3-setuptools python3-six python3-yaml
6161
- name: Run tests
6262
env:
6363
LANG: en_US.UTF-8

.github/workflows/test_tox.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
add-apt-repository -y ppa:deadsnakes/ppa
3838
add-apt-repository -y ppa:gift/dev
3939
apt-get update -q
40-
apt-get install -y build-essential git python${{ matrix.python-version }} python${{ matrix.python-version }}-dev tox libbde-python3 libewf-python3 libfsapfs-python3 libfsext-python3 libfshfs-python3 libfsntfs-python3 libfsxfs-python3 libfvde-python3 libfwnt-python3 libluksde-python3 libqcow-python3 libsigscan-python3 libsmdev-python3 libsmraw-python3 libvhdi-python3 libvmdk-python3 libvshadow-python3 libvslvm-python3 python3-cffi-backend python3-cryptography python3-dfdatetime python3-distutils python3-dtfabric python3-idna python3-mock python3-pbr python3-pytsk3 python3-setuptools python3-six python3-yaml
40+
apt-get install -y build-essential git python${{ matrix.python-version }} python${{ matrix.python-version }}-dev tox libbde-python3 libewf-python3 libfsapfs-python3 libfsext-python3 libfshfs-python3 libfsntfs-python3 libfsxfs-python3 libfvde-python3 libfwnt-python3 libgzipf-python3 libluksde-python3 libqcow-python3 libsigscan-python3 libsmdev-python3 libsmraw-python3 libvhdi-python3 libvmdk-python3 libvshadow-python3 libvslvm-python3 python3-cffi-backend python3-cryptography python3-dfdatetime python3-distutils python3-dtfabric python3-idna python3-mock python3-pbr python3-pytsk3 python3-setuptools python3-six python3-yaml
4141
- name: Run tests
4242
env:
4343
LANG: en_US.UTF-8

.pylintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# A comma-separated list of package or module names from where C extensions may
88
# be loaded. Extensions are loading into the active Python interpreter and may
99
# run arbitrary code.
10-
extension-pkg-whitelist=pybde,pyewf,pyfsapfs,pyfsext,pyfshfs,pyfsntfs,pyfsxfs,pyfvde,pyfwnt,pyluksde,pyqcow,pysigscan,pysmdev,pysmraw,pytsk3,pyvhdi,pyvmdk,pyvshadow,pyvslvm
10+
extension-pkg-whitelist=pybde,pyewf,pyfsapfs,pyfsext,pyfshfs,pyfsntfs,pyfsxfs,pyfvde,pyfwnt,pygzipf,pyluksde,pyqcow,pysigscan,pysmdev,pysmraw,pytsk3,pyvhdi,pyvmdk,pyvshadow,pyvslvm
1111

1212
# Specify a score threshold to be exceeded before program exits with error.
1313
fail-under=10.0

config/appveyor/install.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Script to set up tests on AppVeyor Windows.
22

3-
$Dependencies = "PyYAML cffi cryptography dfdatetime dtfabric idna libbde libewf libfsapfs libfsext libfshfs libfsntfs libfsxfs libfvde libfwnt libluksde libqcow libsigscan libsmdev libsmraw libvhdi libvmdk libvshadow libvslvm mock pbr pytsk3 six"
3+
$Dependencies = "PyYAML cffi cryptography dfdatetime dtfabric idna libbde libewf libfsapfs libfsext libfshfs libfsntfs libfsxfs libfvde libfwnt libgzipf libluksde libqcow libsigscan libsmdev libsmraw libvhdi libvmdk libvshadow libvslvm mock pbr pytsk3 six"
44
$Dependencies = ${Dependencies} -split " "
55

66
$Output = Invoke-Expression -Command "git clone https://github.com/log2timeline/l2tdevtools.git ..\l2tdevtools 2>&1"

config/dpkg/control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Homepage: https://github.com/log2timeline/dfvfs
99

1010
Package: python3-dfvfs
1111
Architecture: all
12-
Depends: libbde-python3 (>= 20140531), libewf-python3 (>= 20131210), libfsapfs-python3 (>= 20201107), libfsext-python3 (>= 20200819), libfshfs-python3 (>= 20201103), libfsntfs-python3 (>= 20200921), libfsxfs-python3 (>= 20201114), libfvde-python3 (>= 20160719), libfwnt-python3 (>= 20160418), libluksde-python3 (>= 20200101), libqcow-python3 (>= 20201213), libsigscan-python3 (>= 20191221), libsmdev-python3 (>= 20140529), libsmraw-python3 (>= 20140612), libvhdi-python3 (>= 20201014), libvmdk-python3 (>= 20140421), libvshadow-python3 (>= 20160109), libvslvm-python3 (>= 20160109), python3-cffi-backend (>= 1.9.1), python3-cryptography (>= 2.0.2), python3-dfdatetime (>= 20200809), python3-dtfabric (>= 20170524), python3-idna (>= 2.5), python3-pytsk3 (>= 20160721), python3-yaml (>= 3.10), ${python3:Depends}, ${misc:Depends}
12+
Depends: libbde-python3 (>= 20140531), libewf-python3 (>= 20131210), libfsapfs-python3 (>= 20201107), libfsext-python3 (>= 20200819), libfshfs-python3 (>= 20201103), libfsntfs-python3 (>= 20200921), libfsxfs-python3 (>= 20201114), libfvde-python3 (>= 20160719), libfwnt-python3 (>= 20160418), libgzipf-python3 (>= 20201228), libluksde-python3 (>= 20200101), libqcow-python3 (>= 20201213), libsigscan-python3 (>= 20191221), libsmdev-python3 (>= 20140529), libsmraw-python3 (>= 20140612), libvhdi-python3 (>= 20201014), libvmdk-python3 (>= 20140421), libvshadow-python3 (>= 20160109), libvslvm-python3 (>= 20160109), python3-cffi-backend (>= 1.9.1), python3-cryptography (>= 2.0.2), python3-dfdatetime (>= 20200809), python3-dtfabric (>= 20170524), python3-idna (>= 2.5), python3-pytsk3 (>= 20160721), python3-yaml (>= 3.10), ${python3:Depends}, ${misc:Depends}
1313
Description: Python 3 module of dfVFS
1414
dfVFS, or Digital Forensics Virtual File System, provides read-only access to
1515
file-system objects from various storage media types and file formats. The goal

config/linux/gift_copr_install.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ PYTHON3_DEPENDENCIES="libbde-python3
1717
libfsxfs-python3
1818
libfvde-python3
1919
libfwnt-python3
20+
libgzipf-python3
2021
libluksde-python3
2122
libqcow-python3
2223
libsigscan-python3
@@ -62,6 +63,8 @@ DEBUG_DEPENDENCIES="libbde-debuginfo
6263
libfvde-python3-debuginfo
6364
libfwnt-debuginfo
6465
libfwnt-python3-debuginfo
66+
libgzipf-debuginfo
67+
libgzipf-python3-debuginfo
6568
libluksde-debuginfo
6669
libluksde-python3-debuginfo
6770
libqcow-debuginfo

config/linux/ubuntu_install_dfvfs.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ PYTHON_DEPENDENCIES="libbde-python3
2424
libfsxfs-python3
2525
libfvde-python3
2626
libfwnt-python3
27+
libgzipf-python3
2728
libluksde-python3
2829
libqcow-python3
2930
libsigscan-python3
@@ -70,6 +71,8 @@ DEBUG_DEPENDENCIES="libbde-dbg
7071
libfvde-python3-dbg
7172
libfwnt-dbg
7273
libfwnt-python3-dbg
74+
libgzipf-dbg
75+
libgzipf-python3-dbg
7376
libluksde-dbg
7477
libluksde-python3-dbg
7578
libqcow-dbg

dependencies.ini

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,15 @@ pypi_name: libfwnt-python
101101
rpm_name: libfwnt-python3
102102
version_property: get_version()
103103

104+
[pygzipf]
105+
dpkg_name: libgzipf-python3
106+
is_optional: true
107+
l2tbinaries_name: libgzipf
108+
minimum_version: 20201228
109+
pypi_name: libgzipf-python
110+
rpm_name: libgzipf-python3
111+
version_property: get_version()
112+
104113
[pyluksde]
105114
dpkg_name: libluksde-python3
106115
l2tbinaries_name: libluksde

dfvfs/file_io/gzip_file_io.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# -*- coding: utf-8 -*-
22
"""The gzip file-like object."""
33

4+
try:
5+
import pygzipf
6+
except ModuleNotFoundError:
7+
pygzipf = None
8+
49
from dfvfs.file_io import file_object_io
510
from dfvfs.lib import errors
611
from dfvfs.lib import gzipfile
@@ -13,16 +18,23 @@ class GzipFile(file_object_io.FileObjectIO):
1318
@property
1419
def comments(self):
1520
"""list(str): comments in the gzip file."""
16-
return [member.comment for member in self._file_object.members]
21+
return [member.comments for member in self._file_object.members]
1722

1823
@property
1924
def modification_times(self):
2025
"""list(int): modification times stored in the gzip file."""
26+
if pygzipf:
27+
return [member.get_modification_time_as_integer()
28+
for member in self._file_object.members]
29+
2130
return [member.modification_time for member in self._file_object.members]
2231

2332
@property
2433
def original_filenames(self):
2534
"""list(str): original filenames stored in the gzip file."""
35+
if pygzipf:
36+
return [member.name for member in self._file_object.members]
37+
2638
return [member.original_filename for member in self._file_object.members]
2739

2840
@property
@@ -54,6 +66,12 @@ def _OpenFileObject(self, path_spec):
5466
file_object = resolver.Resolver.OpenFileObject(
5567
path_spec.parent, resolver_context=self._resolver_context)
5668

69+
if pygzipf:
70+
gzipf_file = pygzipf.file()
71+
gzipf_file.open_file_object(file_object)
72+
73+
return gzipf_file
74+
5775
gzip_compressed_stream = gzipfile.GzipCompressedStream()
5876
gzip_compressed_stream.Open(file_object)
5977

dfvfs/lib/gzipfile.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class GzipMember(data_format.DataFormat):
8383
provides caching of gzip member data during the initial read of each member.
8484
8585
Attributes:
86-
comment (str): comment stored in the member.
86+
comments (str): comments stored in the member.
8787
member_end_offset (int): offset to the end of the member in the parent file
8888
object.
8989
member_start_offset (int): offset to the start of the member in the parent
@@ -153,7 +153,7 @@ def __init__(
153153
# Start offset of the cached uncompressed data of the member.
154154
self._cache_start_offset = None
155155

156-
self.comment = None
156+
self.comments = None
157157
self.modification_time = None
158158
self.operating_system = None
159159
self.original_filename = None
@@ -269,9 +269,9 @@ def _ReadMemberHeader(self, file_object):
269269
if member_header.flags & self._FLAG_FCOMMENT:
270270
file_offset = file_object.get_offset()
271271
string_value = self._ReadString(
272-
file_object, file_offset, self._CSTRING, 'comment')
272+
file_object, file_offset, self._CSTRING, 'comments')
273273

274-
self.comment = string_value.rstrip('\x00')
274+
self.comments = string_value.rstrip('\x00')
275275

276276
if member_header.flags & self._FLAG_FHCRC:
277277
file_object.read(2)

0 commit comments

Comments
 (0)