Skip to content

Commit

Permalink
add encryption checks
Browse files Browse the repository at this point in the history
  • Loading branch information
rjra2611 committed Nov 28, 2023
1 parent d680829 commit 704feb3
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lean/commands/library/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,19 @@ def add(project: Path, name: str, version: Optional[str], no_local: bool) -> Non
library_dir = Path(name).expanduser().resolve()

if library_manager.is_lean_library(library_dir):
# check encryption conditions
if project_config.get('encrypted', False) and project_config.get('encryption-key-path', None):
library_project_config = container.project_config_manager.get_project_config(library_dir)
is_library_encrypted = library_project_config.get('encrypted', False)
library_encryption_key_path = library_project_config.get('encryption-key-path', None)
if library_encryption_key_path:
library_encryption_key_path = Path(library_encryption_key_path)
project_encryption_key_path = project_config.get('encryption-key-path', None)
if project_encryption_key_path:
project_encryption_key_path = Path(project_encryption_key_path)
if is_library_encrypted and library_encryption_key_path != project_encryption_key_path:
raise RuntimeError(f"Library is encrypted with a different key {library_encryption_key_path}. "
f"Please use the same key as project {project_encryption_key_path}.")
logger.info(f"Adding Lean CLI library {library_dir} to project {project}")
if project_language == "CSharp":
library_manager.add_lean_library_to_csharp_project(project, library_dir, no_local)
Expand Down

0 comments on commit 704feb3

Please sign in to comment.