Skip to content

fix(env_manager): Use base64 encoding for robust .env file content wr…#11

Merged
Hordunlarmy merged 1 commit into
mainfrom
dev
Jan 29, 2026
Merged

fix(env_manager): Use base64 encoding for robust .env file content wr…#11
Hordunlarmy merged 1 commit into
mainfrom
dev

Conversation

@Hordunlarmy
Copy link
Copy Markdown
Member

This pull request updates the way environment files are created and written to, improving security and reliability. The main change is switching from direct shell commands to using a base64-encoded approach for writing .env files, which avoids issues with special characters and ensures proper file permissions. The implementation now uses a helper function, run_command, for executing remote commands, and the corresponding unit tests have been updated to mock this new behavior.

Environment file creation improvements:

  • Changed create_env_file in src/env_manager.py to use base64 encoding and tee for writing environment variables to files, preventing shell character and newline mangling issues, and to set secure file permissions (chmod 600). The function now uses run_command for all remote operations instead of calling conn.run directly.
  • Updated imports in src/env_manager.py to include base64 and run_command for the new implementation. [1] [2]

Testing updates:

  • Refactored the test_heredoc_escaping unit test in tests/unit/test_env_manager.py to mock run_command instead of conn.run, and to check for the correct base64-encoded content and usage of tee and base64 -d in the command.…iting

@Hordunlarmy Hordunlarmy merged commit d08f1a4 into main Jan 29, 2026
5 checks passed
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.

1 participant