diff options
author | Steve Fung <stevefung@google.com> | 2015-10-27 22:18:59 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2015-10-27 22:18:59 +0000 |
commit | f7416174ca64d43e2b272c46320cb7e117b4d8b4 (patch) | |
tree | 2434851cb2c963f5f34984ca647f629bbb886133 /crash_reporter | |
parent | ef3c85a027fa0c68e247fdc7853325ff5da325d5 (diff) | |
parent | 270f508b504ad4261fb4f034acf50825119b8234 (diff) | |
download | core-f7416174ca64d43e2b272c46320cb7e117b4d8b4.tar.gz core-f7416174ca64d43e2b272c46320cb7e117b4d8b4.tar.bz2 core-f7416174ca64d43e2b272c46320cb7e117b4d8b4.zip |
Merge "crash_reporter: Make report log more useful"
Diffstat (limited to 'crash_reporter')
-rwxr-xr-x | crash_reporter/crash_sender | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/crash_reporter/crash_sender b/crash_reporter/crash_sender index b24465d80..95204a47b 100755 --- a/crash_reporter/crash_sender +++ b/crash_reporter/crash_sender @@ -98,6 +98,10 @@ lecho() { log -t "${TAG}" "$@" } +lwarn() { + lecho -psyslog.warn "$@" +} + # Returns true if mock is enabled. is_mock() { [ -f "${MOCK_CRASH_SENDING}" ] && return 0 @@ -294,6 +298,11 @@ get_hardware_class() { fi } +# Return the log string filtered with only JSON-safe white-listed characters. +filter_log_string() { + echo "$1" | tr -cd '[:alnum:]_.\-:;' +} + send_crash() { local meta_path="$1" local report_payload="$(get_key_value "${meta_path}" "payload")" @@ -434,8 +443,7 @@ send_crash() { ret=$? if [ ${ret} -ne 0 ]; then proxy='' - lecho -psyslog.warn \ - "Listing proxies failed with exit code ${ret}" + lwarn "Listing proxies failed with exit code ${ret}" else proxy=$(echo "${proxy}" | head -1) fi @@ -466,22 +474,17 @@ send_crash() { if [ ${curl_result} -eq 0 ]; then local id="$(cat "${report_id}")" - local product_name local timestamp="$(date +%s)" - case ${product} in - Chrome_ChromeOS) - if is_official_image; then - product_name="Chrome" - else - product_name="Chromium" - fi - ;; - *) - product_name="Brillo" - ;; - esac - printf '%s,%s,%s\n' \ - "${timestamp}" "${id}" "${product_name}" >> "${CRASH_LOG}" + local filter_prod="$(filter_log_string "${product}")" + local filter_exec="$(filter_log_string "${exec_name}")" + if [ "${filter_prod}" != "${product}" ]; then + lwarn "Product name filtered to: ${filter_prod}." + fi + if [ "${filter_exec}" != "${exec_name}" ]; then + lwarn "Exec name filtered to: ${filter_exec}." + fi + printf "{'time':%s,'id':'%s','product':'%s','exec_name':'%s'}\n" \ + "${timestamp}" "${id}" "${filter_prod}" "${filter_exec}" >> "${CRASH_LOG}" lecho "Crash report receipt ID ${id}" else lecho "Crash sending failed with exit code ${curl_result}: " \ |