diff --git a/pkgs/development/python-modules/defusedcsv/default.nix b/pkgs/development/python-modules/defusedcsv/default.nix new file mode 100644 index 000000000000..5e44ce731748 --- /dev/null +++ b/pkgs/development/python-modules/defusedcsv/default.nix @@ -0,0 +1,35 @@ +{ lib +, buildPythonPackage +, fetchFromGitHub + +# tests +, pytestCheckHook +}: + +buildPythonPackage rec { + pname = "defusedcsv"; + version = "2.0.0"; + format = "setuptools"; + + src = fetchFromGitHub { + owner = "raphaelm"; + repo = "defusedcsv"; + rev = "refs/tags/v${version}"; + hash = "sha256-y8qLVfdkxRrDjtrTOLK5Zvi/1Vyv8eOnCueUkaRp4sQ="; + }; + + pythonImportsCheck = [ + "defusedcsv.csv" + ]; + + nativeCheckInputs = [ + pytestCheckHook + ]; + + meta = with lib; { + description = "Python library to protect your users from Excel injections in CSV-format exports, drop-in replacement for standard library's csv module"; + homepage = "https://github.com/raphaelm/defusedcsv"; + license = licenses.asl20; + maintainers = with maintainers; [ hexa ]; + }; +} diff --git a/pkgs/development/python-modules/django-i18nfield/default.nix b/pkgs/development/python-modules/django-i18nfield/default.nix new file mode 100644 index 000000000000..62d0770a693a --- /dev/null +++ b/pkgs/development/python-modules/django-i18nfield/default.nix @@ -0,0 +1,43 @@ +{ lib +, buildPythonPackage +, fetchFromGitHub + +# tests +, djangorestframework +, html5lib +, lxml +, pytest-django +, pytestCheckHook +, pyyaml +}: + +buildPythonPackage { + pname = "django-i18nfield"; + version = "1.9.4"; + format = "setuptools"; + + src = fetchFromGitHub { + owner = "raphaelm"; + repo = "django-i18nfield"; + rev = "10488eb6c673be50e50387c76085a7c8d84e9157"; + hash = "sha256-FF980LTw7RFuG9QgxA96yJsSczCNNMq9WsbacQqIReE="; + }; + + env.DJANGO_SETTINGS_MODULE = "tests.settings"; + + nativeCheckInputs = [ + djangorestframework + html5lib + lxml + pytest-django + pytestCheckHook + pyyaml + ]; + + meta = with lib; { + description = "Store internationalized strings in Django models"; + homepage = "https://github.com/raphaelm/django-i18nfield"; + license = licenses.asl20; + maintainers = with maintainers; [ hexa ]; + }; +} diff --git a/pkgs/development/python-modules/django-mysql/default.nix b/pkgs/development/python-modules/django-mysql/default.nix new file mode 100644 index 000000000000..0a53c6489fe0 --- /dev/null +++ b/pkgs/development/python-modules/django-mysql/default.nix @@ -0,0 +1,54 @@ +{ lib +, buildPythonPackage +, fetchFromGitHub + +# build-system +, setuptools + +# dependencies +, django +, mysqlclient + +# tests +, pytest-django +, pytestCheckHook +}: + +buildPythonPackage rec { + pname = "django-mysql"; + version = "4.9.0"; + format = "pyproject"; + + src = fetchFromGitHub { + owner = "adamchainz"; + repo = "django-mysql"; + rev = "refs/tags/${version}"; + hash = "sha256-mXAdwNqSIrWMh+YcCjksiqmkLSXGAd+ofyzJmiG+gNo="; + }; + + nativeBuildInputs = [ + setuptools + ]; + + buildInputs = [ + django + mysqlclient + ]; + + doCheck = false; # requires mysql/mariadb server + + env.DJANGO_SETTINGS_MODULE = "tests.settings"; + + nativeCheckInputs = [ + pytest-django + pytestCheckHook + ]; + + meta = with lib; { + changelog = "https://django-mysql.readthedocs.io/en/latest/changelog.html"; + description = "Extensions to Django for use with MySQL/MariaD"; + homepage = "https://github.com/adamchainz/django-mysql"; + license = licenses.mit; + maintainers = with maintainers; [ hexa ]; + }; +} diff --git a/pkgs/development/python-modules/drf-ujson2/default.nix b/pkgs/development/python-modules/drf-ujson2/default.nix new file mode 100644 index 000000000000..58277fca7ed6 --- /dev/null +++ b/pkgs/development/python-modules/drf-ujson2/default.nix @@ -0,0 +1,55 @@ +{ lib +, buildPythonPackage +, fetchFromGitHub + +# dependencies +, django +, djangorestframework +, ujson + +# tests +, pytest-django +, pytest-mock +, pytestCheckHook +}: + +buildPythonPackage rec { + pname = "drf-ujson2"; + version = "1.7.2"; + format = "setuptools"; + + src = fetchFromGitHub { + owner = "Amertz08"; + repo = "drf_ujson2"; + rev = "refs/tags/v${version}"; + hash = "sha256-kbpZN1zOXHvRPcn+Sjbelq74cWgvCUeMXZy1eFSa6rA="; + }; + + postPatch = '' + sed -i '/--cov/d' setup.cfg + ''; + + buildInputs = [ + django + ]; + + propagatedBuildInputs = [ + djangorestframework + ujson + ]; + + env.DJANGO_SETTINGS_MODULE = "tests.settings"; + + nativeCheckInputs = [ + pytest-django + pytest-mock + pytestCheckHook + ]; + + meta = with lib; { + changelog = "https://github.com/Amertz08/drf_ujson2/releases/tag/v${version}"; + description = "JSON parser and renderer using ujson for Django Rest Framework"; + homepage = "https://github.com/Amertz08/drf_ujson2"; + maintainers = with maintainers; [ hexa ]; + }; +} diff --git a/pkgs/development/python-modules/paypal-checkout-serversdk/default.nix b/pkgs/development/python-modules/paypal-checkout-serversdk/default.nix new file mode 100644 index 000000000000..711056008c9b --- /dev/null +++ b/pkgs/development/python-modules/paypal-checkout-serversdk/default.nix @@ -0,0 +1,52 @@ +{ lib +, buildPythonPackage +, fetchFromGitHub + +# propagates +, paypalhttp + +# tersts +, pytestCheckHook +, responses +}: + +buildPythonPackage rec { + pname = "paypal-checkout-serversdk"; + version = "1.0.1"; + format = "setuptools"; + + src = fetchFromGitHub { + owner = "paypal"; + repo = "Checkout-Python-SDK"; + rev = "refs/tags/${version}"; + hash = "sha256-04ojNJeqVMdhnGpeCD+wzgKGLI22tVvrMW3gF/SH7KU="; + }; + + postPatch = '' + # outdated python2 samples + rm -rf sample + ''; + + propagatedBuildInputs = [ + paypalhttp + ]; + + nativeCheckInputs = [ + pytestCheckHook + responses + ]; + + disabledTests = [ + # network tests + "testOrdersPatchTest" + "testOrdersCreateTest" + "testOrderGetRequestTest" + ]; + + meta = with lib; { + changelog = "https://github.com/paypal/Checkout-Python-SDK/releases/tag/${version}"; + description = "Python SDK for Checkout RESTful APIs"; + license = licenses.asl20; + maintainers = with maintainers; [ hexa ]; + }; +} diff --git a/pkgs/development/python-modules/paypalhttp/default.nix b/pkgs/development/python-modules/paypalhttp/default.nix new file mode 100644 index 000000000000..25c6aa1ba878 --- /dev/null +++ b/pkgs/development/python-modules/paypalhttp/default.nix @@ -0,0 +1,45 @@ +{ lib +, buildPythonPackage +, fetchFromGitHub + +# propagates +, pyopenssl +, requests +, six + +# tests +, pytestCheckHook +, responses +}: + +buildPythonPackage rec { + pname = "paypalhttp"; + version = "1.0.0"; + format = "setuptools"; + + src = fetchFromGitHub { + owner = "paypal"; + repo = "paypalhttp_python"; + rev = "refs/tags/${version}"; + hash = "sha256-3ihcpYtpcejPkiyf4g4jveyNU6flQB2sv9EZ5Pd7tUc="; + }; + + propagatedBuildInputs = [ + requests + six + pyopenssl + ]; + + nativeCheckInputs = [ + pytestCheckHook + responses + ]; + + meta = with lib; { + changelog = "https://github.com/paypal/paypalhttp_python/releases/tag/${version}"; + description = "PayPalHttp is a generic HTTP Client"; + homepage = "https://github.com/paypal/paypalhttp_python"; + license = licenses.mit; + maintainers = with maintainers; [ hexa ]; + }; +} diff --git a/pkgs/development/python-modules/python-u2flib-server/cryptography-37-compat.patch b/pkgs/development/python-modules/python-u2flib-server/cryptography-37-compat.patch new file mode 100644 index 000000000000..beed33ab2a35 --- /dev/null +++ b/pkgs/development/python-modules/python-u2flib-server/cryptography-37-compat.patch @@ -0,0 +1,112 @@ +diff --git a/test/soft_u2f_v2.py b/test/soft_u2f_v2.py +index d011b1f..9a24bb9 100644 +--- a/test/soft_u2f_v2.py ++++ b/test/soft_u2f_v2.py +@@ -112,9 +112,7 @@ class SoftU2FDevice(object): + CERT_PRIV, password=None, backend=default_backend()) + cert = CERT + data = b'\x00' + app_param + client_param + key_handle + pub_key +- signer = cert_priv.signer(ec.ECDSA(hashes.SHA256())) +- signer.update(data) +- signature = signer.finalize() ++ signature = cert_priv.sign(data, ec.ECDSA(hashes.SHA256())) + + raw_response = (b'\x05' + pub_key + six.int2byte(len(key_handle)) + + key_handle + cert + signature) +@@ -163,9 +161,7 @@ class SoftU2FDevice(object): + counter = struct.pack('>I', self.counter) + + data = app_param + touch + counter + client_param +- signer = priv_key.signer(ec.ECDSA(hashes.SHA256())) +- signer.update(data) +- signature = signer.finalize() ++ signature = priv_key.sign(data, ec.ECDSA(hashes.SHA256())) + raw_response = touch + counter + signature + + return SignResponse( +diff --git a/u2flib_server/attestation/resolvers.py b/u2flib_server/attestation/resolvers.py +index 034549f..cd59b10 100644 +--- a/u2flib_server/attestation/resolvers.py ++++ b/u2flib_server/attestation/resolvers.py +@@ -86,27 +86,29 @@ class MetadataResolver(object): + cert_bytes = cert.tbs_certificate_bytes + + if isinstance(pubkey, rsa.RSAPublicKey): +- verifier = pubkey.verifier( +- cert_signature, +- padding.PKCS1v15(), +- cert.signature_hash_algorithm +- ) ++ try: ++ pubkey.verify( ++ cert_signature, ++ cert_bytes, ++ padding.PKCS1v15(), ++ cert.signature_hash_algorithm ++ ) ++ return True ++ except InvalidSignature: ++ return False + elif isinstance(pubkey, ec.EllipticCurvePublicKey): +- verifier = pubkey.verifier( +- cert_signature, +- ec.ECDSA(cert.signature_hash_algorithm) +- ) ++ try: ++ pubkey.verify( ++ cert_signature, ++ cert_bytes, ++ ec.ECDSA(cert.signature_hash_algorithm) ++ ) ++ return True ++ except InvalidSignature: ++ return False + else: + raise ValueError("Unsupported public key value") + +- verifier.update(cert_bytes) +- +- try: +- verifier.verify() +- return True +- except InvalidSignature: +- return False +- + def resolve(self, cert): + if isinstance(cert, bytes): + cert = x509.load_der_x509_certificate(cert, default_backend()) +diff --git a/u2flib_server/model.py b/u2flib_server/model.py +index 481be51..6ec01bb 100644 +--- a/u2flib_server/model.py ++++ b/u2flib_server/model.py +@@ -175,12 +175,9 @@ class RegistrationData(object): + cert = x509.load_der_x509_certificate(self.certificate, + default_backend()) + pubkey = cert.public_key() +- verifier = pubkey.verifier(self.signature, ec.ECDSA(hashes.SHA256())) +- +- verifier.update(b'\0' + app_param + chal_param + self.key_handle + +- self.pub_key) ++ msg = (b'\0' + app_param + chal_param + self.key_handle + self.pub_key) + try: +- verifier.verify() ++ pubkey.verify(self.signature, msg, ec.ECDSA(hashes.SHA256())) + except InvalidSignature: + raise ValueError('Attestation signature is invalid') + +@@ -207,13 +204,9 @@ class SignatureData(object): + def verify(self, app_param, chal_param, der_pubkey): + pubkey = load_der_public_key(PUB_KEY_DER_PREFIX + der_pubkey, + default_backend()) +- verifier = pubkey.verifier(self.signature, ec.ECDSA(hashes.SHA256())) +- verifier.update(app_param + +- six.int2byte(self.user_presence) + +- struct.pack('>I', self.counter) + +- chal_param) ++ msg = app_param + six.int2byte(self.user_presence) + struct.pack('>I', self.counter) + chal_param + try: +- verifier.verify() ++ pubkey.verify(self.signature, msg, ec.ECDSA(hashes.SHA256())) + except InvalidSignature: + raise ValueError('U2F signature is invalid') + diff --git a/pkgs/development/python-modules/python-u2flib-server/default.nix b/pkgs/development/python-modules/python-u2flib-server/default.nix new file mode 100644 index 000000000000..08a62d41363a --- /dev/null +++ b/pkgs/development/python-modules/python-u2flib-server/default.nix @@ -0,0 +1,60 @@ +{ lib +, buildPythonPackage +, fetchFromGitHub +, fetchpatch + +# propagates +, cryptography +, six + +# optional +, webob + +# tests +, pytestCheckHook +}: + +buildPythonPackage rec { + pname = "python-u2flib-server"; + version = "5.0.1"; + format = "setuptools"; + + src = fetchFromGitHub { + owner = "Yubico"; + repo = "python-u2flib-server"; + rev = version; + hash = "sha256-ginP9u+aHcdaWpwcFYJWu0Ghf7+nDZq9i3TVAacIPhg="; + }; + + patches = [ + ./cryptography-37-compat.patch + ]; + + propagatedBuildInputs = [ + cryptography + six + ]; + + passthru.optional-dependencies = { + u2f_server = [ + webob + ]; + }; + + pythonImportsCheck = [ + "u2flib_server" + "u2flib_server.u2f" + ]; + + nativeCheckInputs = [ + pytestCheckHook + ] ++ passthru.optional-dependencies.u2f_server; + + meta = with lib; { + description = "Python based U2F server library"; + homepage = "https://github.com/Yubico/python-u2flib-server"; + changelog = "https://github.com/Yubico/python-u2flib-server/blob/${src.rev}/NEWS"; + license = licenses.bsd2; + maintainers = with maintainers; [ hexa ]; + }; +} diff --git a/pkgs/development/python-modules/pyuca/default.nix b/pkgs/development/python-modules/pyuca/default.nix new file mode 100644 index 000000000000..94b29dc80f9b --- /dev/null +++ b/pkgs/development/python-modules/pyuca/default.nix @@ -0,0 +1,33 @@ +{ lib +, buildPythonPackage +, fetchFromGitHub +, unittestCheckHook +}: + +buildPythonPackage rec { + pname = "pyuca"; + version = "1.2"; + format = "setuptools"; + + src = fetchFromGitHub { + owner = "jtauber"; + repo = "pyuca"; + rev = "v${version}"; + hash = "sha256-KIWk+/o1MX5J9cO7xITvjHrYg0NdgdTetOzfGVwAI/4="; + }; + + pythonImportsCheck = [ + "pyuca" + ]; + + nativeCheckInputs = [ + unittestCheckHook + ]; + + meta = with lib; { + description = "A Python implementation of the Unicode Collation Algorithm"; + homepage = "https://github.com/jtauber/pyuca"; + license = licenses.mit; + maintainers = with maintainers; [ hexa ]; + }; +} diff --git a/pkgs/development/python-modules/slimit/default.nix b/pkgs/development/python-modules/slimit/default.nix new file mode 100644 index 000000000000..1166db2639c4 --- /dev/null +++ b/pkgs/development/python-modules/slimit/default.nix @@ -0,0 +1,39 @@ +{ lib +, buildPythonPackage +, fetchFromGitHub +, ply +, pytestCheckHook +}: + +buildPythonPackage rec { + pname = "slimit"; + version = "unstable-2018-08-08"; + format = "setuptools"; + + src = fetchFromGitHub { + owner = "rspivak"; + repo = "slimit"; + rev = "3533eba9ad5b39f3a015ae6269670022ab310847"; + hash = "sha256-J+8RGENM/+eaTNvoC54XXPP+aWmazlssjnZAY88J/F0="; + }; + + propagatedBuildInputs = [ + ply + ]; + + pythonImportsCheck = [ + "slimit" + ]; + + nativeCheckInputs = [ + pytestCheckHook + ]; + + meta = with lib; { + description = "SlimIt - a JavaScript minifier/parser in Python"; + homepage = "https://github.com/rspivak/slimit"; + changelog = "https://github.com/rspivak/slimit/blob/${src.rev}/CHANGES"; + license = licenses.mit; + maintainers = with maintainers; [ hexa ]; + }; +} diff --git a/pkgs/development/python-modules/static3/default.nix b/pkgs/development/python-modules/static3/default.nix new file mode 100644 index 000000000000..9156ea6d6089 --- /dev/null +++ b/pkgs/development/python-modules/static3/default.nix @@ -0,0 +1,55 @@ +{ lib +, buildPythonPackage +, fetchFromGitHub + +# optionals +, genshi + +# tests +, pytestCheckHook +, webtest +}: + +buildPythonPackage rec { + pname = "static3"; + version = "0.7.0"; + format = "setuptools"; + + src = fetchFromGitHub { + owner = "rmohr"; + repo = "static3"; + rev = "v${version}"; + hash = "sha256-uFgv+57/UZs4KoOdkFxbvTEDQrJbb0iYJ5JoWWN4yFY="; + }; + + postPatch = '' + substituteInPlace setup.py \ + --replace ", 'pytest-cov'" "" + ''; + + passthru.optional-dependencies = { + KidMagic = [ + # TODO: kid + ]; + Genshimagic = [ + genshi + ]; + }; + + pythonImportsCheck = [ + "static" + ]; + + nativeCheckInputs = [ + pytestCheckHook + webtest + ] ++ lib.flatten (builtins.attrValues passthru.optional-dependencies); + + meta = with lib; { + changelog = "https://github.com/rmohr/static3/releases/tag/v${version}"; + description = "A really simple WSGI way to serve static (or mixed) content"; + homepage = "https://github.com/rmohr/static3"; + license = licenses.lgpl21Only; + maintainers = with maintainers; [ hexa ]; + }; +} diff --git a/pkgs/development/python-modules/vat-moss/default.nix b/pkgs/development/python-modules/vat-moss/default.nix new file mode 100644 index 000000000000..1bf0879d3427 --- /dev/null +++ b/pkgs/development/python-modules/vat-moss/default.nix @@ -0,0 +1,52 @@ +{ lib +, buildPythonPackage +, fetchFromGitHub +, fetchpatch +, pytestCheckHook +}: + +buildPythonPackage rec { + pname = "vat-moss"; + version = "0.11.0"; + format = "setuptools"; + + src = fetchFromGitHub { + owner = "raphaelm"; + repo = "vat_moss-python"; + rev = version; + hash = "sha256-c0lcyeW8IUhWKcfn3BmsbNmHyAzm8T0sdYp0Zp0FbFw="; + }; + + patches = [ + (fetchpatch { + # Update API URL to HTTPS + url = "https://github.com/raphaelm/vat_moss-python/commit/ed32b7d893da101332d3bb202d17b1bf89e5d9ed.patch"; + hash = "sha256-GpxaQ6/1LdFdxzXT/p4HS7FHU0WeM0i3LbdRFeqnFdw="; + }) + ]; + + pythonImportsCheck = [ + "vat_moss" + ]; + + nativeCheckInputs = [ + pytestCheckHook + ]; + + disabledTests = [ + "test_fetch" + ]; + + disabledTestPaths = [ + # network access + "tests/test_id.py" + ]; + + meta = with lib; { + description = "A Python library for dealing with VAT MOSS and Norway VAT on digital services. Includes VAT ID validation, rate calculation based on place of supply, exchange rate and currency tools for invoices"; + homepage = "https://github.com/raphaelm/vat_moss-python"; + changelog = "https://github.com/raphaelm/vat_moss-python/blob/${src.rev}/changelog.md"; + license = licenses.mit; + maintainers = with maintainers; [ hexa ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index ff799a3bc250..e80f400c781c 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -2408,6 +2408,8 @@ self: super: with self; { deform = callPackage ../development/python-modules/deform { }; + defusedcsv = callPackage ../development/python-modules/defusedcsv { }; + defusedxml = callPackage ../development/python-modules/defusedxml { }; deid = callPackage ../development/python-modules/deid { }; @@ -2669,6 +2671,8 @@ self: super: with self; { django_hijack = callPackage ../development/python-modules/django-hijack { }; # This package may need an older version of Django. Override the package set and set e.g. `django = super.django_1_9`. See the Nixpkgs manual for examples on how to override the package set. + django-i18nfield = callPackage ../development/python-modules/django-i18nfield { }; + django-import-export = callPackage ../development/python-modules/django-import-export { }; django-ipware = callPackage ../development/python-modules/django-ipware { }; @@ -2699,6 +2703,8 @@ self: super: with self; { django-mptt = callPackage ../development/python-modules/django-mptt { }; + django-mysql = callPackage ../development/python-modules/django-mysql { }; + django_nose = callPackage ../development/python-modules/django_nose { }; django-oauth-toolkit = callPackage ../development/python-modules/django-oauth-toolkit { }; @@ -2945,6 +2951,8 @@ self: super: with self; { drf-spectacular-sidecar = callPackage ../development/python-modules/drf-spectacular-sidecar { }; + drf-ujson2 = callPackage ../development/python-modules/drf-ujson2 { }; + drf-writable-nested = callPackage ../development/python-modules/drf-writable-nested { }; drf-yasg = callPackage ../development/python-modules/drf-yasg { }; @@ -7228,6 +7236,10 @@ self: super: with self; { paver = callPackage ../development/python-modules/paver { }; + paypal-checkout-serversdk = callPackage ../development/python-modules/paypal-checkout-serversdk { }; + + paypalhttp = callPackage ../development/python-modules/paypalhttp { }; + paypalrestsdk = callPackage ../development/python-modules/paypalrestsdk { }; pbkdf2 = callPackage ../development/python-modules/pbkdf2 { }; @@ -7653,6 +7665,8 @@ self: super: with self; { pytomorrowio = callPackage ../development/python-modules/pytomorrowio { }; + pyuca = callPackage ../development/python-modules/pyuca { }; + pyutil = callPackage ../development/python-modules/pyutil { }; pyzbar = callPackage ../development/python-modules/pyzbar { }; @@ -9825,6 +9839,8 @@ self: super: with self; { python-u2flib-host = callPackage ../development/python-modules/python-u2flib-host { }; + python-u2flib-server = callPackage ../development/python-modules/python-u2flib-server { }; + python-uinput = callPackage ../development/python-modules/python-uinput { }; python-unshare = callPackage ../development/python-modules/python-unshare { }; @@ -11045,6 +11061,8 @@ self: super: with self; { slither-analyzer = callPackage ../development/python-modules/slither-analyzer { }; + slimit = callPackage ../development/python-modules/slimit { }; + slixmpp = callPackage ../development/python-modules/slixmpp { inherit (pkgs) gnupg; }; @@ -11467,6 +11485,8 @@ self: super: with self; { stashy = callPackage ../development/python-modules/stashy { }; + static3 = callPackage ../development/python-modules/static3 { }; + staticjinja = callPackage ../development/python-modules/staticjinja { }; statistics = callPackage ../development/python-modules/statistics { }; @@ -12524,6 +12544,8 @@ self: super: with self; { varint = callPackage ../development/python-modules/varint { }; + vat-moss = callPackage ../development/python-modules/vat-moss { }; + vcrpy = callPackage ../development/python-modules/vcrpy { }; vcver = callPackage ../development/python-modules/vcver { };