Ejemplo n.º 1
0
 private Uri ObfuscateUri(RequestTelemetry telemetryItem)
 {
     if (IsPIIOperation(telemetryItem.Context.Operation.Name))
     {
         // The new url form will be: https://nuget.org/ObfuscatedUserName
         return(new Uri(Obfuscator.DefaultObfuscatedUrl(telemetryItem.Url)));
     }
     return(telemetryItem.Url);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// These values will be used to overwrite the serverVariables in the Elmah error before the exception is logged.
        /// These are the serverVariables that Gallery decides that will be obfuscated and the values to be used for obfuscation.
        /// </summary>
        /// <param name="currentContext">The current HttpContext.</param>
        /// <returns>A dictionary with the server variables that will be obfuscated.</returns>
        internal static Dictionary<string, string> GetObfuscatedServerVariables(HttpContextBase currentContext)
        {
            string operation = string.Empty;
            if(currentContext == null ||
               currentContext.Request == null ||
               currentContext.Request.RequestContext == null ||
               !IsPIIRoute(currentContext.Request.RequestContext.RouteData, out operation))
            {
                return null;
            }
            
            var obfuscatedServerVariables = new Dictionary<string, string>();
            var obfuscatedURL = Obfuscator.DefaultObfuscatedUrl(currentContext.Request.Url);
            obfuscatedServerVariables.Add("HTTP_REFERER", obfuscatedURL);
            obfuscatedServerVariables.Add("PATH_INFO", operation);
            obfuscatedServerVariables.Add("PATH_TRANSLATED", operation);
            obfuscatedServerVariables.Add("SCRIPT_NAME", operation);
            obfuscatedServerVariables.Add("URL", obfuscatedURL);

            return obfuscatedServerVariables;
        }