Skip to content

Commit

Permalink
Merge pull request #51 from crest42/bump_cryptography
Browse files Browse the repository at this point in the history
* Bump dependencies (notably cryptography>=39.0.1 and flask>=2.2.0)

* Deprecate Python 3.7 due to EOL soon and bump trx version to 1.6.1
* Drop support for Python 2 and remove dependency on 'six'
This commit removes all code and dependencies related to Python 2, including the 'six' library.

This will allow us to focus on using modern Python features and libraries, and streamline our codebase. Any future contributions should be made with Python >=3.8 in mind.

* Update GitHub action to test Python 3.8 - 3.10 only

This commit updates the GitHub action to test our codebase only with Python versions 3.8, 3.9, and 3.10.

* Make github action run on master merges with action pull_request_target

---------

Co-authored-by: Robin Lösch <[email protected]>
  • Loading branch information
crest42 and crest42 authored Apr 27, 2023
2 parents 534a2cb + 0f6715b commit 198d16d
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 30 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/pythonx-boot-check.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
name: 'Runs with Python3.6 - Python3.10'

on: [ push ]
on:
pull_request_target:
branches:
- 'master'

jobs:
boots:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.6.x', '3.7.x', '3.8.x', '3.9.x', '3.10.x' ]
python-version: [ '3.8.x', '3.9.x', '3.10.x' ]

steps:
- uses: actions/checkout@v2
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/pythonx-pytest.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
name: 'PyTest with Python3.6 - Python3.10'

on: [ push ]
on:
pull_request_target:
branches:
- 'master'

jobs:
pytest:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.6.x', '3.7.x', '3.8.x', '3.9.x', '3.10.x' ]
python-version: [ '3.8.x', '3.9.x', '3.10.x' ]

steps:
- uses: actions/checkout@v2
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/sonatype-jack.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
name: 'Sonatype Jake'

on: [ push ]
on:
pull_request_target:
branches:
- 'master'

jobs:
security:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.6.x', '3.10.x' ]
python-version: [ '3.8.x', '3.9.x', '3.10.x' ]

steps:
- uses: actions/checkout@v2
Expand All @@ -19,9 +22,6 @@ jobs:

- name: Run jake from Sonatype
run: |
# needed for Python3.6
export PYTHONIOENCODING=utf-8
python -m pip install --upgrade pip
pip3 install -r requirements.txt
pip3 freeze > frozen.requirements.txt
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# Maltego TRX Python Library

[![Runs with Python3.6 - Python3.10](https://github.com/paterva/maltego-trx/actions/workflows/pythonx-boot-check.yaml/badge.svg)](https://github.com/paterva/maltego-trx/actions/workflows/pythonx-boot-check.yaml)
[![PyTest with Python3.6 - Python3.10](https://github.com/paterva/maltego-trx/actions/workflows/pythonx-pytest.yaml/badge.svg)](https://github.com/paterva/maltego-trx/actions/workflows/pythonx-pytest.yaml)
[![Runs with Python3.8 - Python3.10](https://github.com/paterva/maltego-trx/actions/workflows/pythonx-boot-check.yaml/badge.svg)](https://github.com/paterva/maltego-trx/actions/workflows/pythonx-boot-check.yaml)
[![PyTest with Python3.8 - Python3.10](https://github.com/paterva/maltego-trx/actions/workflows/pythonx-pytest.yaml/badge.svg)](https://github.com/paterva/maltego-trx/actions/workflows/pythonx-pytest.yaml)
[![Sonatype Jake](https://github.com/paterva/maltego-trx/actions/workflows/sonatype-jack.yml/badge.svg)](https://github.com/paterva/maltego-trx/actions/workflows/sonatype-jack.yml)

## Release Notes

__1.6.1__: Update cryptography and Flask dependency and deprecate Python 3.7

__1.6.0__: Automatically generate am `.mtz` for your local transforms

__1.5.2__: Add logging output for invalid / missing params in xml serialization
Expand All @@ -22,7 +24,7 @@ __1.4.2__: Fixed python3.6 incompatibility

## Getting Started

_Note: Support for Python 2 has been officially discontinued as of July 2021. Please use Python 3.6 or higher to use
_Note: Support for Python 2 has been officially discontinued as of July 2021. Please use Python 3.8 or higher to use
up-to-date versions of Maltego TRX._

To install the trx library run the following command:
Expand Down
2 changes: 1 addition & 1 deletion maltego_trx/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = "1.6.0"
VERSION = "1.6.1"
8 changes: 3 additions & 5 deletions maltego_trx/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
from xml.etree import ElementTree
from xml.etree.ElementTree import Element

from six import text_type, binary_type

logger = logging.getLogger("maltego-trx")


Expand Down Expand Up @@ -39,12 +37,12 @@ def make_printable(val):


def force_encoding(val, encoding):
if type(val) == text_type:
if isinstance(val, str):
return val.encode(encoding, 'replace').decode(encoding, 'replace')
elif type(val) == binary_type:
elif isinstance(val, bytes):
return val.decode(encoding, 'replace')
else:
return text_type(val).encode(encoding, 'replace').decode(encoding, 'replace')
return str(val).encode(encoding, 'replace').decode(encoding, 'replace')


def remove_invalid_xml_chars(val):
Expand Down
6 changes: 2 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
flask>=1
six>=1
cryptography==3.3.2 # pinned for now as newer versions require setuptools_rust
dataclasses==0.8; python_version < "3.7"
flask>=2.2.3
cryptography==39.0.1
11 changes: 3 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

setup(
name='maltego-trx',
python_requires='>=3.8.0',
version=VERSION,
description='Python library used to develop Maltego transforms',
long_description=long_description,
Expand All @@ -15,15 +16,9 @@
author_email='[email protected]',
license='MIT',
install_requires=[
'flask>=1',
'six>=1',
'cryptography==3.3.2' # pinned for now as newer versions require setuptools_rust
'flask>=2.2.0',
'cryptography>=39.0.1'
],
extras_require={
':python_version == "3.6"': [
'dataclasses',
],
},
packages=[
'maltego_trx',
'maltego_trx/template_dir',
Expand Down

0 comments on commit 198d16d

Please sign in to comment.