Skip to content

Instantly share code, notes, and snippets.

@kawaz
Last active April 3, 2025 09:43
Show Gist options
  • Save kawaz/a2d0c5bece913a34d2a6d4a02ca6cc3c to your computer and use it in GitHub Desktop.
Save kawaz/a2d0c5bece913a34d2a6d4a02ca6cc3c to your computer and use it in GitHub Desktop.
1password CLI の op run を、引数でもインジェクション出来るようにするラッパースクリプト。
#!/usr/bin/env bash
# 1Password CLI の op run を、引数でもインジェクション出来るようにするラッパースクリプト。
# https://gist.github.com/kawaz/a2d0c5bece913a34d2a6d4a02ca6cc3c
op_args=()
while (( 0 < $# )); do
a=$1
shift
op_args+=("$a")
[[ $a == -- ]] && break
done
if [[ $# != 0 ]]; then
i=1
prefix="OPRUN$(openssl rand -hex 10)"
script="exec"
for a in "$@"; do
k="$prefix$((i++))"
eval "export $k=$(printf %q "$a")"
script+=" \"\$$k\""
done
op_args+=( bash -c "$script" )
fi
exec op run "${op_args[@]}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment