Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/v4' into processor_merge
Browse files Browse the repository at this point in the history
  • Loading branch information
rvazarkar committed Sep 18, 2024
2 parents 30870bc + 6b31074 commit e3cb8e8
Show file tree
Hide file tree
Showing 10 changed files with 197 additions and 64 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
run: dotnet test # coverage happens by default

- name: Upload Coverage Report
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: report
path: docfx/coverage/report/
Expand Down Expand Up @@ -70,7 +70,7 @@ jobs:
uses: actions/checkout@v2

- name: Download Coverage Report
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: report
path: docfx/coverage/report
Expand Down
60 changes: 60 additions & 0 deletions src/CommonLib/ConcurrentHashSet.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;

namespace SharpHoundCommonLib;

/// <summary>
/// A concurrent implementation of a hashset using a ConcurrentDictionary as the backing structure.
/// </summary>
public class ConcurrentHashSet : IDisposable{
private ConcurrentDictionary<string, byte> _backingDictionary;

public ConcurrentHashSet() {
_backingDictionary = new ConcurrentDictionary<string, byte>();
}

public ConcurrentHashSet(StringComparer comparison) {
_backingDictionary = new ConcurrentDictionary<string, byte>(comparison);
}

/// <summary>
/// Attempts to add an item to the set. Returns true if adding was successful, false otherwise
/// </summary>
/// <param name="item"></param>
/// <returns></returns>
public bool Add(string item) {
return _backingDictionary.TryAdd(item, byte.MinValue);
}

/// <summary>
/// Attempts to remove an item from the set. Returns true of removing was successful, false otherwise
/// </summary>
/// <param name="item"></param>
/// <returns></returns>
public bool Remove(string item) {
return _backingDictionary.TryRemove(item, out _);
}

/// <summary>
/// Checks if the given item is in the set
/// </summary>
/// <param name="item"></param>
/// <returns></returns>
public bool Contains(string item) {
return _backingDictionary.ContainsKey(item);
}

/// <summary>
/// Returns all values in the set
/// </summary>
/// <returns></returns>
public IEnumerable<string> Values() {
return _backingDictionary.Keys;
}

public void Dispose() {
_backingDictionary = null;
GC.SuppressFinalize(this);
}
}
5 changes: 5 additions & 0 deletions src/CommonLib/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,11 @@ public static IRegistryKey OpenRemoteRegistry(string target) {
CommonOids.SmartcardLogon,
CommonOids.AnyPurpose
};

public static string[] SchannelAuthenticationOIDs = new string[] {
CommonOids.ClientAuthentication,
CommonOids.AnyPurpose
};
}

public class ParsedGPLink {
Expand Down
5 changes: 5 additions & 0 deletions src/CommonLib/ILdapUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,5 +169,10 @@ IAsyncEnumerable<Result<string>> RangedRetrieval(string distinguishedName,
/// <param name="context">The naming context being retrieved</param>
/// <returns>A tuple containing success state as well as the resolved distinguished name if successful</returns>
Task<(bool Success, string Path)> GetNamingContextPath(string domain, NamingContext context);

/// <summary>
/// Resets temporary caches in LDAPUtils
/// </summary>
void ResetUtils();
}
}
Loading

0 comments on commit e3cb8e8

Please sign in to comment.