dpol1 commented on code in PR #2163:
URL: https://github.com/apache/stormcrawler/pull/2163#discussion_r4026446605
##########
core/src/main/java/org/apache/stormcrawler/protocol/okhttp/HttpProtocol.java:
##########
@@ -499,6 +532,50 @@ private URL getCookieOrigin(Metadata md, String url) {
}
}
+ /**
+ * Adds a host of http.basicauth.hosts in the canonical form OkHttp
reports for the host of a
+ * request, i.e. lower case and IDNs in punycode. An IPv6 address may be
given with or without
+ * brackets. An entry with a scheme, port, user info, path, query or
wildcard is not a plain
+ * host and is ignored.
+ */
+ private void addBasicAuthHost(String entry) {
+ if (StringUtils.isBlank(entry)) {
+ return;
+ }
+ String host = entry.trim();
+ if (!host.startsWith("[") && StringUtils.countMatches(host, ':') > 1) {
+ // an IPv6 address without brackets
+ host = "[" + host + "]";
+ }
+ // checked on the entry itself: HttpUrl keeps '*' as part of the host
name and drops the
+ // default port 80, so neither would be noticed on the parsed url
+ final String afterAddress =
+ host.startsWith("[") ? StringUtils.substringAfter(host, "]") :
host;
+ final HttpUrl parsed =
+ host.contains("*") || afterAddress.contains(":")
+ ? null
+ : HttpUrl.parse("http://" + host + "/");
+ if (parsed == null
+ || !parsed.equals(
+ new
HttpUrl.Builder().scheme("http").host(parsed.host()).build())) {
+ LOG.warn(
+ "Ignoring '{}' in http.basicauth.hosts, expected a host
name or IP address "
Review Comment:
could we not log the value here? a pasted URL with user:pw in it would end
up in the logs, like the proxy string in #2151
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]