Skip to content

Add stdin option to restore_secrets for secure passphrase entry. #943

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions scripts/gha/restore_secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
--passphrase: Passphrase to decrypt the files. This option is insecure on a
multi-user machine; use the --passphrase_file option instead.
--passphrase_file: Specify a file to read the passphrase from (only reads the
first line).
first line). Use "-" (without quotes) for stdin.
--repo_dir: Path to C++ SDK Github repository. Defaults to current directory.

This script will perform the following:
Expand All @@ -48,7 +48,8 @@

flags.DEFINE_string("repo_dir", os.getcwd(), "Path to C++ SDK Github repo.")
flags.DEFINE_string("passphrase", None, "The passphrase itself.")
flags.DEFINE_string("passphrase_file", None, "Path to file with passphrase.")
flags.DEFINE_string("passphrase_file", None,
"Path to file with passphrase. Use \"-\" (without quotes) for stdin.")
flags.DEFINE_string("artifact", None, "Artifact Path, google-services.json will be placed here.")


Expand All @@ -60,6 +61,8 @@ def main(argv):
# The passphrase is sensitive, do not log.
if FLAGS.passphrase:
passphrase = FLAGS.passphrase
elif FLAGS.passphrase_file == "-":
passphrase = input()
elif FLAGS.passphrase_file:
with open(FLAGS.passphrase_file, "r") as f:
passphrase = f.readline().strip()
Expand Down