diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2019-10-03 01:19:35 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2019-10-03 01:19:35 +0000 |
commit | 426fc052949b010ab4016b04e9cbdc816726a2a3 (patch) | |
tree | d19c517da1aad5778eeb53bf1b94ecc6cf66000b | |
parent | 4031fb056942ba55c16515de04028a9f9706bdc0 (diff) | |
parent | 881fa59d09d0015dfed461ceb21addfb41f6f5d2 (diff) | |
download | suite_harness-android10-qpr1-c-release.tar.gz |
Snap for 5915132 from 881fa59d09d0015dfed461ceb21addfb41f6f5d2 to qt-qpr1-releaseandroid-10.0.0_r29android-10.0.0_r28android-10.0.0_r27android-10.0.0_r26android-10.0.0_r25android-10.0.0_r24android-10.0.0_r23android-10.0.0_r22android-10.0.0_r21android-10.0.0_r20android-10.0.0_r19android-10.0.0_r18android-10.0.0_r16android-10.0.0_r15android10-qpr1-releaseandroid10-qpr1-d-releaseandroid10-qpr1-c-s1-releaseandroid10-qpr1-c-releaseandroid10-qpr1-b-s1-releaseandroid10-qpr1-b-release
Change-Id: I8581b4ea6dd790cea103c94ebcf7f7fb98eae8ed
-rw-r--r-- | common/host-side/util/src/com/android/compatibility/common/util/BusinessLogicHostExecutor.java | 2 | ||||
-rw-r--r-- | common/util/src/com/android/compatibility/common/util/BusinessLogicExecutor.java | 21 |
2 files changed, 22 insertions, 1 deletions
diff --git a/common/host-side/util/src/com/android/compatibility/common/util/BusinessLogicHostExecutor.java b/common/host-side/util/src/com/android/compatibility/common/util/BusinessLogicHostExecutor.java index 09769697..9949f077 100644 --- a/common/host-side/util/src/com/android/compatibility/common/util/BusinessLogicHostExecutor.java +++ b/common/host-side/util/src/com/android/compatibility/common/util/BusinessLogicHostExecutor.java @@ -70,7 +70,7 @@ public class BusinessLogicHostExecutor extends BusinessLogicExecutor { */ @Override protected String formatExecutionString(String method, String... args) { - return String.format("%s(%s)", method, String.join(", ", args)); + return String.format("%s(%s)", method, String.join(", ", formatArgs(args))); } /** diff --git a/common/util/src/com/android/compatibility/common/util/BusinessLogicExecutor.java b/common/util/src/com/android/compatibility/common/util/BusinessLogicExecutor.java index a53b0c41..c2143293 100644 --- a/common/util/src/com/android/compatibility/common/util/BusinessLogicExecutor.java +++ b/common/util/src/com/android/compatibility/common/util/BusinessLogicExecutor.java @@ -35,6 +35,10 @@ public abstract class BusinessLogicExecutor { protected static final String STRING_CLASS = "java.lang.String"; protected static final String STRING_ARRAY_CLASS = "[Ljava.lang.String;"; + /* List of substrings indicating a method arg should be redacted in the logs */ + private static final String[] REDACTED_VALUES = new String[] {"permission"}; + private static final String REDACTED_PLACEHOLDER = "[redacted]"; + /** * Execute a business logic condition. * @param method the name of the method to invoke. Must include fully qualified name of the @@ -92,6 +96,23 @@ public abstract class BusinessLogicExecutor { */ protected abstract String formatExecutionString(String method, String... args); + /** Substitute sensitive information with REDACTED_PLACEHOLDER if necessary. */ + protected static String[] formatArgs(String[] args) { + for (int i = 0; i < args.length; i++) { + args[i] = formatArg(args[i]); + } + return args; + } + + private static String formatArg(String arg) { + for (String str : REDACTED_VALUES) { + if (arg.contains(str)) { + return REDACTED_PLACEHOLDER; + } + } + return arg; + } + /** * Execute a business logic method. * @param method the name of the method to invoke. Must include fully qualified name of the |