Skip to content

fix/python upgrade 3.11->3.13#3320

Closed
IshaanXCoder wants to merge 12 commits intointelowlproject:developfrom
IshaanXCoder:fix/python-version-upgrade
Closed

fix/python upgrade 3.11->3.13#3320
IshaanXCoder wants to merge 12 commits intointelowlproject:developfrom
IshaanXCoder:fix/python-version-upgrade

Conversation

@IshaanXCoder
Copy link
Copy Markdown
Contributor

Description

This PR resolved #3306 where we're upgrading python version from 3.11 to 3.13
I have updated the necessary configuration files, CI workflows, Docker files and test files for compatibility (a few test files are still breaking)

  • Minor changes were made due to some depreceated functions like assertDictContainsSubset()
  • pydeep has been replaced with ppdeep
  • removal of PosixPath
  • in api_app/analyzers_manager/observable_analyzers/maxmind.py , i noticed the test was failing with cls._api_key_name, changed it to auth_token (need a feedback on this)
  • made some changes in docker/test.override.yml for my local , adding for reference here.

Type of change

  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as expected -> tried my best to fix these, still might be a few, will fix with discussion).

Checklist

  • I have read and understood the rules about how to Contribute to this project
  • The pull request is for the branch develop
  • I have inserted the copyright banner at the start of the file: # This file is a part of IntelOwl https://github.com/intelowlproject/IntelOwl # See the file 'LICENSE' for copying permission.
  • Please avoid adding new libraries as requirements whenever it is possible. Use new libraries only if strictly needed to solve the issue you are working for. In case of doubt, ask a maintainer permission to use a specific library.
  • If external libraries/packages with restrictive licenses were added, they were added in the Legal Notice section.
  • Linters (Ruff) gave 0 errors. If you have correctly installed pre-commit, it does these checks and adjustments on your behalf.

Important Rules

  • If you miss to compile the Checklist properly, your PR won't be reviewed by the maintainers.
  • Everytime you make changes to the PR and you think the work is done, you should explicitly ask for a review by using GitHub's reviewing system detailed here.

Copilot AI review requested due to automatic review settings February 15, 2026 20:44
@IshaanXCoder IshaanXCoder marked this pull request as draft February 15, 2026 20:44
@IshaanXCoder
Copy link
Copy Markdown
Contributor Author

@mlodic ptal at this draft pr, still need to make many changes on failing tests, i just want to get some reviews on the work done till now

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR upgrades the project from Python 3.11 to Python 3.13, addressing compatibility issues with deprecated functions and updating dependencies. The linked issue mentions Python 3.14, but correctly targets Python 3.13 (the latest stable version).

Changes:

  • Updated Python base images to 3.13 in Dockerfiles and CI workflows
  • Replaced deprecated testing methods (assertDictContainsSubset) with explicit key-value assertions
  • Replaced pydeep library with ppdeep and updated API calls accordingly
  • Upgraded major dependencies (Django 5.2, DRF 3.16.1, Celery 5.6.0, etc.)
  • Fixed bug in maxmind.py where incorrect variable was passed to update_all_dbs
  • Removed unnecessary PosixPath usage from TextChoices enum
  • Updated typing.Generator syntax to simplified Python 3.9+ format

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
docker/Dockerfile Updated base image from python:3.11.7 to python:3.13-slim
integrations/tor_analyzers/Dockerfile Fixed python:3.14-slim (non-existent) to python:3.13-slim
integrations/malware_tools_analyzers/Dockerfile Updated base image to python:3.13-slim
.github/workflows/pull_request_automation.yml Updated CI Python version to 3.13
.github/workflows/codeql-analysis.yml Updated CI Python version to 3.13
pyproject.toml Updated Ruff target-version to py313
requirements/project-requirements.txt Upgraded Django, DRF, Celery, and other dependencies for Python 3.13 compatibility; replaced pydeep with ppdeep
api_app/choices.py Removed PosixPath wrapper from TextChoices enum values; simplified typing.Generator syntax
api_app/analyzers_manager/file_analyzers/file_info.py Updated to use ppdeep.hash_from_file instead of pydeep.hash_file
api_app/analyzers_manager/observable_analyzers/maxmind.py Fixed bug: pass auth_token instead of cls._api_key_name to update_all_dbs
tests/test_crons.py Removed skip import (unused); updated test_maxmind_updater with proper mocking; changed retention days from 10 to 30
tests/api_app/test_views.py Replaced deprecated assertDictContainsSubset with explicit for-loop assertions
tests/api_app/test_api.py Replaced deprecated assertDictContainsSubset with assertIn and assertEqual
tests/api_app/analyzers_manager/unit_tests/observable_analyzers/test_greynoise_labs.py Changed report mock from dict to SimpleNamespace with save method
tests/api_app/analyzers_manager/unit_tests/file_analyzers/test_file_info.py Updated mock from pydeep.hash_file to ppdeep.hash_from_file
tests/api_app/analyzers_manager/unit_tests/file_analyzers/test_blint_scan.py Fixed mock patch to target import location in module (best practice)
tests/api_app/analyzers_manager/unit_tests/file_analyzers/base_test_class.py Added missing test file mapping for application/x-elf
docker/test.override.yml Added MOCK_CONNECTIONS and CELERY_TASK_SOFT_TIME_LIMIT environment variables

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/test_crons.py Outdated
Comment thread docker/test.override.yml Outdated
Comment thread docker/Dockerfile Outdated
Comment thread docker/test.override.yml Outdated
Comment thread integrations/tor_analyzers/Dockerfile Outdated
Comment thread requirements/project-requirements.txt Outdated
Comment thread tests/api_app/analyzers_manager/unit_tests/file_analyzers/test_file_info.py Outdated
@IshaanXCoder
Copy link
Copy Markdown
Contributor Author

