You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2020/09/03 19:07:23 UTC

[GitHub] [trafficcontrol] srijeet0406 opened a new pull request #5011: Enhanced Geo Location bypass in Traffic Router

srijeet0406 opened a new pull request #5011:
URL: https://github.com/apache/trafficcontrol/pull/5011


   <!--
   ************ STOP!! ************
   If this Pull Request is intended to fix a security vulnerability, DO NOT submit it! Instead, contact
   the Apache Software Foundation Security Team at security@trafficcontrol.apache.org and follow the
   guidelines at https://www.apache.org/security/ regarding vulnerability disclosure.
   -->
   ## What does this PR (Pull Request) do?
   <!-- Explain the changes you made here. If this fixes an Issue, identify it by
   replacing the text in the checkbox item with the Issue number e.g.
   
   - [x] This PR fixes #9001 OR is not related to any Issue
   
   ^ This will automatically close Issue number 9001 when the Pull Request is
   merged (The '#' is important).
   
   Be sure you check the box properly, see the "The following criteria are ALL
   met by this PR" section for details.
   -->
   
   - [x] This PR fixes #4912  <!-- You can check for an issue here: https://github.com/apache/trafficcontrol/issues -->
   
   
   ## Which Traffic Control components are affected by this PR?
   <!-- Please delete all components from this list that are NOT affected by this
   Pull Request. Also, feel free to add the name of a tool or script that is
   affected but not on the list.
   
   Additionally, if this Pull Request does NOT affect documentation, please
   explain why documentation is not required. -->
   
   - Documentation
   - Traffic Router
   
   ## What is the best way to verify this PR?
   <!-- Please include here ALL the steps necessary to test your Pull Request. If
   it includes tests (and most should), outline here the steps needed to run the
   tests. If not, lay out the manual testing procedure and please explain why
   tests are unnecessary for this Pull Request. -->
   
   There are a few pre reqs to test this PR.
   1.) You need to be in an environment that has the `geolocation.polling.url` set to `http://cdn-dczf.cdn.comcast.net/maxmind/GeoIP2-City.mmdb.gz`
   NOTE: CiaB does NOT use this version of Maxmind, and instead uses the `Lite` version of that database. This will not work for this PR. You could use staging/ nightly. You can also override the param value to point to `http://cdn-dczf.cdn.comcast.net/maxmind/GeoIP2-City.mmdb.gz`, and then do a snapshot of the CDN.
   2.) You will also need to set the `maxmind.default.override` for the `CRConfig.json` to point to the default coordinates of the country. This can be done for multiple countries. The value for my setup is `US;37.751,-97.822`.
   3.) Now, you will need to route traffic through this TR, using a spoofed IP. This IP should be one that has the city and postal code, and no subdivisions, and should be in the US (since our override is configured with the default coordinates of the US). I use this IP for my tests `103.111.32.61` 
   4.) Tail the logs of the TR docker container
   5.) The way I use this spoofed IP in my CiaB environment (which has all the above mentioned changes) is this:
   Exec into the enroller container of CiaB: `docker-compose exec enroller /bin/bash`
   Curl the DS URL of CiaB, with a spoofed IP: `curl -H x-mm-client-ip:103.111.32.61 -L http://video.demo1.mycdn.ciab.test`
   6.) You should see a `rType` of `GEO_DS` in the logs, for your client IP. This is the new rType that says that the default miss location of the DS was used.
   
   ## If this is a bug fix, what versions of Traffic Control are affected?
   <!-- If this PR fixes a bug, please list here all of the affected versions - to
   the best of your knowledge. It's also pretty helpful to include a commit hash
   of where 'master' is at the time this PR is opened (if it affects master),
   because what 'master' means will change over time. For example, if this PR
   fixes a bug that's present in master (at commit hash '1df853c8'), in v4.0.0,
   and in the current 4.0.1 Release candidate (e.g. RC1), then this list would
   look like:
   
   - master (1df853c8)
   - 4.0.0
   - 4.0.1 (RC1)
   
   If you don't know what other versions might have this bug, AND don't know how
   to find the commit hash of 'master', then feel free to leave this section
   blank (or, preferably, delete it entirely).
    -->
   - master
   
   ## The following criteria are ALL met by this PR
   <!-- Check the boxes to signify that the associated statement is true. To
   "check a box", replace the space inside of the square brackets with an 'x'.
   e.g.
   
   - [ x] <- Wrong
   - [x ] <- Wrong
   - [] <- Wrong
   - [*] <- Wrong
   - [x] <- Correct!
   
   -->
   
   - [x] This PR includes tests
   - [x] This PR includes documentation
   - [x] This PR includes an update to CHANGELOG.md
   - [x] This PR includes any and all required license headers
   - [x] This PR does not include a database migration
   - [x] This PR **DOES NOT FIX A SERIOUS SECURITY VULNERABILITY** (see [the Apache Software Foundation's security guidelines](https://www.apache.org/security/) for details)
   
   
   ## Additional Information
   <!-- If you would like to include any additional information on the PR for
   potential reviewers please put it here.
   
   Some examples of this would be:
   
   - Before and after screenshots/gifs of the Traffic Portal if it is affected
   - Links to other dependent Pull Requests
   - References to relevant context (e.g. new/updates to dependent libraries,
   mailing list records, blueprints)
   
   Feel free to leave this section blank (or, preferably, delete it entirely).
   -->
   
   <!--
   Licensed to the Apache Software Foundation (ASF) under one
   or more contributor license agreements.  See the NOTICE file
   distributed with this work for additional information
   regarding copyright ownership.  The ASF licenses this file
   to you under the Apache License, Version 2.0 (the
   "License"); you may not use this file except in compliance
   with the License.  You may obtain a copy of the License at
   
       http://www.apache.org/licenses/LICENSE-2.0
   
   Unless required by applicable law or agreed to in writing,
   software distributed under the License is distributed on an
   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   KIND, either express or implied.  See the License for the
   specific language governing permissions and limitations
   under the License.
   -->
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [trafficcontrol] srijeet0406 commented on a change in pull request #5011: Enhanced Geo Location bypass in Traffic Router

Posted by GitBox <gi...@apache.org>.
srijeet0406 commented on a change in pull request #5011:
URL: https://github.com/apache/trafficcontrol/pull/5011#discussion_r485748925



##########
File path: traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/router/TrafficRouter.java
##########
@@ -513,8 +514,9 @@ public Geolocation getLocation(final String clientIP, final DeliveryService deli
 			}
 		}
 
-		if (clientLocation.isDefaultLocation() && defaultGeolocationsOverride.containsKey(clientLocation.getCountryCode())) {
-			clientLocation = defaultGeolocationsOverride.get(clientLocation.getCountryCode());
+		if (clientLocation.isDefaultLocation() && getDefaultGeoLocationsOverride().containsKey(clientLocation.getCountryCode())) {
+			clientLocation = deliveryService.getMissLocation();

Review comment:
       Yeah that will be a part of the change that I proposed last night on the mailing list. I was just waiting to see if there were any concerns with that. I'll make the changes today 👍 




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [trafficcontrol] srijeet0406 commented on a change in pull request #5011: Enhanced Geo Location bypass in Traffic Router

Posted by GitBox <gi...@apache.org>.
srijeet0406 commented on a change in pull request #5011:
URL: https://github.com/apache/trafficcontrol/pull/5011#discussion_r488260183



##########
File path: traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/router/StatTracker.java
##########
@@ -184,7 +184,13 @@ public void setRegionalAlternateCount(final int regionalAlternateCount) {
 			/**
 			 * This value indicates that routing was blocked in accordance with anonymous blocking configurations.
 			 */
-			ANON_BLOCK
+			ANON_BLOCK,
+			/**
+			 * This value indicates that routing was based on the default lat/long of the delivery service, because maxmind
+			 * returned the centre of the country as the client location, due to the CZF not being able to resolve the client IP
+			 * to a valid location.
+			 */
+			GEO_DS

Review comment:
       This was part of the ticket description from @dneuman64. I think he wants it so that the Maple team can easily see how many events matched this type.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [trafficcontrol] mattjackson220 commented on a change in pull request #5011: Enhanced Geo Location bypass in Traffic Router

Posted by GitBox <gi...@apache.org>.
mattjackson220 commented on a change in pull request #5011:
URL: https://github.com/apache/trafficcontrol/pull/5011#discussion_r488184275



##########
File path: traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/router/TrafficRouter.java
##########
@@ -523,7 +530,11 @@ public Geolocation getLocation(final String clientIP, final DeliveryService deli
 			track.setResultDetails(ResultDetails.GEO_NO_CACHE_FOUND);
 		}
 
-		track.setResult(ResultType.GEO);
+		if (useDSDefaults) {

Review comment:
       would this be able to go into the if statement above? instead of having the useDSDefaults boolean just set the result type in that if statement instead? then we could get rid of the SuppressWarnings too




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [trafficcontrol] mattjackson220 commented on a change in pull request #5011: Enhanced Geo Location bypass in Traffic Router

Posted by GitBox <gi...@apache.org>.
mattjackson220 commented on a change in pull request #5011:
URL: https://github.com/apache/trafficcontrol/pull/5011#discussion_r488822277



##########
File path: traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/router/StatTracker.java
##########
@@ -184,7 +184,13 @@ public void setRegionalAlternateCount(final int regionalAlternateCount) {
 			/**
 			 * This value indicates that routing was blocked in accordance with anonymous blocking configurations.
 			 */
-			ANON_BLOCK
+			ANON_BLOCK,
+			/**
+			 * This value indicates that routing was based on the default lat/long of the delivery service, because maxmind
+			 * returned the centre of the country as the client location, due to the CZF not being able to resolve the client IP
+			 * to a valid location.
+			 */
+			GEO_DS

Review comment:
       yea thats why i was thinking it might be good to add another one in there that tells us that it is just using the maxmind defaults. eh if theres value there itll be an easy change to add in if people decide they want it




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [trafficcontrol] mattjackson220 commented on a change in pull request #5011: Enhanced Geo Location bypass in Traffic Router

Posted by GitBox <gi...@apache.org>.
mattjackson220 commented on a change in pull request #5011:
URL: https://github.com/apache/trafficcontrol/pull/5011#discussion_r488185211



##########
File path: traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/router/StatTracker.java
##########
@@ -184,7 +184,13 @@ public void setRegionalAlternateCount(final int regionalAlternateCount) {
 			/**
 			 * This value indicates that routing was blocked in accordance with anonymous blocking configurations.
 			 */
-			ANON_BLOCK
+			ANON_BLOCK,
+			/**
+			 * This value indicates that routing was based on the default lat/long of the delivery service, because maxmind
+			 * returned the centre of the country as the client location, due to the CZF not being able to resolve the client IP
+			 * to a valid location.
+			 */
+			GEO_DS

Review comment:
       do you think there would be any gain to add another result type that let us know that it is just using the default from maxmind (like if it doesnt have a DS default and the client ip didnt resolve to a valid location)? not sure if theres any gain there but might just give us more info quickly?




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [trafficcontrol] limited commented on a change in pull request #5011: Enhanced Geo Location bypass in Traffic Router

Posted by GitBox <gi...@apache.org>.
limited commented on a change in pull request #5011:
URL: https://github.com/apache/trafficcontrol/pull/5011#discussion_r485739065



##########
File path: traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/router/TrafficRouter.java
##########
@@ -513,8 +514,9 @@ public Geolocation getLocation(final String clientIP, final DeliveryService deli
 			}
 		}
 
-		if (clientLocation.isDefaultLocation() && defaultGeolocationsOverride.containsKey(clientLocation.getCountryCode())) {
-			clientLocation = defaultGeolocationsOverride.get(clientLocation.getCountryCode());
+		if (clientLocation.isDefaultLocation() && getDefaultGeoLocationsOverride().containsKey(clientLocation.getCountryCode())) {
+			clientLocation = deliveryService.getMissLocation();

Review comment:
       What happens if `missLocation` is null? 
   
   I think the most consistent behavior for a null `missLocation` would be to continue using 
   ```
   defaultGeolocationsOverride.get(clientLocation.getCountryCode());
   ```` 
   




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [trafficcontrol] mattjackson220 merged pull request #5011: Enhanced Geo Location bypass in Traffic Router

Posted by GitBox <gi...@apache.org>.
mattjackson220 merged pull request #5011:
URL: https://github.com/apache/trafficcontrol/pull/5011


   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [trafficcontrol] srijeet0406 commented on a change in pull request #5011: Enhanced Geo Location bypass in Traffic Router

Posted by GitBox <gi...@apache.org>.
srijeet0406 commented on a change in pull request #5011:
URL: https://github.com/apache/trafficcontrol/pull/5011#discussion_r488262059



##########
File path: traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/router/TrafficRouter.java
##########
@@ -523,7 +530,11 @@ public Geolocation getLocation(final String clientIP, final DeliveryService deli
 			track.setResultDetails(ResultDetails.GEO_NO_CACHE_FOUND);
 		}
 
-		track.setResult(ResultType.GEO);
+		if (useDSDefaults) {

Review comment:
       Done 👍 




----------------------------------------------------------------
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:
users@infra.apache.org