Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tests/_data/** filter=lfs diff=lfs merge=lfs -text
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
coverage.xml
.coverage
build/
dist/
.eggs/
*.egg-info/
*.pyc
__pycache__/
.pytest_cache/
tests/docs/api
tests/docs/build
tests/_docs/api
tests/_docs/build
.tox/
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ select = [
ignore = ["E203", "B904", "UP024", "ANN002", "ANN003", "ANN204", "ANN401", "SIM105", "TRY003"]

[tool.ruff.lint.per-file-ignores]
"tests/docs/**" = ["INP001"]
"tests/_docs/**" = ["INP001"]

[tool.ruff.lint.isort]
known-first-party = ["dissect.squashfs"]
Expand Down
3 changes: 3 additions & 0 deletions tests/_data/gzip-opts.sqfs
Git LFS file not shown
3 changes: 3 additions & 0 deletions tests/_data/gzip.sqfs
Git LFS file not shown
3 changes: 3 additions & 0 deletions tests/_data/lz4.sqfs
Git LFS file not shown
3 changes: 3 additions & 0 deletions tests/_data/lzma.sqfs
Git LFS file not shown
3 changes: 3 additions & 0 deletions tests/_data/lzo.sqfs
Git LFS file not shown
3 changes: 3 additions & 0 deletions tests/_data/xz.sqfs
Git LFS file not shown
3 changes: 3 additions & 0 deletions tests/_data/zstd.sqfs
Git LFS file not shown
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 7 additions & 7 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,34 +26,34 @@ def open_file_gz(name: str, mode: str = "rb") -> Iterator[BinaryIO]:

@pytest.fixture
def gzip_sqfs() -> Iterator[BinaryIO]:
yield from open_file("data/gzip.sqfs")
yield from open_file("_data/gzip.sqfs")


@pytest.fixture
def gzip_opts_sqfs() -> Iterator[BinaryIO]:
yield from open_file("data/gzip-opts.sqfs")
yield from open_file("_data/gzip-opts.sqfs")


@pytest.fixture
def lz4_sqfs() -> Iterator[BinaryIO]:
yield from open_file("data/lz4.sqfs")
yield from open_file("_data/lz4.sqfs")


@pytest.fixture
def lzma_sqfs() -> Iterator[BinaryIO]:
yield from open_file("data/lzma.sqfs")
yield from open_file("_data/lzma.sqfs")


@pytest.fixture
def lzo_sqfs() -> Iterator[BinaryIO]:
yield from open_file("data/lzo.sqfs")
yield from open_file("_data/lzo.sqfs")


@pytest.fixture
def xz_sqfs() -> Iterator[BinaryIO]:
yield from open_file("data/xz.sqfs")
yield from open_file("_data/xz.sqfs")


@pytest.fixture
def zstd_sqfs() -> Iterator[BinaryIO]:
yield from open_file("data/zstd.sqfs")
yield from open_file("_data/zstd.sqfs")
Binary file removed tests/data/gzip-opts.sqfs
Binary file not shown.
Binary file removed tests/data/gzip.sqfs
Binary file not shown.
Binary file removed tests/data/lz4.sqfs
Binary file not shown.
Binary file removed tests/data/lzma.sqfs
Binary file not shown.
Binary file removed tests/data/lzo.sqfs
Binary file not shown.
Binary file removed tests/data/xz.sqfs
Binary file not shown.
Binary file removed tests/data/zstd.sqfs
Binary file not shown.
19 changes: 19 additions & 0 deletions tests/test_squashfs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from __future__ import annotations

from io import BytesIO

import pytest

from dissect.squashfs.c_squashfs import c_squashfs
Expand Down Expand Up @@ -75,3 +77,20 @@ def test_squashfs(sqfs: str, compression_id: int, request: pytest.FixtureRequest
sqfs = SquashFS(request.getfixturevalue(sqfs))
assert sqfs.sb.compression == compression_id
_verify_filesystem(sqfs)


def test_squashfs_unsupported_bigendian_3_0() -> None:
"""Test if we correctly detect a SquashFS 3.0 big-endian filesystem."""

# Random SquashFS version 3.0 big-endian header found on binwalk GitHub issue tracker.
buf = bytes.fromhex(
"73717368000000b60000002042010d364200bc844200339440016800000300006b0400104003004ae64f330000000000"
"001623000100000000001177ff8e0800000000000e303100000000000e3025000000000000000000000000000e234c00"
)

sb = c_squashfs.squashfs_super_block(buf)
assert sb.s_magic == c_squashfs.SQUASHFS_MAGIC_SWAP
assert sb.s_major == 0x300

with pytest.raises(NotImplementedError, match="Unsupported squashfs pre-4.0 big-endian filesystem"):
SquashFS(BytesIO(buf))
8 changes: 4 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ deps =
sphinx-design
furo
commands =
make -C tests/docs clean
make -C tests/docs html
make -C tests/_docs clean
make -C tests/_docs html

[testenv:docs-linkcheck]
allowlist_externals = make
deps = {[testenv:docs-build]deps}
commands =
make -C tests/docs clean
make -C tests/docs linkcheck
make -C tests/_docs clean
make -C tests/_docs linkcheck