Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/CommonLib/SecurityDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public virtual string GetOwner(Type targetType)
{
// Blocking External Call -- Possible blocking through locks, and Translate call
// see https://github.com/dotnet/runtime/blob/9d5a6a9aa463d6d10b0b0ba6d5982cc82f363dc3/src/libraries/System.Security.AccessControl/src/System/Security/AccessControl/ObjectSecurity.cs#L336
return _sd.GetOwner(targetType).Value;
return _sd.GetOwner(targetType)?.Value;
}
}
}
}
21 changes: 21 additions & 0 deletions test/unit/SecurityDescriptorTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.DirectoryServices;
using System.Runtime.Versioning;
using System.Security.Principal;
using SharpHoundCommonLib;
using Xunit;

namespace CommonLibTest;

public class SecurityDescriptorTests
{
[SupportedOSPlatform("windows")]
[WindowsOnlyFact]
public void GetOwner_SecurityDescriptorWithoutOwner_ReturnsNull()
{
var descriptor = new ActiveDirectorySecurityDescriptor(new ActiveDirectorySecurity());

var owner = descriptor.GetOwner(typeof(SecurityIdentifier));

Assert.Null(owner);
}
}
Loading