public void DirectoryInfo_AnalyzeSecurity_LocalAcess_ShouldNotExist() { var testDir = GetTempDirectoryName(); SetSecuritySystem(testDir); var dirsec = new System.IO.DirectoryInfo(testDir + @"\inherited").GetAccessControl(); var accessRules = dirsec.GetAccessRules(true, true, typeof(System.Security.Principal.SecurityIdentifier)); Assert.IsFalse(HasLocalAces(accessRules), "local access rules found"); testDir = GetTempDirectoryName(); SetSecurityAlpha(testDir); dirsec = new Alphaleonis.Win32.Filesystem.DirectoryInfo(testDir + @"\inherited").GetAccessControl(); accessRules = dirsec.GetAccessRules(true, true, typeof(System.Security.Principal.SecurityIdentifier)); Assert.IsFalse(HasLocalAces(accessRules), "local access rules found"); }
private void AnalyzeDirectoryInfoSecurity_ShouldNotExist(bool isNetwork) { using (var tempRoot = new TemporaryDirectory(isNetwork)) { var folder = tempRoot.CreateDirectory(); Console.WriteLine("Input Directory Path: [{0}]", folder.FullName); SetSecuritySystem(folder.FullName); var dirsec = new System.IO.DirectoryInfo(folder.FullName + @"\inherited").GetAccessControl(); var accessRules = dirsec.GetAccessRules(true, true, typeof(System.Security.Principal.SecurityIdentifier)); UnitTestConstants.Dump(dirsec); Assert.IsFalse(HasLocalAces(accessRules), "Local access rules are found, but it is not expected."); folder = tempRoot.CreateDirectory(); Console.WriteLine("\nInput Directory Path: [{0}]", folder.FullName); SetSecurityAlpha(folder.FullName); dirsec = new Alphaleonis.Win32.Filesystem.DirectoryInfo(folder.FullName + @"\inherited").GetAccessControl(); accessRules = dirsec.GetAccessRules(true, true, typeof(System.Security.Principal.SecurityIdentifier)); UnitTestConstants.Dump(dirsec); Assert.IsFalse(HasLocalAces(accessRules), "Local access rules are found, but it is not expected."); } Console.WriteLine(); }