diff --git a/src/main/java/com/google/devtools/build/lib/runtime/SafeRequestLogging.java b/src/main/java/com/google/devtools/build/lib/runtime/SafeRequestLogging.java index 0b75d5f0a1a8fb..3d8adb07c5f16a 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/SafeRequestLogging.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/SafeRequestLogging.java @@ -21,14 +21,15 @@ /** Utils for logging safely user commandlines. */ public class SafeRequestLogging { private static final Pattern suppressFromLog = - Pattern.compile("--client_env=([^=]*(?:auth|pass|cookie)[^=]*)=", Pattern.CASE_INSENSITIVE); + Pattern.compile( + "--client_env=([^=]*(?:auth|pass|cookie|token)[^=]*)=", Pattern.CASE_INSENSITIVE); private SafeRequestLogging() {} /** * Generates a string form of a request to be written to the logs, filtering the user environment * to remove anything that looks private. The current filter criteria removes any variable whose - * name includes "auth", "pass", or "cookie". + * name includes "auth", "pass", "cookie" or "token". * * @return the filtered request to write to the log. */ diff --git a/src/test/java/com/google/devtools/build/lib/runtime/SafeRequestLoggingTest.java b/src/test/java/com/google/devtools/build/lib/runtime/SafeRequestLoggingTest.java index d9334ebd6f0608..5838ef0c46cb61 100644 --- a/src/test/java/com/google/devtools/build/lib/runtime/SafeRequestLoggingTest.java +++ b/src/test/java/com/google/devtools/build/lib/runtime/SafeRequestLoggingTest.java @@ -69,6 +69,16 @@ public void testGetRequestLogStringStripsApparentPasswordValues() { "[--client_env=dont_paSS_ME=__private_value_removed__, --client_env=other=isprinted]"); } + @Test + public void testGetRequestLogStringStripsApparentTokenValues() { + assertThat( + SafeRequestLogging.getRequestLogString( + ImmutableList.of( + "--client_env=service_ToKEn=notprinted", "--client_env=other=isprinted"))) + .isEqualTo( + "[--client_env=service_ToKEn=__private_value_removed__, --client_env=other=isprinted]"); + } + @Test public void testGetRequestLogIgnoresSensitiveTermsInValues() { assertThat(SafeRequestLogging.getRequestLogString(ImmutableList.of("--client_env=ok=COOKIE")))