Keeper-Security / Commander

Keeper Commander is a python-based CLI and SDK interface to the Keeper Security platform. Provides administrative controls, reporting, import/export and vault management.
https://www.keepersecurity.com/commander.html
MIT License
186 stars 74 forks source link

Weird internal dependency error #305

Closed pgelinas closed 3 years ago

pgelinas commented 3 years ago

We have just updated to the latest version on PyPi (4.55) and since then I have the following problem issue when importing the API

root@2067786b050d:/var/code/ansible-playbooks# python Python 3.6.9 (default, Nov 23 2019, 06:49:55) [GCC 8.3.0] on linux Type "help", "copyright", "credits" or "license" for more information.

from keepercommander import api Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python3.6/site-packages/keepercommander/api.py", line 31, in from .loginv3 import LoginV3Flow as loginv3, LoginV3API, CommonHelperMethods File "/usr/local/lib/python3.6/site-packages/keepercommander/loginv3.py", line 23, in from . import cli File "/usr/local/lib/python3.6/site-packages/keepercommander/cli.py", line 28, in from .commands.msp import get_mc_by_name_or_id File "/usr/local/lib/python3.6/site-packages/keepercommander/commands/msp.py", line 23, in from keepercommander.loginv3 import CommonHelperMethods ImportError: cannot import name 'CommonHelperMethods'

I forced the version we use to the last minor version that we had that worked as a workaround. I have tested in both 4.33 and 4.51 and it works on them, but 4.55 is broken.

maksimu commented 3 years ago

I would like to see if I can reproduce it. Is this error happening when you are just running python command (according to the log you pasted).

Also I see that you are using Ansible, would it be possible to share some details what commands are being executed.

pgelinas commented 3 years ago

We are writing a custom Ansible filter plugin to integrate Keeper, I would be surprised if this has an impact since I'm testing this outside of Ansbile. To test, I run the python REPL and try to import keepercommander:

# python
> from keepercommander import api

And it prints the error shown.

All of this was tested inside a Docker container with this Dockerfile:

FROM python:3.6.9-slim-buster

ENV vault_version=0.9.5 \
  VAULT_ADDR=https://foobar/

# unzip and curl are used in the dockerfile
# gettext is for the envsubst command used in our scripts
# git, openssh-client and openssl are required by Ansible
# gcc is required by some python library for setup
RUN apt-get update \
  && apt-get install --no-upgrade -y unzip curl gettext git openssh-client openssl gcc \
  && rm -rf /var/lib/apt

RUN curl -sS "https://releases.hashicorp.com/vault/${vault_version}/vault_${vault_version}_linux_amd64.zip" > "vault_${vault_version}.zip" \
  && unzip -oq "vault_${vault_version}.zip" \
  && mv "vault" "/bin/" \
  && rm "vault_${vault_version}.zip" 

ENV ansible_version=2.9.10

# azure-cli is for azure integration (some ansible tasks are executing Azure commands)
# hvac is for hashicorp vault lookup
# pypsrp, pywinrm and "requests[socks]" are for Windows VM PSRemoting
# boto3 is for AWS integration (S3 download)
# keepercommander is for Keeper SDK.
# CLP-819 Force 4.33 as we know it works and later version seems to have problems
RUN pip install ansible==${ansible_version} azure-cli hvac pypsrp pywinrm "requests[socks]" boto3 keepercommander==4.33

ENV terraform_version=0.13.5

RUN curl -sS "https://releases.hashicorp.com/terraform/${terraform_version}/terraform_${terraform_version}_linux_amd64.zip" > "terraform_${terraform_version}.zip" \
  && unzip -oq "terraform_${terraform_version}.zip" \
  && mv "terraform" "/bin/"

COPY ssh.config.docker /root/.ssh/config

RUN chmod 0600 /root/.ssh/config
maksimu commented 3 years ago

Thanks for the details to reproduce this issue. I was able to get the same result that you got. Working on the fix and it should be out in the next few days along with few other minor fixes.

By the way, releases 4.5x and up use new Login V3 API that will require devices to be approved before accessing retrieving encrypted data from Keeper's server. Feel free to reach out to us to help you with setting up your environment.

pgelinas commented 3 years ago

Thanks for the heads-up. Since this was confirmed working on our side with another version, it will probably be months before I have bandwidth to circle back to this and try out the new Login V3 API, but I'll keep a note.

maksimu commented 3 years ago

I'll be happy to help you out with the testing and configuration. If you could give me some ideas on what exactly you are doing I can run tests and make necessary changes if needed. Is it possible to share code of your custom Ansible filter plugin to integrate Keeper (at least the part that talk to Keeper). You can send it to my email mustinov[AT]keepersecurity.com

maksimu commented 3 years ago

@pgelinas we have released new version which should resolve this issue.

maksimu commented 3 years ago

Fix was released. Feel free to reopen or create a new issue if the solution didn't work for you.