Skip to content

Commit 2b946b0

Browse files
authored
Merge pull request #1008 from onekey-sec/drop-python3.8
Drop python 3.8 support
2 parents 94f13df + 8c778cd commit 2b946b0

36 files changed

+462
-534
lines changed

.github/actions/setup-dependencies/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ inputs:
22
python-version:
33
description: "Python version to setup"
44
required: false
5-
default: "3.8"
5+
default: "3.9"
66

77
name: "Setup dependencies"
88
description: "Install all required dependencies for worflows to run."

.github/workflows/documentation.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@ jobs:
1616
- name: Setup Python
1717
uses: actions/setup-python@v5
1818
with:
19-
python-version: 3.8
19+
python-version: 3.9
2020

2121
- name: Setup Python
2222
uses: actions/setup-python@v5
2323
with:
24-
python-version: 3.8
24+
python-version: 3.9
2525

2626
- name: Restore pip cache
2727
uses: actions/cache@v4
2828
with:
2929
path: ~/.cache/pip
30-
key: pip-3.8
30+
key: pip-3.9
3131

3232
- name: Upgrade pip and install poetry
3333
run: python -m pip install --upgrade pip poetry
@@ -39,13 +39,13 @@ jobs:
3939
path: |
4040
~/.cache/pypoetry/cache
4141
~/.cache/pypoetry/artifacts
42-
key: poetry-cache-and-artifacts-3.8
42+
key: poetry-cache-and-artifacts-3.9
4343

4444
- name: Restore virtualenvs
4545
uses: actions/cache@v4
4646
with:
4747
path: ~/.cache/pypoetry/virtualenvs
48-
key: venv-${{ hashFiles('poetry.lock') }}-3.8
48+
key: venv-${{ hashFiles('poetry.lock') }}-3.9
4949

5050
- name: Poetry install
5151
run: poetry install --only docs

.github/workflows/run-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
runs-on: ubuntu-latest
5050
strategy:
5151
matrix:
52-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
52+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
5353
steps:
5454
- name: Checkout source code
5555
uses: actions/checkout@v4

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.8-slim
1+
FROM python:3.12-slim
22

33
RUN mkdir -p /data/input /data/output
44
RUN useradd -m unblob

docs/development.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ where the exciting stuff is.
2626

2727
### Required tools
2828

29-
- **Python**: unblob requires **Python 3.8** or above. Make sure that
29+
- **Python**: unblob requires **Python 3.9** or above. Make sure that
3030
[Python is installed](https://www.python.org/downloads/) on your system.
3131

3232
- **git**: You need it for cloning the repository.
@@ -48,7 +48,7 @@ where the exciting stuff is.
4848
- **pyenv** (_Recommended_): When you are working with multiple versions of Python,
4949
pyenv makes it very easy to install and use different versions and make virtualenvs.
5050
Follow the [instructions on GitHub](https://github.com/pyenv/pyenv) for the installation.
51-
If your system already has at least Python 3.8 installed, you don't need it.
51+
If your system already has at least Python 3.9 installed, you don't need it.
5252

5353
### Cloning the Git repository
5454

@@ -85,7 +85,7 @@ Or instead of Poetry you can use `pyenv`. You can set the Python interpreter
8585
version for the local folder only with:
8686

8787
```
88-
pyenv local 3.8.12
88+
pyenv local 3.12.7
8989
```
9090

9191
### Installing Python dependencies

poetry.lock

Lines changed: 316 additions & 382 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ packages = [
99
]
1010

1111
[tool.poetry.dependencies]
12-
python = "^3.8"
12+
python = "^3.9"
1313
click = "^8.1.7"
14-
"dissect.cstruct" = ">=2.0,<5.0"
14+
"dissect.cstruct" = ">=4.0,<5.0"
1515
attrs = ">=23.1.0"
1616
structlog = ">=24.1.0"
1717
arpy = "^2.3.0"
@@ -57,7 +57,7 @@ mkdocstrings-python = "^1.8.0"
5757
unblob = "unblob.cli:main"
5858

5959
[tool.ruff]
60-
target-version = "py38"
60+
target-version = "py39"
6161

6262
[tool.ruff.lint]
6363
select = [

tests/test_cli.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
from collections.abc import Iterable
12
from pathlib import Path
2-
from typing import Iterable, List, Optional, Tuple, Type
3+
from typing import Optional
34
from unittest import mock
45

56
import pytest
@@ -157,7 +158,7 @@ def test_help(params):
157158
),
158159
],
159160
)
160-
def test_without_file(params: List[str]):
161+
def test_without_file(params: list[str]):
161162
runner = CliRunner()
162163
result = runner.invoke(unblob.cli.cli, params)
163164
assert result.exit_code == 2
@@ -238,7 +239,7 @@ def test_archive_success(
238239
expected_randomness_depth: int,
239240
expected_process_num: int,
240241
expected_verbosity: int,
241-
expected_progress_reporter: Type[ProgressReporter],
242+
expected_progress_reporter: type[ProgressReporter],
242243
tmp_path: Path,
243244
):
244245
runner = CliRunner()
@@ -254,9 +255,10 @@ def test_archive_success(
254255
process_file_mock = mock.MagicMock()
255256
logger_config_mock = mock.MagicMock()
256257
new_params = [*params, "--extract-dir", str(tmp_path), str(in_path)]
257-
with mock.patch.object(
258-
unblob.cli, "process_file", process_file_mock
259-
), mock.patch.object(unblob.cli, "configure_logger", logger_config_mock):
258+
with (
259+
mock.patch.object(unblob.cli, "process_file", process_file_mock),
260+
mock.patch.object(unblob.cli, "configure_logger", logger_config_mock),
261+
):
260262
result = runner.invoke(unblob.cli.cli, new_params)
261263
assert result.exit_code == 0
262264
assert "error" not in result.output
@@ -285,7 +287,7 @@ def test_archive_success(
285287
],
286288
)
287289
def test_keep_extracted_chunks(
288-
args: List[str], keep_extracted_chunks: bool, fail_message: str, tmp_path: Path
290+
args: list[str], keep_extracted_chunks: bool, fail_message: str, tmp_path: Path
289291
):
290292
runner = CliRunner()
291293
in_path = (
@@ -321,7 +323,7 @@ def test_keep_extracted_chunks(
321323
],
322324
)
323325
def test_skip_extension(
324-
skip_extension: List[str], expected_skip_extensions: Tuple[str, ...], tmp_path: Path
326+
skip_extension: list[str], expected_skip_extensions: tuple[str, ...], tmp_path: Path
325327
):
326328
runner = CliRunner()
327329
in_path = (
@@ -355,7 +357,7 @@ def test_skip_extension(
355357
],
356358
)
357359
def test_skip_extraction(
358-
args: List[str], skip_extraction: bool, fail_message: str, tmp_path: Path
360+
args: list[str], skip_extraction: bool, fail_message: str, tmp_path: Path
359361
):
360362
runner = CliRunner()
361363
in_path = (
@@ -403,7 +405,7 @@ def test_skip_extraction(
403405
],
404406
)
405407
def test_clear_skip_magics(
406-
args: List[str], skip_magic: Iterable[str], fail_message: str, tmp_path: Path
408+
args: list[str], skip_magic: Iterable[str], fail_message: str, tmp_path: Path
407409
):
408410
runner = CliRunner()
409411
in_path = (

tests/test_file_utils.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import io
22
import os
33
from pathlib import Path
4-
from typing import List
54

65
import pytest
76

@@ -296,7 +295,7 @@ def test_decode_invalid_values(self, value: bytes):
296295
(b"abcdef abcdef", b"not-found", []),
297296
],
298297
)
299-
def test_iterate_patterns(content: bytes, pattern: bytes, expected: List[int]):
298+
def test_iterate_patterns(content: bytes, pattern: bytes, expected: list[int]):
300299
file = File.from_bytes(content)
301300
assert list(iterate_patterns(file, pattern)) == expected
302301

@@ -320,7 +319,7 @@ def test_iterate_file(
320319
start_offset: int,
321320
size: int,
322321
buffer_size: int,
323-
expected: List[bytes],
322+
expected: list[bytes],
324323
):
325324
file = File.from_bytes(content)
326325
assert list(iterate_file(file, start_offset, size, buffer_size)) == expected
@@ -512,7 +511,7 @@ def test_create_symlink(self, sandbox: FileSystem):
512511

513512
output_path = sandbox.root / "symlink"
514513
assert not output_path.exists()
515-
assert os.readlink(output_path) == "target file"
514+
assert output_path.readlink() == Path("target file")
516515
assert sandbox.problems == []
517516

518517
def test_create_symlink_target_inside_sandbox(self, sandbox: FileSystem):
@@ -525,7 +524,7 @@ def test_create_symlink_target_inside_sandbox(self, sandbox: FileSystem):
525524
output_path = sandbox.root / "sbin/shell"
526525
assert output_path.read_bytes() == b"posix shell"
527526
assert output_path.exists()
528-
assert os.readlink(output_path) == "../bin/sh"
527+
assert output_path.readlink() == Path("../bin/sh")
529528
assert sandbox.problems == []
530529

531530
def test_create_symlink_target_outside_sandbox(self, sandbox: FileSystem):
@@ -545,7 +544,7 @@ def test_create_symlink_absolute_paths(self, sandbox: FileSystem):
545544

546545
output_path = sandbox.root / "symlink"
547546
assert output_path.exists()
548-
assert os.readlink(output_path) == "target file"
547+
assert output_path.readlink() == Path("target file")
549548
assert sandbox.problems == []
550549

551550
def test_create_symlink_absolute_paths_self_referenced(self, sandbox: FileSystem):
@@ -554,7 +553,7 @@ def test_create_symlink_absolute_paths_self_referenced(self, sandbox: FileSystem
554553

555554
output_path = sandbox.root / "etc/passwd"
556555
assert not output_path.exists()
557-
assert os.readlink(output_path) == "../etc/passwd"
556+
assert output_path.readlink() == Path("../etc/passwd")
558557
assert sandbox.problems == []
559558

560559
def test_create_symlink_outside_sandbox(self, sandbox: FileSystem):

tests/test_handlers.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
import inspect
1111
from pathlib import Path
12-
from typing import Type
1312

1413
import pytest
1514

@@ -43,7 +42,7 @@ def test_all_handlers(
4342
"handler",
4443
(pytest.param(handler, id=handler.NAME) for handler in handlers.BUILTIN_HANDLERS),
4544
)
46-
def test_missing_handlers_integrations_tests(handler: Type[Handler]):
45+
def test_missing_handlers_integrations_tests(handler: type[Handler]):
4746
handler_module_path = Path(inspect.getfile(handler))
4847
handler_test_path = handler_module_path.relative_to(
4948
HANDLERS_PACKAGE_PATH

0 commit comments

Comments
 (0)