Skip to content
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

Adding the provision of redirecting HTTP requests to HTTPS #675

Open
wants to merge 2 commits into
base: tuning_20190221
Choose a base branch
from

Conversation

ShubhamGupta29
Copy link
Contributor

DESCRIPTION
In this PR changes are done to redirect HTTP requests to HTTPS-enabled endpoints if Dr.Elephant has HTTPS enabled. This is achieved by checking the port of every request and if the port is the same as that of HTTP_PORT(defined in elephant.conf or 8080 by default) then redirect the request to the HTTPS-enabled port if exists.

HOW THESE CHANGES ARE TESTED
Tested these changes on the local and EI machines both. In this testing confirmed if the HTTPS requests are getting redirected to HTTPs endpoints or not.

@ShubhamGupta29 ShubhamGupta29 self-assigned this Apr 8, 2020
@ShubhamGupta29 ShubhamGupta29 added the security Any issue related to security of the user or service label Apr 9, 2020
Copy link

@loganrosen loganrosen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for implementing this!

app/Global.java Outdated
* @return Return the port of the of the hostAddress if exists else return INVALID_PORT
*/
private String getPortFromHostAddress(String hostAddress) {
String patterForPort = "(.+):([\\d]{1,5})";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/patter/pattern/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After using Guava's HostAndPort.fromString() there was no need of the method so removed the respective method.

app/Global.java Outdated
Comment on lines 129 to 141
/**
*
* @param hostAddress The hostAddress string which will be of format "elephant.abc.com:8080"
* @return Return the port of the of the hostAddress if exists else return INVALID_PORT
*/
private String getPortFromHostAddress(String hostAddress) {
String patterForPort = "(.+):([\\d]{1,5})";
Matcher matcher = Pattern.compile(patterForPort).matcher(hostAddress);
if (matcher.find()) {
return matcher.group(2);
}
return INVALID_PORT;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to consider leveraging Guava's HostAndPort.fromString() instead of manually implementing this logic. I also don't think this regular expression will work if it's a bare IPv6 address.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Big thanks Logan, I was looking for such a utility method and couldn't find it so implemented a crude one. Thanks for the review and for reporting this issue.

Copy link

@saniyanajeeb saniyanajeeb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
security Any issue related to security of the user or service task
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Credentials for login are passed over HTTP even if HTTPS is enabled
3 participants