diff --git a/.isort.cfg b/.isort.cfg index 69e050ee6e71a26dbd8ffed12e239ebc499fdc2f..3fd5b5e9943afb92e081676235d0b4f46155608f 100644 --- a/.isort.cfg +++ b/.isort.cfg @@ -8,4 +8,4 @@ line_length = 120 default_section=FIRSTPARTY known_first_party = transkribus -known_third_party = SolrClient,bleach,boto3,botocore,corsheaders,django,django_admin_hstore_widget,django_rq,drf_spectacular,enumfields,gitlab,psycopg2,requests,responses,rest_framework,rq,setuptools,sqlparse,teklia_toolbox,tenacity,tripoli,yaml +known_third_party = SolrClient,bleach,boto3,botocore,cryptography,corsheaders,django,django_admin_hstore_widget,django_rq,drf_spectacular,enumfields,gitlab,psycopg2,requests,responses,rest_framework,rq,setuptools,sqlparse,teklia_toolbox,tenacity,tripoli,yaml diff --git a/arkindex/ponos/keys.py b/arkindex/ponos/keys.py index 31d77be0cd4cbd9d9e266157758111dcb94b9713..137da04232149e930a069b09a0ec45ec2a0fab25 100644 --- a/arkindex/ponos/keys.py +++ b/arkindex/ponos/keys.py @@ -7,12 +7,7 @@ from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives.asymmetric import ec from cryptography.hazmat.primitives.hashes import SHA256 from cryptography.hazmat.primitives.kdf.hkdf import HKDF -from cryptography.hazmat.primitives.serialization import ( - Encoding, - NoEncryption, - PrivateFormat, - load_pem_private_key, -) +from cryptography.hazmat.primitives.serialization import Encoding, NoEncryption, PrivateFormat, load_pem_private_key from django.conf import settings logger = logging.getLogger(__name__) diff --git a/arkindex/ponos/models.py b/arkindex/ponos/models.py index 37784016c7b676a5b0e4bf3c9a342c698ce8c5ac..ce312053fc6ee19f25af66997877e36e71586d23 100644 --- a/arkindex/ponos/models.py +++ b/arkindex/ponos/models.py @@ -7,6 +7,7 @@ from datetime import timedelta from hashlib import sha256 from botocore.exceptions import ClientError +from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes from django.conf import settings from django.core.exceptions import ValidationError from django.core.validators import MinLengthValidator, MinValueValidator, RegexValidator @@ -24,7 +25,6 @@ from arkindex.ponos.keys import gen_nonce from arkindex.ponos.managers import TaskManager from arkindex.ponos.recipe import parse_recipe, recipe_depth from arkindex.ponos.validators import MaxValueValidator -from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes from rest_framework_simplejwt.tokens import RefreshToken # Maximum allowed time until an agent is considered inactive since last request diff --git a/arkindex/ponos/serializer_fields.py b/arkindex/ponos/serializer_fields.py index 8b950c2dd63cfe692eef083a8d326d2791535cf8..1fac0de04256046114da513cda37487fa159dbf8 100644 --- a/arkindex/ponos/serializer_fields.py +++ b/arkindex/ponos/serializer_fields.py @@ -3,11 +3,7 @@ import base64 from cryptography.exceptions import UnsupportedAlgorithm from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives.asymmetric import ec -from cryptography.hazmat.primitives.serialization import ( - Encoding, - PublicFormat, - load_pem_public_key, -) +from cryptography.hazmat.primitives.serialization import Encoding, PublicFormat, load_pem_public_key from enumfields import Enum from rest_framework import serializers diff --git a/arkindex/ponos/tests/test_api.py b/arkindex/ponos/tests/test_api.py index d4d18d55147f8063c85c7382bc31046775611f28..5e1cd7da621a1e1079ca70ca61fbf51e6e4e5854 100644 --- a/arkindex/ponos/tests/test_api.py +++ b/arkindex/ponos/tests/test_api.py @@ -5,6 +5,11 @@ import uuid from io import BytesIO from unittest.mock import call, patch +from cryptography.hazmat.backends import default_backend +from cryptography.hazmat.primitives.asymmetric import ec +from cryptography.hazmat.primitives.hashes import SHA256 +from cryptography.hazmat.primitives.kdf.hkdf import HKDF +from cryptography.hazmat.primitives.serialization import Encoding, PublicFormat from django.conf import settings from django.contrib.auth.models import User from django.test import override_settings @@ -17,11 +22,6 @@ from arkindex.ponos.api import timezone as api_tz from arkindex.ponos.authentication import AgentUser from arkindex.ponos.models import FINAL_STATES, GPU, Agent, Farm, Secret, State, Task, Workflow, encrypt from arkindex.project.tools import build_public_key -from cryptography.hazmat.backends import default_backend -from cryptography.hazmat.primitives.asymmetric import ec -from cryptography.hazmat.primitives.hashes import SHA256 -from cryptography.hazmat.primitives.kdf.hkdf import HKDF -from cryptography.hazmat.primitives.serialization import Encoding, PublicFormat RECIPE = """ env: diff --git a/arkindex/ponos/tests/test_keys.py b/arkindex/ponos/tests/test_keys.py index 697c5717d6f7c576bb78355a22e31b855740d96a..f1d397e970dfe4f65304f8bb709c4434b434b2ad 100644 --- a/arkindex/ponos/tests/test_keys.py +++ b/arkindex/ponos/tests/test_keys.py @@ -1,9 +1,9 @@ import os import tempfile +import cryptography from django.test import TestCase, override_settings -import cryptography from arkindex.ponos.keys import gen_private_key, load_private_key BAD_KEY = """-----BEGIN RSA PRIVATE KEY----- diff --git a/arkindex/project/tools.py b/arkindex/project/tools.py index efdd02f823ff0defb1c87d1ade1b8eb5213b4459..1a9348d43adb9681f8c797f5b9723426c525f5ff 100644 --- a/arkindex/project/tools.py +++ b/arkindex/project/tools.py @@ -1,14 +1,14 @@ from collections.abc import Iterable, Iterator, Sized +from cryptography.hazmat.backends import default_backend +from cryptography.hazmat.primitives.asymmetric import ec +from cryptography.hazmat.primitives.serialization import Encoding, PublicFormat from django.db.models import Aggregate, CharField, Func from django.db.models.expressions import BaseExpression, OrderByList from django.urls import reverse from rest_framework import serializers from arkindex.documents.models import Element, ElementPath -from cryptography.hazmat.backends import default_backend -from cryptography.hazmat.primitives.asymmetric import ec -from cryptography.hazmat.primitives.serialization import Encoding, PublicFormat def build_absolute_url(element, request, name, id_argument='pk', **kwargs):