Hey @mlodic PTAL at this, i've made the required changes, few tests are still failing on my local, but they seem to be unrelated with python migration.

Copy link
Copy Markdown
Member

@mlodic mlodic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are still linter errors.

Also, ppdeep is not compliant to IntelOwl basic scorecard checks. I checked that project and there is a single maintainer keeping it so it can be quite unreliable on the long term. Isn't there any alternatives?

Comment thread requirements/project-requirements.txt Outdated
@IshaanXCoder
Copy link
Copy Markdown
Contributor Author

IshaanXCoder commented Feb 17, 2026

there are still linter errors.

alright i've fixed this, there was an erorr due to modern style of python (eg, Generator[Signature, None, None] to the modern equivalent Generator[Signature])

Also, ppdeep is not compliant to IntelOwl basic scorecard checks. I checked that project and there is a single maintainer keeping it so it can be quite unreliable on the long term. Isn't there any alternatives?

an alternative which we've is https://github.com/DinoTools/python-ssdeep , but it doesnt have any commits since past 5 years.

@IshaanXCoder
Copy link
Copy Markdown
Contributor Author

@mlodic should i proceed with the above approaches?

@mlodic
Copy link
Copy Markdown
Member

mlodic commented Feb 17, 2026

that's still another very niche and old repository but it is older like the other one that we are already using as of now. You can try it and see whether it passes the tests and the scorecard test

@IshaanXCoder
Copy link
Copy Markdown
Contributor Author

that's still another very niche and old repository but it is older like the other one that we are already using as of now. You can try it and see whether it passes the tests and the scorecard test

Alright, agreed.
Sure, i'll check and let you know about the same at the earliest.

@IshaanXCoder
Copy link
Copy Markdown
Contributor Author

IshaanXCoder commented Feb 17, 2026

Nope, ssdeep didnt work due to python version issue

@mlodic
Copy link
Copy Markdown
Member

mlodic commented Feb 17, 2026

we can use the ppdeep you propose first but we have to find a way to circumvent the dependency check with a special exclusion. See: https://github.com/intelowlproject/IntelOwl/blob/master/.github/workflows/dependency_review.yml
https://github.com/actions/dependency-review-action

@IshaanXCoder
Copy link
Copy Markdown
Contributor Author

find a way to circumvent the dependency check with a special exclusion

