-
Notifications
You must be signed in to change notification settings - Fork 8.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HADOOP-17311. ABFS: Logs should redact SAS signature #2422
HADOOP-17311. ABFS: Logs should redact SAS signature #2422
Conversation
5e7f550
to
0e4dbc8
Compare
0e4dbc8
to
8883b59
Compare
💔 -1 overall
This message was automatically generated. |
@@ -36,6 +36,7 @@ | |||
import org.codehaus.jackson.JsonParser; | |||
import org.codehaus.jackson.JsonToken; | |||
import org.codehaus.jackson.map.ObjectMapper; | |||
import com.google.common.annotations.VisibleForTesting; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now all shaded I'm afraid. Making backporting harder already
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
LOG.warn(String.format("Unknown host name: %s. Retrying to resolve the host name...", httpOperation.getUrl().getHost())); | ||
LOG.warn(String.format( | ||
"Unknown host name: %s. Retrying to resolve the host name...", | ||
httpOperation.getHost())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While you are there
- add a catch for UnknownHostException
- move from String.format to Log.warn("unknown host {}", httpOperation,getHost()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
final AzureBlobFileSystem fs; | ||
String msg = null; | ||
try { | ||
fs = getFileSystem(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use LambdaTestUtils.intercept(). Not only simpler, it will (correctly) fail if the rest operation didn't actually raise an exception
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
if (this.maskedUrlStr != null) { | ||
return this.maskedUrlStr; | ||
} | ||
final String urlStr = url.toString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is complicated enough it could be pulled out into a static method, and so its handling fully tested in (new) Unit tests, as well as in the ITests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check comments.
return this.maskedUrlStr; | ||
} | ||
final String urlStr = url.toString(); | ||
final String qpStr = "sig="; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create a private static final string. - private static final String SIGNATURE_QUERY_PARAM_KEY = "sig=";
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
int idx = urlStrSecondPart.indexOf("&"); | ||
if (idx > -1) { | ||
sb.append(urlStrSecondPart.substring(idx)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -58,6 +58,9 @@ public static void dumpHeadersToDebugLog(final String origin, | |||
if (key.contains("Cookie")) { | |||
values = "*cookie info*"; | |||
} | |||
if (key.equals("sig")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is a header called "sig" getting added when SAS ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The latency tracker sends all the query params through headers.
Driver test results using accounts in Central India HNS-OAuth[INFO] Results: HNS-SharedKey[INFO] Results: NonHNS-SharedKey[INFO] Results: |
@@ -61,6 +64,8 @@ | |||
|
|||
private final String method; | |||
private final URL url; | |||
private String maskedUrlStr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove Str suffix
,"http://www.testurl.net?abc=xyz&sig=abcd" | ||
,"http://www.testurl.net?abc=xyz&sig=XXXX"); | ||
|
||
testIfMaskedSuccessfully("Where sig query param is not present" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
query params ending mysig/*sig.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sig in other cases, like caps,
sig as suffix in the param names and values
💔 -1 overall
This message was automatically generated. |
findbugs is pretty unhappy
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
The yetus run error is due to tests failing on the WASB side, which is not affected by the changes proposed here. The findbugs reported is also unrelated to the change in this PR. |
where did the findbugs error come from? do we need to fix/roll back that change? |
This comment has been minimized.
This comment has been minimized.
This is fixed. |
thx. Trying to work out where that regression failing tests is coming from. as far as I'm concerned, consistent unit test failures are a block on anything new going in. All too easy to ignore and then accidentally add more regressions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
Contributed by bilaharith. Change-Id: Iff0ed4303ac5ce41b62bfda8150ee983dafa40be
…che#2422) Contributed by bilaharith. Change-Id: Iff0ed4303ac5ce41b62bfda8150ee983dafa40be
Masking SAS signatures from logs
HNS-OAuth
[INFO] Results:
[INFO]
[INFO] Tests run: 88, Failures: 0, Errors: 0, Skipped: 0
[INFO] Results:
[INFO]
[WARNING] Tests run: 459, Failures: 0, Errors: 0, Skipped: 66
[INFO] Results:
[INFO]
[WARNING] Tests run: 208, Failures: 0, Errors: 0, Skipped: 24
HNS-SharedKey
[INFO] Results:
[INFO]
[INFO] Tests run: 88, Failures: 0, Errors: 0, Skipped: 0
[INFO] Results:
[INFO]
[WARNING] Tests run: 459, Failures: 0, Errors: 0, Skipped: 24
[INFO] Results:
[INFO]
[WARNING] Tests run: 208, Failures: 0, Errors: 0, Skipped: 16
NonHNS-SharedKey
[INFO] Results:
[INFO]
[INFO] Tests run: 88, Failures: 0, Errors: 0, Skipped: 0
[INFO] Results:
[INFO]
[WARNING] Tests run: 459, Failures: 0, Errors: 0, Skipped: 247
[INFO] Results:
[INFO]
[WARNING] Tests run: 208, Failures: 0, Errors: 0, Skipped: 16