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

Restrict version of transitive dependency pyasn1 #5527

Closed
wants to merge 2 commits into from

Conversation

szemek
Copy link
Contributor

@szemek szemek commented Aug 13, 2022

Description

Changes:

  • restricted version of pyasn1 to fix ImportError: cannot import name 'tagMap' from 'pyasn1.codec.ber.encoder'

Recent version of pyasn1 (0.5.0rc1 PRE-RELEASE) (depedency of ldap3) causes following issues:

 ➜ mitmdump --version
Traceback (most recent call last):
  File "/Users/szemek//mitmproxy/.venv/bin/mitmdump", line 33, in <module>
    sys.exit(load_entry_point('mitmproxy==9.0.0.dev0', 'console_scripts', 'mitmdump')())
  File "/Users/szemek//mitmproxy/.venv/lib/python3.10/site-packages/mitmproxy-9.0.0.dev0-py3.10.egg/mitmproxy/tools/main.py", line 126, in mitmdump
    from mitmproxy.tools import dump
  File "/Users/szemek//mitmproxy/.venv/lib/python3.10/site-packages/mitmproxy-9.0.0.dev0-py3.10.egg/mitmproxy/tools/dump.py", line 1, in <module>
    from mitmproxy import addons
  File "/Users/szemek//mitmproxy/.venv/lib/python3.10/site-packages/mitmproxy-9.0.0.dev0-py3.10.egg/mitmproxy/addons/__init__.py", line 17, in <module>
    from mitmproxy.addons import proxyauth
  File "/Users/szemek//mitmproxy/.venv/lib/python3.10/site-packages/mitmproxy-9.0.0.dev0-py3.10.egg/mitmproxy/addons/proxyauth.py", line 9, in <module>
    import ldap3
  File "/Users/szemek//mitmproxy/.venv/lib/python3.10/site-packages/ldap3-2.9.1-py3.10.egg/ldap3/__init__.py", line 141, in <module>
    from .core.connection import Connection
  File "/Users/szemek//mitmproxy/.venv/lib/python3.10/site-packages/ldap3-2.9.1-py3.10.egg/ldap3/core/connection.py", line 38, in <module>
    from ..extend import ExtendedOperationsRoot
  File "/Users/szemek//mitmproxy/.venv/lib/python3.10/site-packages/ldap3-2.9.1-py3.10.egg/ldap3/extend/__init__.py", line 29, in <module>
    from .microsoft.dirSync import DirSync
  File "/Users/szemek//mitmproxy/.venv/lib/python3.10/site-packages/ldap3-2.9.1-py3.10.egg/ldap3/extend/microsoft/dirSync.py", line 27, in <module>
    from ...protocol.microsoft import dir_sync_control, extended_dn_control, show_deleted_control
  File "/Users/szemek//mitmproxy/.venv/lib/python3.10/site-packages/ldap3-2.9.1-py3.10.egg/ldap3/protocol/microsoft.py", line 32, in <module>
    from .controls import build_control
  File "/Users/szemek//mitmproxy/.venv/lib/python3.10/site-packages/ldap3-2.9.1-py3.10.egg/ldap3/protocol/controls.py", line 27, in <module>
    from ..utils.asn1 import encode
  File "/Users/szemek//mitmproxy/.venv/lib/python3.10/site-packages/ldap3-2.9.1-py3.10.egg/ldap3/utils/asn1.py", line 50, in <module>
    from pyasn1.codec.ber.encoder import tagMap, typeMap, AbstractItemEncoder
