summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2019-10-03 01:19:35 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2019-10-03 01:19:35 +0000
commit426fc052949b010ab4016b04e9cbdc816726a2a3 (patch)
treed19c517da1aad5778eeb53bf1b94ecc6cf66000b
parent4031fb056942ba55c16515de04028a9f9706bdc0 (diff)
parent881fa59d09d0015dfed461ceb21addfb41f6f5d2 (diff)
downloadsuite_harness-android10-qpr1-c-release.tar.gz
Change-Id: I8581b4ea6dd790cea103c94ebcf7f7fb98eae8ed
-rw-r--r--common/host-side/util/src/com/android/compatibility/common/util/BusinessLogicHostExecutor.java2
-rw-r--r--common/util/src/com/android/compatibility/common/util/BusinessLogicExecutor.java21
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