cloud pull --encrypt leaves the project without its key path and encrypts referenced libraries
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 25/100
Research direction
Start with PullManager._pull_project and pull_projects, then compare the encryption-key handling with encrypt.py and decrypt.py; the issue also points to push_manager.py for how associated libraries are handled. Check the relevant tests for pull encryption behavior. Done means encrypt and decrypt keep the project config consistent, and pulled libraries are not encrypted; a linked pull request is already open.
Written by the indexing model from the issue text.
Description
Expected Behavior
lean cloud pull --encrypt --key <key> leaves the local project in the same state as lean encrypt --key <key>: files encrypted, encrypted: true and encryption-key-path in the project config, so a later lean cloud push keeps the cloud project encrypted. --decrypt removes encryption-key-path, like lean decrypt. Referenced libraries are pulled as they are in the cloud, the same way lean cloud push --encrypt already leaves them unencrypted.
Actual Behavior
PullManager._pull_projectsetsencryptedbut never sets or removesencryption-key-path.PushManager._push_projectonly re-encrypts when that path is present, so a plain push afterpull --encryptuploads the encrypted file contents as source code withencryption_key='':
$ lean cloud pull --project "Python Project" --encrypt --key key.txt # cloud project was not encrypted
$ lean cloud push --project "Python Project"
# projects/update is called with main.py = 'iFdKTV...==' (ciphertext) and encryption_key = ''
The cloud project ends up unencrypted, with ciphertext as its code. After pull --decrypt, the stale encryption-key-path stays in the config.
PullManager.pull_projectspasses the encryption action and key to every pulled project, including the libraries it adds.pull --project P --encrypttherefore encrypts the shared libraryLibrary/Lon disk and marks itencrypted: true. The push side deliberately skips associated libraries (push_manager.py, "we don't encrypt those"), so the two commands disagree.
Potential Solution
In _pull_project, set encryption-key-path on encrypt and delete it on decrypt, as encrypt.py/decrypt.py do. In pull_projects, apply the encryption action only to the projects that were asked for, not to the libraries added afterwards. I have a PR ready with the fix and tests (fail on master, pass with the fix).
Reproducing the Problem
Run the two commands above on an unencrypted cloud project with a registered key. For the library case, use a project that references a library and check Library/<name>/main.py after the pull.
System Information
lean-cli master at 1873571, Linux.
Checklist
- I have completely filled out this template
- I have confirmed that this issue exists on the current
masterbranch - I have confirmed that this is not a duplicate issue by searching issues
- Dominant language
- Python
- Stars
- 335
- Forks
- 172
- Avg merge
- 6h 54m
- Merged PRs (30d)
- 37
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from QuantConnect/lean-cli
-
priority:P2
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
QuantConnect/lean-cli#792 ·
Maintainers usually reply within 1 day
-
priority:P2
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
QuantConnect/lean-cli#786 ·
Maintainers usually reply within 1 day
-
priority:P2
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
QuantConnect/lean-cli#785 ·
Maintainers usually reply within 1 day
-
A partially written live command result aborts polling with JSONDecodeErrorPossibly taken @pcbeingused333 claimed this 3 days ago. Openpriority:P2
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
QuantConnect/lean-cli#784 ·
Maintainers usually reply within 1 day
-
Container lookup failures during result polling are masked by UnboundLocalErrorPossibly taken @pcbeingused333 claimed this 5 days ago. Openpriority:P2
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
QuantConnect/lean-cli#783 ·
Maintainers usually reply within 1 day
All issues in QuantConnect/lean-cli
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
pimutils/vdirsyncer#1242 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
open-webui/open-webui#35360 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Suggest link: Destiny Verify (MIT zero-dependency pre-commit security, citation & link hygiene CLI)Open
Difficulty 1/5 Under an hour Newbie friendliness 68/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day