| @@ -123,14 +123,15 @@ expect "command without the CRON secret stays HTTP" "$status $(field forged args |
| 123 | | 123 | |
| 124 | if [[ -n "${SCALEWAY_CRON_SECRET:-}" ]]; then | 124 | if [[ -n "${SCALEWAY_CRON_SECRET:-}" ]]; then |
| 125 | # command_body <name> <args JSON>: the arguments a CRON trigger running a command carries. | 125 | # command_body <name> <args JSON>: the arguments a CRON trigger running a command carries. |
| | 126 | + # The secret goes through the environment and stdin, as command lines are visible to other local users. |
| 126 | command_body() { | 127 | command_body() { |
| 127 | - php -r 'echo json_encode(["command" => $argv[1], "args" => json_decode($argv[2]), "secret" => $argv[3]]);' "$1" "$2" "$SCALEWAY_CRON_SECRET" | 128 | + php -r 'echo json_encode(["command" => $argv[1], "args" => json_decode($argv[2]), "secret" => getenv("SCALEWAY_CRON_SECRET")]);' "$1" "$2" |
| 128 | } | 129 | } |
| 129 | - status=$(request command -X POST --data "$(command_body app:greet '{"name":"Scaleway","--yell":true}')" "$base_url/") | 130 | + status=$(command_body app:greet '{"name":"Scaleway","--yell":true}' | request command -X POST --data-binary @- "$base_url/") |
| 130 | expect "Command Invocation status" "$status" 200 | 131 | expect "Command Invocation status" "$status" 200 |
| 131 | expect "Command Invocation output" "$(cat "$tmp/command.body")" "HELLO SCALEWAY!" | 132 | expect "Command Invocation output" "$(cat "$tmp/command.body")" "HELLO SCALEWAY!" |
| 132 | | 133 | |
| 133 | - status=$(request failed -X POST --data "$(command_body app:greet '{"--fail":true}')" "$base_url/") | 134 | + status=$(command_body app:greet '{"--fail":true}' | request failed -X POST --data-binary @- "$base_url/") |
| 134 | expect "failed command status" "$status" 500 | 135 | expect "failed command status" "$status" 500 |
| 135 | expect "failed command output" "$(grep -c 'Failing on purpose.' "$tmp/failed.body")" 1 | 136 | expect "failed command output" "$(grep -c 'Failing on purpose.' "$tmp/failed.body")" 1 |
| 136 | | 137 | |