Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Python 3.13 compatibility #897

Merged
merged 20 commits into from
Feb 20, 2025
Merged

Add Python 3.13 compatibility #897

merged 20 commits into from
Feb 20, 2025

Conversation

JSCU-CNI
Copy link
Contributor

@JSCU-CNI JSCU-CNI commented Oct 9, 2024

@Schamper
Copy link
Member

Schamper commented Dec 4, 2024

Fixed up the rest, I believe only flow.record needs to add compatibility with 3.13 (path type).

Copy link

codecov bot commented Dec 4, 2024

Codecov Report

Attention: Patch coverage is 96.01594% with 10 lines in your changes missing coverage. Please review.

Project coverage is 78.34%. Comparing base (78f434f) to head (b5322f4).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
dissect/target/helpers/compat/path_313.py 95.40% 8 Missing ⚠️
dissect/target/helpers/compat/path_common.py 50.00% 1 Missing ⚠️
dissect/target/target.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #897      +/-   ##
==========================================
+ Coverage   78.24%   78.34%   +0.10%     
==========================================
  Files         336      337       +1     
  Lines       29673    29686      +13     
==========================================
+ Hits        23217    23258      +41     
+ Misses       6456     6428      -28     
Flag Coverage Δ
unittests 78.34% <96.01%> (+0.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Schamper
Copy link
Member

Schamper commented Dec 4, 2024

Depends on fox-it/flow.record#154

@JSCU-CNI JSCU-CNI marked this pull request as ready for review December 5, 2024 09:17
@JSCU-CNI
Copy link
Contributor Author

JSCU-CNI commented Dec 5, 2024

That looks great @Schamper, nice work!

@JSCU-CNI
Copy link
Contributor Author

JSCU-CNI commented Dec 5, 2024

Seems like some tests are still failing:

$ docker run --rm -it -v .:/data python:3.13 bash
root@4d52f1e090ab:/# useradd user && su user
user@a2523f6f5315:/data$ pip install -e .[dev] && pip install pytest pytest-cov coverage docutils
user@a2523f6f5315:/data$ pip install git+https://github.com/fox-it/flow.record.git@py313-compat
user@a2523f6f5315:/data$ pytest tests -vv
...
FAILED tests/loaders/test_ova.py::test_ova_loader - dissect.target.exceptions.FileNotFoundError: /st.ovf
FAILED tests/plugins/apps/vpn/test_wireguard.py::test_wireguard_plugin_global_log - AssertionError: assert './etc/wireguard/wg0.conf' == 'etc/wireguard/wg0.conf'
  
  - etc/wireguard/wg0.conf
  + ./etc/wireguard/wg0.conf
  ? ++
FAILED tests/plugins/apps/webserver/test_iis.py::test_plugins_apps_webservers_iis_access_iis_format - TypeError: can't compare offset-naive and offset-aware datetimes
FAILED tests/plugins/os/windows/test_clfs.py::test_clfs_plugin - AttributeError: 'TargetPath' object has no attribute '_flavour'
FAILED tests/test_container.py::test_open_fallback_fh - AttributeError: 'RawContainer' object has no attribute 'size'
FAILED tests/test_container.py::test_reset_file_position - AttributeError: 'MockContainer' object has no attribute 'size'
FAILED tests/tools/test_dump.py::test_execute_pipeline[jsonlines-gzip] - TypeError: can't compare offset-naive and offset-aware datetimes
FAILED tests/tools/test_dump.py::test_execute_pipeline[jsonlines-bzip2] - TypeError: can't compare offset-naive and offset-aware datetimes
FAILED tests/tools/test_dump.py::test_execute_pipeline[jsonlines-None] - TypeError: can't compare offset-naive and offset-aware datetimes
FAILED tests/tools/test_dump.py::test_execute_pipeline[msgpack-gzip] - TypeError: can't compare offset-naive and offset-aware datetimes
FAILED tests/tools/test_dump.py::test_execute_pipeline[msgpack-bzip2] - TypeError: can't compare offset-naive and offset-aware datetimes
FAILED tests/tools/test_dump.py::test_execute_pipeline[msgpack-None] - TypeError: can't compare offset-naive and offset-aware datetimes
FAILED tests/tools/test_dump.py::test_execute_pipeline_limited[5] - TypeError: can't compare offset-naive and offset-aware datetimes
FAILED tests/tools/test_dump.py::test_execute_pipeline_limited[15] - TypeError: can't compare offset-naive and offset-aware datetimes
FAILED tests/tools/test_dump.py::test_execute_pipeline_limited[None] - TypeError: can't compare offset-naive and offset-aware datetimes
========================================== 15 failed, 1907 passed, 1 skipped, 8 warnings in 34.07s ==========================================
user@a2523f6f5315:/data$ 

@Schamper
Copy link
Member

Schamper commented Dec 5, 2024

I didn't run the entire test suite yet with the flow.record fixes, so that probably still requires some looking into 😄

@JSCU-CNI
Copy link
Contributor Author

JSCU-CNI commented Dec 5, 2024

Looks good, all tests seem to be working now. We mitigated some new 3.13 DeprecationWarnings in 2ceb21c. Two remain as it seems pathlib.Path.is_reserved() will be deprecated from 3.15 and onwards. What do you suggest we do here?

tests/helpers/test_fsutil.py::test_target_path_is_reserved
  /data/tests/helpers/test_fsutil.py:316: DeprecationWarning: pathlib.PurePath.is_reserved() is deprecated and scheduled for removal in Python 3.15. Use os.path.isreserved() to detect reserved paths on Windows.
    assert not path_fs.path("CON").is_reserved()

tests/helpers/test_fsutil.py::test_target_path_is_reserved
  /data/tests/helpers/test_fsutil.py:317: DeprecationWarning: pathlib.PurePath.is_reserved() is deprecated and scheduled for removal in Python 3.15. Use os.path.isreserved() to detect reserved paths on Windows.
    assert not path_fs.path("foo").is_reserved()

@Schamper Schamper changed the title Make TargetPath Python 3.13 compatible Add Python 3.13 compatibility Dec 5, 2024
@Schamper
Copy link
Member

Schamper commented Dec 5, 2024

I saw that deprecation warning as well when looking at the pathlib changes, but the alternative is not really a good fit for Dissect. We don't really use that function anyway beside a unit test, so maybe remove it from the unit test and add a fsutil.isreserved() for completeness sake?

@JSCU-CNI
Copy link
Contributor Author

JSCU-CNI commented Dec 9, 2024

[..] so maybe remove it from the unit test and add a fsutil.isreserved() for completeness sake?

b860576 looks like a good solution.

1932 passed, 1 skipped in 33.90s

Seems like this PR is good to go :)

@JSCU-CNI
Copy link
Contributor Author

JSCU-CNI commented Jan 8, 2025

We performed some more testing on 3.13 and have not come across any breaking issues.

@JSCU-CNI
Copy link
Contributor Author

JSCU-CNI commented Jan 9, 2025

I think the tests for 3.13 fail because the CI does not install the pre-release version of flow.record.

@Schamper
Copy link
Member

Schamper commented Jan 9, 2025

We have to bump that version anyway, so we'll just have to wait for a new release.

@Horofic Horofic self-assigned this Jan 9, 2025
Co-authored-by: Stefan de Reuver <[email protected]>
@Schamper Schamper requested a review from Horofic January 10, 2025 13:12
Horofic
Horofic previously approved these changes Jan 10, 2025
Horofic
Horofic previously approved these changes Jan 11, 2025
@Schamper
Copy link
Member

Can be merged after a new release of flow.record.

@JSCU-CNI
Copy link
Contributor Author

Tests should pass now that flow.record 3.19 has been released.

@Schamper Schamper merged commit aeb7cfc into fox-it:main Feb 20, 2025
19 of 22 checks passed
@JSCU-CNI JSCU-CNI deleted the py313-support branch February 24, 2025 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CPython 3.13 support
3 participants