Skip to content

Commit

Permalink
Catch FormatException from get_Uri
Browse files Browse the repository at this point in the history
  • Loading branch information
e-n-0 committed Dec 31, 2024
1 parent 6486306 commit e6eceee
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions tracer/src/Datadog.Trace/Iast/Aspects/System/UriBuilderAspect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ public static UriBuilder Init(string uriText)
{
PropagationModuleImpl.PropagateWholeResultWhenInputTainted(result.Uri.OriginalString, uriText);
}
catch (FormatException ex)
{
IastModule.Log.Debug(ex, $"Error invoking {nameof(UriBuilderAspect)}.{nameof(SetQuery)}");
}
catch (Exception ex)
{
IastModule.Log.Error(ex, $"Error invoking {nameof(UriBuilderAspect)}.{nameof(Init)}");
Expand All @@ -51,6 +55,10 @@ public static UriBuilder Init(Uri uri)
{
PropagationModuleImpl.PropagateWholeResultWhenInputTainted(result.Uri.OriginalString, uri.OriginalString);
}
catch (FormatException ex)
{
IastModule.Log.Debug(ex, $"Error invoking {nameof(UriBuilderAspect)}.{nameof(SetQuery)}");
}
catch (Exception ex)
{
IastModule.Log.Error(ex, $"Error invoking {nameof(UriBuilderAspect)}.{nameof(Init)}");
Expand All @@ -73,6 +81,10 @@ public static UriBuilder Init(string scheme, string host)
{
PropagationModuleImpl.PropagateWholeResultWhenInputTainted(result.Uri.OriginalString, host);
}
catch (FormatException ex)
{
IastModule.Log.Debug(ex, $"Error invoking {nameof(UriBuilderAspect)}.{nameof(SetQuery)}");
}
catch (Exception ex)
{
IastModule.Log.Error(ex, $"Error invoking {nameof(UriBuilderAspect)}.{nameof(Init)}");
Expand All @@ -96,6 +108,10 @@ public static UriBuilder Init(string scheme, string host, int port)
{
PropagationModuleImpl.PropagateWholeResultWhenInputTainted(result.Uri.OriginalString, host);
}
catch (FormatException ex)
{
IastModule.Log.Debug(ex, $"Error invoking {nameof(UriBuilderAspect)}.{nameof(SetQuery)}");
}
catch (Exception ex)
{
IastModule.Log.Error(ex, $"Error invoking {nameof(UriBuilderAspect)}.{nameof(Init)}");
Expand All @@ -120,6 +136,10 @@ public static UriBuilder Init(string scheme, string host, int port, string path)
{
PropagationModuleImpl.PropagateWholeResultWhenInputTainted(result.Uri.OriginalString, host, path);
}
catch (FormatException ex)
{
IastModule.Log.Debug(ex, $"Error invoking {nameof(UriBuilderAspect)}.{nameof(SetQuery)}");
}
catch (Exception ex)
{
IastModule.Log.Error(ex, $"Error invoking {nameof(UriBuilderAspect)}.{nameof(Init)}");
Expand All @@ -145,6 +165,10 @@ public static UriBuilder Init(string scheme, string host, int port, string path,
{
PropagationModuleImpl.PropagateWholeResultWhenInputTainted(result.Uri.OriginalString, host, path, extra);
}
catch (FormatException ex)
{
IastModule.Log.Debug(ex, $"Error invoking {nameof(UriBuilderAspect)}.{nameof(SetQuery)}");
}
catch (Exception ex)
{
IastModule.Log.Error(ex, $"Error invoking {nameof(UriBuilderAspect)}.{nameof(Init)}");
Expand All @@ -166,6 +190,10 @@ public static void SetHost(UriBuilder instance, string parameter)
{
PropagationModuleImpl.PropagateWholeResultWhenInputTainted(instance.Uri.OriginalString, parameter);
}
catch (FormatException ex)
{
IastModule.Log.Debug(ex, $"Error invoking {nameof(UriBuilderAspect)}.{nameof(SetQuery)}");
}
catch (Exception ex)
{
IastModule.Log.Error(ex, $"Error invoking {nameof(UriBuilderAspect)}.{nameof(Init)}");
Expand All @@ -185,6 +213,10 @@ public static void SetQuery(UriBuilder instance, string parameter)
{
PropagationModuleImpl.PropagateWholeResultWhenInputTainted(instance.Uri.OriginalString, parameter);
}
catch (FormatException ex)
{
IastModule.Log.Debug(ex, $"Error invoking {nameof(UriBuilderAspect)}.{nameof(SetQuery)}");
}
catch (Exception ex)
{
IastModule.Log.Error(ex, $"Error invoking {nameof(UriBuilderAspect)}.{nameof(SetQuery)}");
Expand All @@ -204,6 +236,10 @@ public static void SetPath(UriBuilder instance, string parameter)
{
PropagationModuleImpl.PropagateWholeResultWhenInputTainted(instance.Uri.OriginalString, parameter);
}
catch (FormatException ex)
{
IastModule.Log.Debug(ex, $"Error invoking {nameof(UriBuilderAspect)}.{nameof(SetQuery)}");
}
catch (Exception ex)
{
IastModule.Log.Error(ex, $"Error invoking {nameof(UriBuilderAspect)}.{nameof(SetPath)}");
Expand All @@ -223,6 +259,10 @@ public static string GetHost(UriBuilder instance)
{
PropagationModuleImpl.PropagateWholeResultWhenInputTainted(result, instance.Uri.OriginalString);
}
catch (FormatException ex)
{
IastModule.Log.Debug(ex, $"Error invoking {nameof(UriBuilderAspect)}.{nameof(SetQuery)}");
}
catch (Exception ex)
{
IastModule.Log.Error(ex, $"Error invoking {nameof(UriBuilderAspect)}.{nameof(GetHost)}");
Expand All @@ -244,6 +284,10 @@ public static string GetQuery(UriBuilder instance)
{
PropagationModuleImpl.PropagateWholeResultWhenInputTainted(result, instance.Uri.OriginalString);
}
catch (FormatException ex)
{
IastModule.Log.Debug(ex, $"Error invoking {nameof(UriBuilderAspect)}.{nameof(SetQuery)}");
}
catch (Exception ex)
{
IastModule.Log.Error(ex, $"Error invoking {nameof(UriBuilderAspect)}.{nameof(GetQuery)}");
Expand All @@ -265,6 +309,10 @@ public static string GetPath(UriBuilder instance)
{
PropagationModuleImpl.PropagateWholeResultWhenInputTainted(result, instance.Uri.OriginalString);
}
catch (FormatException ex)
{
IastModule.Log.Debug(ex, $"Error invoking {nameof(UriBuilderAspect)}.{nameof(SetQuery)}");
}
catch (Exception ex)
{
IastModule.Log.Error(ex, $"Error invoking {nameof(UriBuilderAspect)}.{nameof(GetPath)}");
Expand All @@ -287,6 +335,10 @@ public static string GetPath(UriBuilder instance)
{
PropagationModuleImpl.PropagateWholeResultWhenInputTainted(result, (instance as UriBuilder)?.Uri?.OriginalString);
}
catch (FormatException ex)
{
IastModule.Log.Debug(ex, $"Error invoking {nameof(UriBuilderAspect)}.{nameof(SetQuery)}");
}
catch (Exception ex)
{
IastModule.Log.Error(ex, $"Error invoking {nameof(UriBuilderAspect)}.{nameof(ToString)}");
Expand Down

0 comments on commit e6eceee

Please sign in to comment.