mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Move the type data definition of System.Security.AccessControl.ObjectSecurity to the Microsoft.PowerShell.Security module (#16355)
This commit is contained in:
@@ -10,5 +10,6 @@ FunctionsToExport = @()
|
||||
CmdletsToExport="Get-Acl", "Set-Acl", "Get-PfxCertificate", "Get-Credential", "Get-ExecutionPolicy", "Set-ExecutionPolicy", "Get-AuthenticodeSignature", "Set-AuthenticodeSignature", "ConvertFrom-SecureString", "ConvertTo-SecureString", "Get-CmsMessage", "Unprotect-CmsMessage", "Protect-CmsMessage" , "New-FileCatalog" , "Test-FileCatalog"
|
||||
AliasesToExport = @()
|
||||
NestedModules="Microsoft.PowerShell.Security.dll"
|
||||
TypesToProcess="Security.types.ps1xml"
|
||||
HelpInfoURI = 'https://aka.ms/powershell73-help'
|
||||
}
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!-- *******************************************************************
|
||||
These sample files contain type information used by the PowerShell engine.
|
||||
Do not edit or change the contents of this file directly.
|
||||
Please see the PowerShell documentation or type "Get-Help Update-TypeData"
|
||||
for more information.
|
||||
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
THIS SAMPLE CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND,WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
|
||||
PURPOSE. IF THIS CODE AND INFORMATION IS MODIFIED, THE ENTIRE RISK OF USE
|
||||
OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE AND INFORMATION
|
||||
REMAINS WITH THE USER.
|
||||
******************************************************************** -->
|
||||
|
||||
<Types>
|
||||
<Type>
|
||||
<Name>System.Security.AccessControl.ObjectSecurity</Name>
|
||||
<Members>
|
||||
<CodeProperty>
|
||||
<Name>Path</Name>
|
||||
<GetCodeReference>
|
||||
<TypeName>Microsoft.PowerShell.Commands.SecurityDescriptorCommandsBase</TypeName>
|
||||
<MethodName>GetPath</MethodName>
|
||||
</GetCodeReference>
|
||||
</CodeProperty>
|
||||
<CodeProperty>
|
||||
<Name>Owner</Name>
|
||||
<GetCodeReference>
|
||||
<TypeName>Microsoft.PowerShell.Commands.SecurityDescriptorCommandsBase</TypeName>
|
||||
<MethodName>GetOwner</MethodName>
|
||||
</GetCodeReference>
|
||||
</CodeProperty>
|
||||
<CodeProperty>
|
||||
<Name>Group</Name>
|
||||
<GetCodeReference>
|
||||
<TypeName>Microsoft.PowerShell.Commands.SecurityDescriptorCommandsBase</TypeName>
|
||||
<MethodName>GetGroup</MethodName>
|
||||
</GetCodeReference>
|
||||
</CodeProperty>
|
||||
<CodeProperty>
|
||||
<Name>Access</Name>
|
||||
<GetCodeReference>
|
||||
<TypeName>Microsoft.PowerShell.Commands.SecurityDescriptorCommandsBase</TypeName>
|
||||
<MethodName>GetAccess</MethodName>
|
||||
</GetCodeReference>
|
||||
</CodeProperty>
|
||||
<CodeProperty>
|
||||
<Name>Sddl</Name>
|
||||
<GetCodeReference>
|
||||
<TypeName>Microsoft.PowerShell.Commands.SecurityDescriptorCommandsBase</TypeName>
|
||||
<MethodName>GetSddl</MethodName>
|
||||
</GetCodeReference>
|
||||
</CodeProperty>
|
||||
<ScriptProperty>
|
||||
<Name>AccessToString</Name>
|
||||
<GetScriptBlock>
|
||||
$toString = "";
|
||||
$first = $true;
|
||||
if ( ! $this.Access ) { return "" }
|
||||
foreach($ace in $this.Access)
|
||||
{
|
||||
if($first)
|
||||
{
|
||||
$first = $false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$tostring += "`n";
|
||||
}
|
||||
$toString += $ace.IdentityReference.ToString();
|
||||
$toString += " ";
|
||||
$toString += $ace.AccessControlType.ToString();
|
||||
$toString += " ";
|
||||
if($ace -is [System.Security.AccessControl.FileSystemAccessRule])
|
||||
{
|
||||
$toString += $ace.FileSystemRights.ToString();
|
||||
}
|
||||
elseif($ace -is [System.Security.AccessControl.RegistryAccessRule])
|
||||
{
|
||||
$toString += $ace.RegistryRights.ToString();
|
||||
}
|
||||
}
|
||||
return $toString;
|
||||
</GetScriptBlock>
|
||||
</ScriptProperty>
|
||||
<ScriptProperty>
|
||||
<Name>AuditToString</Name>
|
||||
<GetScriptBlock>
|
||||
$toString = "";
|
||||
$first = $true;
|
||||
if ( ! (& { Set-StrictMode -Version 1; $this.audit }) ) { return "" }
|
||||
foreach($ace in (& { Set-StrictMode -Version 1; $this.audit }))
|
||||
{
|
||||
if($first)
|
||||
{
|
||||
$first = $false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$tostring += "`n";
|
||||
}
|
||||
$toString += $ace.IdentityReference.ToString();
|
||||
$toString += " ";
|
||||
$toString += $ace.AuditFlags.ToString();
|
||||
$toString += " ";
|
||||
if($ace -is [System.Security.AccessControl.FileSystemAuditRule])
|
||||
{
|
||||
$toString += $ace.FileSystemRights.ToString();
|
||||
}
|
||||
elseif($ace -is [System.Security.AccessControl.RegistryAuditRule])
|
||||
{
|
||||
$toString += $ace.RegistryRights.ToString();
|
||||
}
|
||||
}
|
||||
return $toString;
|
||||
</GetScriptBlock>
|
||||
</ScriptProperty>
|
||||
</Members>
|
||||
</Type>
|
||||
|
||||
</Types>
|
||||
@@ -4081,152 +4081,6 @@ namespace System.Management.Automation.Runspaces
|
||||
|
||||
#endregion System.Management.ManagementObject
|
||||
|
||||
#region System.Security.AccessControl.ObjectSecurity
|
||||
|
||||
typeName = @"System.Security.AccessControl.ObjectSecurity";
|
||||
typeMembers = _extendedMembers.GetOrAdd(typeName, static key => new PSMemberInfoInternalCollection<PSMemberInfo>(capacity: 7));
|
||||
Type securityDescriptorCommandsBaseType = TypeResolver.ResolveType("Microsoft.PowerShell.Commands.SecurityDescriptorCommandsBase", exception: out _);
|
||||
|
||||
// Process regular members.
|
||||
newMembers.Add(@"Path");
|
||||
AddMember(
|
||||
errors,
|
||||
typeName,
|
||||
new PSCodeProperty(
|
||||
@"Path",
|
||||
GetMethodInfo(securityDescriptorCommandsBaseType, @"GetPath"),
|
||||
setterCodeReference: null),
|
||||
typeMembers,
|
||||
isOverride: false);
|
||||
|
||||
newMembers.Add(@"Owner");
|
||||
AddMember(
|
||||
errors,
|
||||
typeName,
|
||||
new PSCodeProperty(
|
||||
@"Owner",
|
||||
GetMethodInfo(securityDescriptorCommandsBaseType, @"GetOwner"),
|
||||
setterCodeReference: null),
|
||||
typeMembers,
|
||||
isOverride: false);
|
||||
|
||||
newMembers.Add(@"Group");
|
||||
AddMember(
|
||||
errors,
|
||||
typeName,
|
||||
new PSCodeProperty(
|
||||
@"Group",
|
||||
GetMethodInfo(securityDescriptorCommandsBaseType, @"GetGroup"),
|
||||
setterCodeReference: null),
|
||||
typeMembers,
|
||||
isOverride: false);
|
||||
|
||||
newMembers.Add(@"Access");
|
||||
AddMember(
|
||||
errors,
|
||||
typeName,
|
||||
new PSCodeProperty(
|
||||
@"Access",
|
||||
GetMethodInfo(securityDescriptorCommandsBaseType, @"GetAccess"),
|
||||
setterCodeReference: null),
|
||||
typeMembers,
|
||||
isOverride: false);
|
||||
|
||||
newMembers.Add(@"Sddl");
|
||||
AddMember(
|
||||
errors,
|
||||
typeName,
|
||||
new PSCodeProperty(
|
||||
@"Sddl",
|
||||
GetMethodInfo(securityDescriptorCommandsBaseType, @"GetSddl"),
|
||||
setterCodeReference: null),
|
||||
typeMembers,
|
||||
isOverride: false);
|
||||
|
||||
newMembers.Add(@"AccessToString");
|
||||
AddMember(
|
||||
errors,
|
||||
typeName,
|
||||
new PSScriptProperty(
|
||||
@"AccessToString",
|
||||
GetScriptBlock(@"$toString = """";
|
||||
$first = $true;
|
||||
if ( ! $this.Access ) { return """" }
|
||||
|
||||
foreach($ace in $this.Access)
|
||||
{
|
||||
if($first)
|
||||
{
|
||||
$first = $false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$tostring += ""`n"";
|
||||
}
|
||||
|
||||
$toString += $ace.IdentityReference.ToString();
|
||||
$toString += "" "";
|
||||
$toString += $ace.AccessControlType.ToString();
|
||||
$toString += "" "";
|
||||
if($ace -is [System.Security.AccessControl.FileSystemAccessRule])
|
||||
{
|
||||
$toString += $ace.FileSystemRights.ToString();
|
||||
}
|
||||
elseif($ace -is [System.Security.AccessControl.RegistryAccessRule])
|
||||
{
|
||||
$toString += $ace.RegistryRights.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
return $toString;"),
|
||||
setterScript: null,
|
||||
shouldCloneOnAccess: true),
|
||||
typeMembers,
|
||||
isOverride: false);
|
||||
|
||||
newMembers.Add(@"AuditToString");
|
||||
AddMember(
|
||||
errors,
|
||||
typeName,
|
||||
new PSScriptProperty(
|
||||
@"AuditToString",
|
||||
GetScriptBlock(@"$toString = """";
|
||||
$first = $true;
|
||||
if ( ! (& { Set-StrictMode -Version 1; $this.audit }) ) { return """" }
|
||||
|
||||
foreach($ace in (& { Set-StrictMode -Version 1; $this.audit }))
|
||||
{
|
||||
if($first)
|
||||
{
|
||||
$first = $false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$tostring += ""`n"";
|
||||
}
|
||||
|
||||
$toString += $ace.IdentityReference.ToString();
|
||||
$toString += "" "";
|
||||
$toString += $ace.AuditFlags.ToString();
|
||||
$toString += "" "";
|
||||
if($ace -is [System.Security.AccessControl.FileSystemAuditRule])
|
||||
{
|
||||
$toString += $ace.FileSystemRights.ToString();
|
||||
}
|
||||
elseif($ace -is [System.Security.AccessControl.RegistryAuditRule])
|
||||
{
|
||||
$toString += $ace.RegistryRights.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
return $toString;"),
|
||||
setterScript: null,
|
||||
shouldCloneOnAccess: true),
|
||||
typeMembers,
|
||||
isOverride: false);
|
||||
|
||||
#endregion System.Security.AccessControl.ObjectSecurity
|
||||
|
||||
#region Microsoft.PowerShell.Commands.HistoryInfo
|
||||
|
||||
typeName = @"Microsoft.PowerShell.Commands.HistoryInfo";
|
||||
|
||||
@@ -15,7 +15,6 @@ Describe "Validate start of console host" -Tag CI {
|
||||
'pwsh.dll'
|
||||
'System.Collections.Concurrent.dll'
|
||||
'System.Collections.dll'
|
||||
'System.Collections.NonGeneric.dll'
|
||||
'System.Collections.Specialized.dll'
|
||||
'System.ComponentModel.dll'
|
||||
'System.ComponentModel.Primitives.dll'
|
||||
|
||||
@@ -19,9 +19,9 @@ Describe "Built-in type information tests" -Tag "CI" {
|
||||
|
||||
It "Should have correct number of built-in type items in type table" {
|
||||
$expected = if ($IsWindows) {
|
||||
273
|
||||
} else {
|
||||
272
|
||||
} else {
|
||||
271
|
||||
}
|
||||
$types.Count | Should -BeExactly $expected
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user