(master: str, token: Optional[str])
| 840 | |
| 841 | |
| 842 | def vault_decrypt(master: str, token: Optional[str]) -> str: |
| 843 | if not token: |
| 844 | return "" |
| 845 | env = os.environ.copy() |
| 846 | env["FS_PASS"] = master |
| 847 | res = subprocess.run( |
| 848 | ["openssl", "enc", "-d", "-aes-256-cbc", "-pbkdf2", "-a", "-A", "-pass", "env:FS_PASS"], |
| 849 | input=token.encode("utf-8"), capture_output=True, env=env, check=False |
| 850 | ) |
| 851 | if res.returncode != 0: |
| 852 | raise RuntimeError(res.stderr.decode("utf-8", "ignore") or "Decryption failed") |
| 853 | return res.stdout.decode("utf-8", "ignore") |
| 854 | |
| 855 | |
| 856 | def vault_master() -> Optional[str]: |
no test coverage detected