Просмотр исходного кода

Strip user input URLs from net/url parse errors

Rod Hynes 5 лет назад
Родитель
Сommit
ffbcfd7857
1 измененных файлов с 12 добавлено и 0 удалено
  1. 12 0
      psiphon/server/api.go

+ 12 - 0
psiphon/server/api.go

@@ -1068,6 +1068,18 @@ func getRequestLogFields(
 				// value for speed_test_samples via the web API protocol. Omit
 				// the field in this case.
 
+			case "tunnel_error":
+				// net/url.Error, returned from net/url.Parse, contains the original input
+				// URL, which may contain PII. New clients strip this out by using
+				// common.SafeParseURL. Legacy clients will still send the full error
+				// message, so strip it out here. The target substring should be unique to
+				// legacy clients.
+				target := "upstreamproxy error: proxyURI url.Parse: parse "
+				index := strings.Index(strValue, target)
+				if index != -1 {
+					strValue = strValue[:index+len(target)] + "<redacted>"
+				}
+
 			default:
 				if expectedParam.flags&requestParamLogStringAsInt != 0 {
 					intValue, _ := strconv.Atoi(strValue)