Apply NTFS level filters to data area creation

This commit is contained in:
Meik
2026-07-09 22:53:47 +02:00
parent 3ca1a41816
commit e8b138f9c3
2 changed files with 34 additions and 13 deletions

View File

@@ -1105,15 +1105,25 @@ namespace C4IT.LIAM
}
public Task<ResultToken> CreateDataAreaAsync(
string newFolderPath,
string newFolderParent,
IDictionary<string, string> customTags,
IEnumerable<string> ownerSids,
IEnumerable<string> readerSids,
IEnumerable<string> writerSids,
bool whatIf = false
)
string newFolderPath,
string newFolderParent,
IDictionary<string, string> customTags,
IEnumerable<string> ownerSids,
IEnumerable<string> readerSids,
IEnumerable<string> writerSids,
bool whatIf = false)
{
var classification = ClassifyPath(newFolderPath);
string levelSkipReason;
if (!IsCreateDataAreaLevelManagedPath(classification, out levelSkipReason))
{
return Task.FromResult(new ResultToken(System.Reflection.MethodBase.GetCurrentMethod().ToString())
{
resultErrorId = 30008,
resultMessage = levelSkipReason
});
}
var engine = CreateFilesystemEngine(
newFolderPath,
newFolderParent,
@@ -1456,6 +1466,15 @@ namespace C4IT.LIAM
out skipReason);
}
private bool IsCreateDataAreaLevelManagedPath(cNtfsPathClassification classification, out string skipReason)
{
return IsLevelManagedPath(
classification,
GetPermissionLevelRange(),
"create data area",
out skipReason);
}
private bool IsTraverseLevelManagedPath(cNtfsPathClassification classification, out string skipReason)
{
return IsLevelManagedPath(
@@ -1468,15 +1487,15 @@ namespace C4IT.LIAM
private bool IsLevelManagedPath(cNtfsPathClassification classification, cNtfsLevelRange range, string operationName, out string skipReason)
{
skipReason = string.Empty;
if (range == null || !range.IsConfigured)
return true;
if (classification == null)
{
skipReason = $"NTFS {operationName} skipped because the path could not be classified.";
return false;
}
if (range == null || !range.IsConfigured)
return true;
if (!range.IsValid)
{
skipReason = $"NTFS {operationName} skipped for '{classification.NormalizedPath}' because {range.ErrorMessage}";