Skip to content

Commit fd6c5c6

Browse files
authored
Add stdin option to restore_secrets for secure passphrase usage on runner. (#943)
This allows us to avoid passing in a passphrase on the command line, which can be insecure on a shared machine.
1 parent 0644119 commit fd6c5c6

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

scripts/gha/restore_secrets.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
--passphrase: Passphrase to decrypt the files. This option is insecure on a
2323
multi-user machine; use the --passphrase_file option instead.
2424
--passphrase_file: Specify a file to read the passphrase from (only reads the
25-
first line).
25+
first line). Use "-" (without quotes) for stdin.
2626
--repo_dir: Path to C++ SDK Github repository. Defaults to current directory.
2727
2828
This script will perform the following:
@@ -48,7 +48,8 @@
4848

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

5455

@@ -60,6 +61,8 @@ def main(argv):
6061
# The passphrase is sensitive, do not log.
6162
if FLAGS.passphrase:
6263
passphrase = FLAGS.passphrase
64+
elif FLAGS.passphrase_file == "-":
65+
passphrase = input()
6366
elif FLAGS.passphrase_file:
6467
with open(FLAGS.passphrase_file, "r") as f:
6568
passphrase = f.readline().strip()

0 commit comments

Comments
 (0)