Skip to content

Commit

Permalink
Fix issue with exception masking - fixes #2.
Browse files Browse the repository at this point in the history
Was creating an invalid regex to replace url’s and ip’s. Was preventing
exceptions being notified to analytics - no user identifiable data was
published.
  • Loading branch information
matt-richardson committed May 6, 2016
1 parent 5eb2ba1 commit b8b87a8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
env:
global:
- VERSION=2.4.1
- VERSION=2.4.2
- SHORT_COMMIT_SHA=$(git rev-parse --short HEAD)
- RELEASE_VERSION=$VERSION+build.$TRAVIS_BUILD_NUMBER.sha.$SHORT_COMMIT_SHA
- secure: FQU39qHnx9XMeB/DMN6AMBD18ReFfKdPyP6o/p3b7PA3Yr0JuvDb2y9YZmv7XFI1I6o/fEObHrq66sNXwQzBFmtj1RZMYbU9Me8BsqoxggHxK9jFsp7ycHn0KjCVGKqJLQ3GmyaaA9GDbYDq3hv3RkeCDzHYJ0UoiVYBX8SXtZaXvJv6geTbbY8SAKgLnr9J3+YXTLhN3hgCdBkLyWJpKyWtrgdFDr6q4OHpU5zN+NmzO5UBHO44A4Q0jcs15kwvgpk7miiwyOuXA7l7kcVQLukh19q3eVrMxBLpm8tH2aHgFQIvg9rIEF/1+jB337OTqFcwWrxZFq5Ryiu0QK3UDypP92zaqEsKzYcubs9GHoTMPmpxGGxOZMJ02iW5jB9BhicrhUuozGfUndmk+eSkjjUAtFISMDHIQlAapyck0uz+k+km00MdA9p1lHOLruCSrDrYj/8ncltprq2BjzASRY9N365XuYGgkP/j9Df/UXETXsEfGHvoAidu2Vo1CYtfp0LFL5XK+oXfXvk6ZS8/WV0LPume+wlm/pL4eT53rpNsu8N8LUJJXOPmqe9EvYQM8OoEmfJzuU9sDDZ2DOU9Kbu2rnPIj2dnmj5zEanEebVYGzxdlg6sIst3O+grlhZdLN5LhqN1S/xZjwOTC0V0DLE89K74X97vl39DV43oOPI=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class AnalyticsTrackerImpl implements AnalyticsTracker {
private final String teamCityVersion;
private final String applicationName = "teamcity-octopus-build-trigger-plugin";
private static final Pattern ipAddressPattern = Pattern.compile("\\d*\\.\\d*\\.\\d*\\.\\d*");
private static final Pattern urlPattern = Pattern.compile("(http|https)://(.*?)/");
private static final Pattern urlPattern = Pattern.compile("(http|https)://(.*?)(/|:)");
private GoogleAnalytics ga = null;
private String octopusVersion = "not-set";
private String octopusApiVersion = "not-set";
Expand Down Expand Up @@ -138,7 +138,7 @@ static String maskException(Exception e) {
if (urlMatcher.find())
url = urlMatcher.group(2);

Pattern urlPatternWithPort = Pattern.compile("(" + url + ":\\d*) ");
Pattern urlPatternWithPort = Pattern.compile("(" + url + ":\\d+)");

Matcher urlPatternMatcher = urlPatternWithPort.matcher(result);
String urlWithPort = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,10 @@ public void masks_private_detail_in_exception_messages_for_https() {
String result = AnalyticsTrackerImpl.maskException(e);
Assert.assertEquals(result, "java.lang.Exception: com.mjrichardson.teamCity.buildTriggers.DeploymentComplete.DeploymentsProviderException: Unexpected exception in DeploymentsProviderImpl, while attempting to get deployments from https://*****/: org.apache.http.conn.ConnectTimeoutException: Connect to *****:***** [*****/*****] failed: connect timed out");
}

public void masks_private_detail_in_exception_messages_for_xxx() {
Exception e = new Exception("Unexpected exception in MachinesProviderImpl, while attempting to get Machines from https://windows10vm.local: org.apache.http.conn.HttpHostConnectException: Connect to windows10vm.local:443 [windows10vm.local/192.168.213.80] failed: Connection timed out: connect ");
String result = AnalyticsTrackerImpl.maskException(e);
Assert.assertEquals(result, "java.lang.Exception: Unexpected exception in MachinesProviderImpl, while attempting to get Machines from https://*****: org.apache.http.conn.HttpHostConnectException: Connect to *****:***** [*****/*****] failed: Connection timed out: connect ");
}
}

0 comments on commit b8b87a8

Please sign in to comment.