Skip to content

Impelement secrets detection for Az modules #412

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Feb 28, 2024
Prev Previous commit
Next Next commit
Skip indexed properties in the object traverse
  • Loading branch information
vidai-msft committed Feb 26, 2024
commit 85a5378df3afdcc4d94bab4d2a54b43c0c8fce72
4 changes: 3 additions & 1 deletion src/Common/Sanitizer/DefaultProviderResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,9 @@ private SanitizerProvider CreateCustomObjectProvider(Type objType)
var objProvider = new SanitizerCustomObjectProvider(Service);
foreach (var property in objType.GetRuntimeProperties())
{
if (property.CanRead && !property.PropertyType.IsValueType && property.GetMethod != null && !property.GetMethod.IsStatic && !IsIgnoredProperty(objType.FullName, property.Name))
if (property.CanRead && !property.PropertyType.IsValueType && property.GetMethod != null && !property.GetMethod.IsStatic
&& property.GetIndexParameters().Length == 0
&& !IsIgnoredProperty(objType.FullName, property.Name))
{
var sanitizerProperty = new SanitizerProperty(property);
objProvider.Properties.Add(sanitizerProperty);
Expand Down
17 changes: 10 additions & 7 deletions src/Common/Sanitizer/SanitizerCustomObjectProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,18 @@ public override void SanitizeValue(object sanitizingObject, Stack<object> saniti
if (propValue != null)
{
var provider = resolver.ResolveProvider(propValue.GetType());
if (provider?.GetType() == typeof(SanitizerStringProvider))
if (provider != null)
{
provider?.SanitizeValue(sanitizingObject, sanitizingStack, resolver, prop, telemetry);
}
else
{
if (!sanitizingStack.HasCircularReference(propValue))
if (provider.GetType() == typeof(SanitizerStringProvider))
{
provider.SanitizeValue(sanitizingObject, sanitizingStack, resolver, prop, telemetry);
}
else
{
provider?.SanitizeValue(propValue, sanitizingStack, resolver, prop, telemetry);
if (!sanitizingStack.HasCircularReference(propValue))
{
provider.SanitizeValue(propValue, sanitizingStack, resolver, prop, telemetry);
}
}
}
}
Expand Down
11 changes: 10 additions & 1 deletion src/Common/Sanitizer/SanitizerProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,16 @@ public SanitizerProperty(PropertyInfo property)

public object GetValue(object instance)
{
return ValueSupplier.GetValue(instance);
try
{
return ValueSupplier.GetValue(instance);
}
catch
{
// Ignore exceptions
}

return null;
}
}
}