From 739c06229dc04861d225f19480b8169e965b9727 Mon Sep 17 00:00:00 2001 From: Cheng XU Date: Sat, 13 Jul 2019 23:31:56 +0800 Subject: [PATCH] curl/curl_output: allow redacting secrets in the log Add a new argument `secrets` to specify secret tokens, so we can redact them in the log. --- Library/Homebrew/utils/curl.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Library/Homebrew/utils/curl.rb b/Library/Homebrew/utils/curl.rb index 6bd2333bd3..59be98dd49 100644 --- a/Library/Homebrew/utils/curl.rb +++ b/Library/Homebrew/utils/curl.rb @@ -42,13 +42,14 @@ def curl_args(*extra_args, show_output: false, user_agent: :default) args + extra_args end -def curl(*args) +def curl(*args, secrets: [], **options) # SSL_CERT_FILE can be incorrectly set by users or portable-ruby and screw # with SSL downloads so unset it here. system_command! curl_executable, - args: curl_args(*args), + args: curl_args(*args, **options), print_stdout: true, - env: { "SSL_CERT_FILE" => nil } + env: { "SSL_CERT_FILE" => nil }, + secrets: secrets end def curl_download(*args, to: nil, **options) @@ -77,10 +78,11 @@ def curl_download(*args, to: nil, **options) curl("--location", "--remote-time", "--continue-at", continue_at.to_s, "--output", destination, *args, **options) end -def curl_output(*args, **options) - system_command(curl_executable, +def curl_output(*args, secrets: [], **options) + system_command curl_executable, args: curl_args(*args, show_output: true, **options), - print_stderr: false) + print_stderr: false, + secrets: secrets end def curl_check_http_content(url, user_agents: [:default], check_content: false, strict: false)