this can be done using allow-dependencies-licenses (mentioned here - https://github.com/actions/dependency-review-action/blob/main/README.md#configuration-options)

image

@IshaanXCoder IshaanXCoder marked this pull request as ready for review February 18, 2026 19:51
Copilot AI review requested due to automatic review settings February 18, 2026 19:51
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 22 out of 22 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pyproject.toml
Comment thread requirements/project-requirements.txt Outdated
Comment thread api_app/analyzers_manager/file_analyzers/file_info.py
Comment thread docker/test.override.yml Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 18, 2026 20:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 22 out of 22 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -1,4 +1,4 @@
FROM python:3.14-slim
FROM python:3.13.12
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Several integration Dockerfiles still use older Python versions and have not been updated to Python 3.13. For consistency and to complete the Python upgrade, the following Dockerfiles should also be updated: integrations/bbot/Dockerfile (uses python:3.12-slim), integrations/phishing_analyzers/Dockerfile (uses python:3.12.3), and integrations/phunter/Dockerfile (uses python:3.12-slim). Note that integrations/pcap_analyzers, integrations/thug, integrations/nuclei_analyzer, and integrations/cyberchef use base images that don't directly specify Python versions.

Copilot uses AI. Check for mistakes.
return_value="e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
),
patch("pydeep.hash_file", return_value=b"3:AOn4:An"),
patch("tlsh.hash", return_value="T1234567890ABCDEF"),
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing mock for ppdeep in the test. The old pydeep mock was removed, but no mock for ppdeep.hash_from_file was added. This will cause the test to fail if ppdeep is not installed or if the test file path doesn't exist, as ppdeep.hash_from_file will be called with an actual file path. Consider adding a mock for ppdeep similar to the other hash function mocks.

Suggested change
patch("tlsh.hash", return_value="T1234567890ABCDEF"),
patch("tlsh.hash", return_value="T1234567890ABCDEF"),
patch("ppdeep.hash_from_file", return_value="PPDEEP_HASH_VALUE"),

Copilot uses AI. Check for mistakes.
Comment thread docker/test.override.yml
@IshaanXCoder
Copy link
Copy Markdown
Contributor Author

A lot of commits have been added, i'll make a clean pr later after all the changes/reviews.

@IshaanXCoder IshaanXCoder requested a review from mlodic February 18, 2026 22:13
@mlodic
Copy link
Copy Markdown
Member

mlodic commented Feb 19, 2026

sure, thanks

@IshaanXCoder
Copy link
Copy Markdown
Contributor Author

sure, thanks

H3y @mlodic ! do we need any more changes or are we good to go? i'll make a new pr in that case.

@mlodic
Copy link
Copy Markdown
Member

mlodic commented Feb 19, 2026

it seems there are still errors in the CI

@IshaanXCoder
Copy link
Copy Markdown
Contributor Author

Hey @mlodic i checked out the test failures, some seemed to be independent of the python upgrade, but i've made a clean fix for all the backend tests. Have used patch and override_settings in some cases, hope that's not an issue.

Copilot AI review requested due to automatic review settings February 20, 2026 10:52
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@IshaanXCoder
Copy link
Copy Markdown
Contributor Author

working on this fail

@IshaanXCoder
Copy link
Copy Markdown
Contributor Author

there's an issue with pillow dependency,
https://github.com/intelowlproject/IntelOwl/actions/runs/22221253027/job/64276951563?pr=3320
Checked in the codebase, it's not being used anywhere, should we remove this?
Screenshot 2026-02-20 at 4 49 50 PM

@mlodic
Copy link
Copy Markdown
Member

mlodic commented Feb 20, 2026

It's a subdependency IIRC. Anyway I don't see the error, where it is?

@IshaanXCoder
Copy link
Copy Markdown
Contributor Author

under vulnerabilities
Screenshot 2026-02-20 at 4 59 40 PM

Comment thread requirements/project-requirements.txt Outdated
Copilot AI review requested due to automatic review settings February 20, 2026 12:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 30 out of 30 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/dependency_review.yml
Comment thread tests/api_app/test_classes.py
Comment thread docker/Dockerfile Outdated
Comment thread api_app/serializers/job.py
Comment thread api_app/analyzers_manager/classes.py
Comment thread tests/test_crons.py
Copilot AI review requested due to automatic review settings February 20, 2026 13:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 31 out of 31 changed files in this pull request and generated 10 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/auth/test_oauth.py
Comment thread integrations/tor_analyzers/Dockerfile
Comment thread integrations/malware_tools_analyzers/Dockerfile
Comment thread api_app/interfaces.py
Comment thread api_app/engines_manager/models.py
Comment thread api_app/analyzers_manager/observable_analyzers/maxmind.py
Comment thread tests/api_app/ingestors_manager/test_classes.py
Comment thread api_app/serializers/job.py
Comment thread api_app/choices.py
Comment thread api_app/classes.py
@IshaanXCoder IshaanXCoder mentioned this pull request Feb 21, 2026
6 tasks
@IshaanXCoder
Copy link
Copy Markdown
Contributor Author

Opened a clean PR at #3352

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.

3 participants