#!/usr/bin/env python3 """sec-put probe: stdin = decrypted YAML; adds/replaces NAME with the content of VALUEFILE; stdout = YAML. The value never touches argv, a terminal or a temp file. put.py NAME VALUEFILE""" import sys, json name, path = sys.argv[1], sys.argv[2] value = open(path).read().rstrip("\n") lines = [l for l in sys.stdin.read().splitlines() if not l.startswith(name + ":")] lines.append("%s: %s" % (name, json.dumps(value))) # JSON string is valid YAML print("\n".join(l for l in lines if l.strip() and l.strip() != "{}"))