Skip to content

Commit 09302b2

Browse files
committed
Filtering out Auth keys and API key from logging
Added checks to omit Auth key and API key before logging
1 parent ab0750b commit 09302b2

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

iterableapi/src/main/java/com/iterable/iterableapi/IterableAuthManager.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ public void queueExpirationRefresh(String encodedJWT) {
8282
if (triggerExpirationRefreshTime > 0) {
8383
scheduleAuthTokenRefresh(triggerExpirationRefreshTime);
8484
} else {
85-
IterableLogger.w(TAG, "The expiringAuthTokenRefreshPeriod has already passed for the current JWT " + encodedJWT);
85+
IterableLogger.w(TAG, "The expiringAuthTokenRefreshPeriod has already passed for the current JWT");
8686
}
8787
} catch (Exception e) {
88-
IterableLogger.e(TAG, "Error while parsing JWT for the expiration: " + encodedJWT, e);
88+
IterableLogger.e(TAG, "Error while parsing JWT for the expiration", e);
8989
}
9090
}
9191

iterableapi/src/main/java/com/iterable/iterableapi/IterableLogger.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
public class IterableLogger {
99

1010
public static void d(String tag, String msg) {
11-
if (isLoggableLevel(Log.DEBUG)) {
11+
if (isLoggable(Log.DEBUG)) {
1212
Log.d(tag, " 💚 " + msg);
1313
}
1414
}
@@ -59,7 +59,7 @@ public static void printInfo() {
5959

6060
private static boolean isLoggable(int messageLevel) {
6161
boolean isDebug = ((IterableApi.getInstance().getMainActivityContext().getApplicationInfo().flags & IterableApi.getInstance().getMainActivityContext().getApplicationInfo().FLAG_DEBUGGABLE) != 0);
62-
if(isDebug){
62+
if (isDebug) {
6363
return isLoggableLevel(messageLevel);
6464
}
6565
// Log level will be set to WARNING and above if in release mode.

iterableapi/src/main/java/com/iterable/iterableapi/IterableRequestTask.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -245,12 +245,19 @@ private static String buildHeaderString(HttpURLConnection urlConnection) {
245245
Iterator<?> headerKeys = urlConnection.getRequestProperties().keySet().iterator();
246246
while (headerKeys.hasNext()) {
247247
String key = (String) headerKeys.next();
248-
headerString.append(key + " : " + urlConnection.getRequestProperties().get(key) + "\n");
248+
if (isSensitive(key)) {
249+
continue;
250+
}
251+
headerString.append(key).append(" : ").append(urlConnection.getRequestProperties().get(key)).append("\n");
249252
}
250253
headerString.append("}");
251254
return headerString.toString();
252255
}
253256

257+
private static boolean isSensitive(String key) {
258+
return (key.equals(IterableConstants.HEADER_API_KEY)) || key.equals(IterableConstants.HEADER_SDK_AUTHORIZATION);
259+
}
260+
254261
@Override
255262
protected void onPostExecute(IterableApiResponse response) {
256263
boolean retryRequest = !response.success && response.responseCode >= 500;

0 commit comments

Comments
 (0)