ImportError: cannot import name 'tagMap' from 'pyasn1.codec.ber.encoder' (/Users/szemek//mitmproxy/.venv/lib/python3.10/site-packages/pyasn1-0.5.0rc1-py3.10.egg/pyasn1/codec/ber/encoder.py)

After restricting version pyasn1>=0.4.6,<0.5.0 I can successfully run:

➜ mitmdump --version
Mitmproxy: 9.0.0.dev (+58, commit 51684e1)
Python:    3.10.1
OpenSSL:   OpenSSL 3.0.5 5 Jul 2022
Platform:  macOS-12.3-x86_64-i386-64bit

I set pyasn1>=0.4.6,<0.5.0 after checking
https://github.com/cannatag/ldap3/blob/v2.8/requirements.txt
https://github.com/cannatag/ldap3/blob/v2.9.1/requirements.txt

ldap3 has a fix for this issue, but no new version has been released since Jul 18, 2021
https://github.com/cannatag/ldap3/pull/983/files

Checklist

  • I have updated tests where applicable.
  • I have added an entry to the CHANGELOG.

@mhils
Copy link
Member

mhils commented Aug 16, 2022

Thanks for the PR! Ideally we'd like that to be handled upstream in ldap3, I've filed cannatag/ldap3#1046.

@tiran: Do you have an ETA for pyasn1 0.5.0? We'd probably ship a patch release if ldap3 doesn't move and pip install mitmproxy breaks.

@tiran
Copy link

tiran commented Aug 16, 2022

@mhils I'd like to get some feedback on 0.5.0rc1. Can you run your tests with pip install --pre, please?

@tiran
Copy link

tiran commented Aug 16, 2022

Ah, now I see that you already did. Could you please report the issue at https://github.com/pyasn1/pyasn1 ? I'll look into the regression.

@mhils
Copy link
Member

mhils commented Aug 16, 2022

Done. Thank you and @droideck for taking over maintenance of pyasn1! 🍰 ❤️

@tiran
Copy link

tiran commented Aug 16, 2022

Could you please test the fix? I'll do another rc after you have confirmed that the fix is working for you.

@mhils
Copy link
Member

mhils commented Aug 16, 2022

Thanks. :) Next one:

    import ldap3
  File "/home/user/venv/lib/python3.10/site-packages/ldap3/__init__.py", line 141, in <module>
    from .core.connection import Connection
  File "/home/user/venv/lib/python3.10/site-packages/ldap3/core/connection.py", line 38, in <module>
    from ..extend import ExtendedOperationsRoot
  File "/home/user/venv/lib/python3.10/site-packages/ldap3/extend/__init__.py", line 29, in <module>
    from .microsoft.dirSync import DirSync
  File "/home/user/venv/lib/python3.10/site-packages/ldap3/extend/microsoft/dirSync.py", line 27, in <module>
    from ...protocol.microsoft import dir_sync_control, extended_dn_control, show_deleted_control
  File "/home/user/venv/lib/python3.10/site-packages/ldap3/protocol/microsoft.py", line 32, in <module>
    from .controls import build_control
  File "/home/user/venv/lib/python3.10/site-packages/ldap3/protocol/controls.py", line 27, in <module>
    from ..utils.asn1 import encode
  File "/home/user/venv/lib/python3.10/site-packages/ldap3/utils/asn1.py", line 80, in <module>
    encode = Encoder(customTagMap, customTypeMap)
TypeError: Encoder.__init__() takes 1 positional argument but 3 were given

https://github.com/cannatag/ldap3/blob/3a2f89663c73d862b8ba7ca9e974012952ed3024/ldap3/utils/asn1.py#L80

pyasn1/pyasn1@8393983#diff-44ba4d6c194902a9eab1816c099062f83c043c4aee9f9fb1117a0fd2737d69ebL851-R856

@tiran
Copy link

tiran commented Aug 16, 2022

Meh :( Ticket please?

@mhils
Copy link
Member

mhils commented Aug 16, 2022

pyasn1/pyasn1#12 :)

@tiran
Copy link

tiran commented Aug 16, 2022

I would appreciate another pair of eyes on pyasn1/pyasn1#13 . It solves the ldap3 issue. But I'm not entirely sure that is covers all problems.

@mhils
Copy link
Member

mhils commented Aug 23, 2022

@szemek: Could you verify that 0.5.0rc2 fixes this issue for you? 😃

@szemek
Copy link
Contributor Author

szemek commented Aug 23, 2022

@szemek: Could you verify that 0.5.0rc2 fixes this issue for you? 😃

@mhils I checked pyasn1 0.5.0rc2 and it works fine without errors, so I'm closing this pull request as it is no longer relevant.

@szemek szemek closed this Aug 23, 2022
@szemek szemek deleted the pyasn1-version branch August 23, 2022 08:34
@mhils
Copy link
Member

mhils commented Aug 23, 2022

Thank you again for flagging this initially! 🍰

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.

None yet

3 participants