snvijaya commented on a change in pull request #2422:
URL: https://github.com/apache/hadoop/pull/2422#discussion_r515748434
##########
File path:
hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsHttpOperation.java
##########
@@ -513,4 +509,45 @@ private void parseListFilesResponse(final InputStream
stream) throws IOException
private boolean isNullInputStream(InputStream stream) {
return stream == null ? true : false;
}
+
+ @VisibleForTesting
+ public String getSignatureMaskedUrlStr() {
+ if (this.maskedUrlStr != null) {
+ return this.maskedUrlStr;
+ }
+ final String urlStr = url.toString();
+ final String qpStr = "sig=";
Review comment:
create a private static final string. - private static final String
SIGNATURE_QUERY_PARAM_KEY = "sig=";
##########
File path:
hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsIoUtils.java
##########
@@ -58,6 +58,9 @@ public static void dumpHeadersToDebugLog(final String origin,
if (key.contains("Cookie")) {
values = "*cookie info*";
}
+ if (key.equals("sig")) {
Review comment:
Is a header called "sig" getting added when SAS ?
##########
File path:
hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsHttpOperation.java
##########
@@ -513,4 +509,45 @@ private void parseListFilesResponse(final InputStream
stream) throws IOException
private boolean isNullInputStream(InputStream stream) {
return stream == null ? true : false;
}
+
+ @VisibleForTesting
+ public String getSignatureMaskedUrlStr() {
+ if (this.maskedUrlStr != null) {
+ return this.maskedUrlStr;
+ }
+ final String urlStr = url.toString();
+ final String qpStr = "sig=";
+ final int qpStrIdx = urlStr.indexOf(qpStr);
+ if (qpStrIdx < 0) {
+ return urlStr;
+ }
+ final StringBuilder sb = new StringBuilder();
+ sb.append(urlStr, 0, qpStrIdx);
+ sb.append(qpStr);
+ sb.append("XXXX");
+ if (qpStrIdx + qpStr.length() < urlStr.length()) {
+ String urlStrSecondPart = urlStr.substring(qpStrIdx + qpStr.length());
+ int idx = urlStrSecondPart.indexOf("&");
+ if (idx > -1) {
+ sb.append(urlStrSecondPart.substring(idx));
+ }
Review comment:
Using string replace should be easier.
int sigStartIndex = urlStr.indexOf(SIGNATURE_QUERY_PARAM_KEY);
if (sigStartIndex == -1) {
// no signature query param in the url
return urlStr;
}
sigStartIndex += SIGNATURE_QUERY_PARAM_KEY.length();
int sigEndIndex = urlStr.indexOf("&", sigStartIndex);
String sigValue = (sigEndIndex == -1)
? urlStr.substring(sigStartIndex)
: urlStr.substring(sigStartIndex, sigEndIndex);
return urlStr.replace(sigValue, "XXXX");
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]