Skip to content
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

Fixed wildcard file path rules for drive roots #600

Merged
merged 1 commit into from
Feb 15, 2025
Merged
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
11 changes: 9 additions & 2 deletions AppControl Manager/XMLOps/SignerAndHashBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
using System.Collections.Generic;
using System.Linq;
using AppControlManager.IntelGathering;
using AppControlManager.Others;

namespace AppControlManager.XMLOps;

internal static class SignerAndHashBuilder
{
// Get all of the drive letters on the system
private static readonly List<DriveLetterMapper.DriveMapping> Drives = DriveLetterMapper.GetGlobalRootDrives();
private static readonly IEnumerable<string?> DriveLetters = Drives.Select(x => x.DriveLetter);


/// <summary>
/// Creates Signer and Hash objects from the input data
///
Expand Down Expand Up @@ -378,8 +384,9 @@ internal static FileBasedInfoPackage BuildSignerAndHashObjects(

foreach (string item in wildCardFilePathData)
{
// Create wildcard path
string wildcardPath = item + @"\" + "*";

// Create wildcard path - If user selected a root of a drive then do not add the extra backward slash otherwise we'd create an invalid path such as "D:\\*" in the policy
string wildcardPath = DriveLetters.Any(x => string.Equals(x, item[..^1], System.StringComparison.OrdinalIgnoreCase)) ? item + "*" : item + @"\" + "*";

// FilePath rules can only be used for User-Mode files only
// Plus we wouldn't know if the folder contains user-mode or kernel-mode files
Expand Down