Skip to content

Commit 08e4596

Browse files
authored
Move the type data definition of System.Security.AccessControl.ObjectSecurity to the Microsoft.PowerShell.Security module (PowerShell#16355)
1 parent 7ce0df7 commit 08e4596

File tree

5 files changed

+127
-149
lines changed

5 files changed

+127
-149
lines changed

src/Modules/Windows/Microsoft.PowerShell.Security/Microsoft.PowerShell.Security.psd1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ FunctionsToExport = @()
1010
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"
1111
AliasesToExport = @()
1212
NestedModules="Microsoft.PowerShell.Security.dll"
13+
TypesToProcess="Security.types.ps1xml"
1314
HelpInfoURI = 'https://aka.ms/powershell73-help'
1415
}
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<!-- *******************************************************************
3+
These sample files contain type information used by the PowerShell engine.
4+
Do not edit or change the contents of this file directly.
5+
Please see the PowerShell documentation or type "Get-Help Update-TypeData"
6+
for more information.
7+
8+
Copyright (c) Microsoft Corporation.
9+
10+
THIS SAMPLE CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
11+
OF ANY KIND,WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
12+
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
13+
PURPOSE. IF THIS CODE AND INFORMATION IS MODIFIED, THE ENTIRE RISK OF USE
14+
OR RESULTS IN CONNECTION WITH THE USE OF THIS CODE AND INFORMATION
15+
REMAINS WITH THE USER.
16+
******************************************************************** -->
17+
18+
<Types>
19+
<Type>
20+
<Name>System.Security.AccessControl.ObjectSecurity</Name>
21+
<Members>
22+
<CodeProperty>
23+
<Name>Path</Name>
24+
<GetCodeReference>
25+
<TypeName>Microsoft.PowerShell.Commands.SecurityDescriptorCommandsBase</TypeName>
26+
<MethodName>GetPath</MethodName>
27+
</GetCodeReference>
28+
</CodeProperty>
29+
<CodeProperty>
30+
<Name>Owner</Name>
31+
<GetCodeReference>
32+
<TypeName>Microsoft.PowerShell.Commands.SecurityDescriptorCommandsBase</TypeName>
33+
<MethodName>GetOwner</MethodName>
34+
</GetCodeReference>
35+
</CodeProperty>
36+
<CodeProperty>
37+
<Name>Group</Name>
38+
<GetCodeReference>
39+
<TypeName>Microsoft.PowerShell.Commands.SecurityDescriptorCommandsBase</TypeName>
40+
<MethodName>GetGroup</MethodName>
41+
</GetCodeReference>
42+
</CodeProperty>
43+
<CodeProperty>
44+
<Name>Access</Name>
45+
<GetCodeReference>
46+
<TypeName>Microsoft.PowerShell.Commands.SecurityDescriptorCommandsBase</TypeName>
47+
<MethodName>GetAccess</MethodName>
48+
</GetCodeReference>
49+
</CodeProperty>
50+
<CodeProperty>
51+
<Name>Sddl</Name>
52+
<GetCodeReference>
53+
<TypeName>Microsoft.PowerShell.Commands.SecurityDescriptorCommandsBase</TypeName>
54+
<MethodName>GetSddl</MethodName>
55+
</GetCodeReference>
56+
</CodeProperty>
57+
<ScriptProperty>
58+
<Name>AccessToString</Name>
59+
<GetScriptBlock>
60+
$toString = "";
61+
$first = $true;
62+
if ( ! $this.Access ) { return "" }
63+
foreach($ace in $this.Access)
64+
{
65+
if($first)
66+
{
67+
$first = $false;
68+
}
69+
else
70+
{
71+
$tostring += "`n";
72+
}
73+
$toString += $ace.IdentityReference.ToString();
74+
$toString += " ";
75+
$toString += $ace.AccessControlType.ToString();
76+
$toString += " ";
77+
if($ace -is [System.Security.AccessControl.FileSystemAccessRule])
78+
{
79+
$toString += $ace.FileSystemRights.ToString();
80+
}
81+
elseif($ace -is [System.Security.AccessControl.RegistryAccessRule])
82+
{
83+
$toString += $ace.RegistryRights.ToString();
84+
}
85+
}
86+
return $toString;
87+
</GetScriptBlock>
88+
</ScriptProperty>
89+
<ScriptProperty>
90+
<Name>AuditToString</Name>
91+
<GetScriptBlock>
92+
$toString = "";
93+
$first = $true;
94+
if ( ! (&amp; { Set-StrictMode -Version 1; $this.audit }) ) { return "" }
95+
foreach($ace in (&amp; { Set-StrictMode -Version 1; $this.audit }))
96+
{
97+
if($first)
98+
{
99+
$first = $false;
100+
}
101+
else
102+
{
103+
$tostring += "`n";
104+
}
105+
$toString += $ace.IdentityReference.ToString();
106+
$toString += " ";
107+
$toString += $ace.AuditFlags.ToString();
108+
$toString += " ";
109+
if($ace -is [System.Security.AccessControl.FileSystemAuditRule])
110+
{
111+
$toString += $ace.FileSystemRights.ToString();
112+
}
113+
elseif($ace -is [System.Security.AccessControl.RegistryAuditRule])
114+
{
115+
$toString += $ace.RegistryRights.ToString();
116+
}
117+
}
118+
return $toString;
119+
</GetScriptBlock>
120+
</ScriptProperty>
121+
</Members>
122+
</Type>
123+
124+
</Types>

src/System.Management.Automation/engine/TypeTable_Types_Ps1Xml.cs

Lines changed: 0 additions & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -4081,152 +4081,6 @@ private void Process_Types_Ps1Xml(string filePath, ConcurrentBag<string> errors)
40814081

40824082
#endregion System.Management.ManagementObject
40834083

4084-
#region System.Security.AccessControl.ObjectSecurity
4085-
4086-
typeName = @"System.Security.AccessControl.ObjectSecurity";
4087-
typeMembers = _extendedMembers.GetOrAdd(typeName, static key => new PSMemberInfoInternalCollection<PSMemberInfo>(capacity: 7));
4088-
Type securityDescriptorCommandsBaseType = TypeResolver.ResolveType("Microsoft.PowerShell.Commands.SecurityDescriptorCommandsBase", exception: out _);
4089-
4090-
// Process regular members.
4091-
newMembers.Add(@"Path");
4092-
AddMember(
4093-
errors,
4094-
typeName,
4095-
new PSCodeProperty(
4096-
@"Path",
4097-
GetMethodInfo(securityDescriptorCommandsBaseType, @"GetPath"),
4098-
setterCodeReference: null),
4099-
typeMembers,
4100-
isOverride: false);
4101-
4102-
newMembers.Add(@"Owner");
4103-
AddMember(
4104-
errors,
4105-
typeName,
4106-
new PSCodeProperty(
4107-
@"Owner",
4108-
GetMethodInfo(securityDescriptorCommandsBaseType, @"GetOwner"),
4109-
setterCodeReference: null),
4110-
typeMembers,
4111-
isOverride: false);
4112-
4113-
newMembers.Add(@"Group");
4114-
AddMember(
4115-
errors,
4116-
typeName,
4117-
new PSCodeProperty(
4118-
@"Group",
4119-
GetMethodInfo(securityDescriptorCommandsBaseType, @"GetGroup"),
4120-
setterCodeReference: null),
4121-
typeMembers,
4122-
isOverride: false);
4123-
4124-
newMembers.Add(@"Access");
4125-
AddMember(
4126-
errors,
4127-
typeName,
4128-
new PSCodeProperty(
4129-
@"Access",
4130-
GetMethodInfo(securityDescriptorCommandsBaseType, @"GetAccess"),
4131-
setterCodeReference: null),
4132-
typeMembers,
4133-
isOverride: false);
4134-
4135-
newMembers.Add(@"Sddl");
4136-
AddMember(
4137-
errors,
4138-
typeName,
4139-
new PSCodeProperty(
4140-
@"Sddl",
4141-
GetMethodInfo(securityDescriptorCommandsBaseType, @"GetSddl"),
4142-
setterCodeReference: null),
4143-
typeMembers,
4144-
isOverride: false);
4145-
4146-
newMembers.Add(@"AccessToString");
4147-
AddMember(
4148-
errors,
4149-
typeName,
4150-
new PSScriptProperty(
4151-
@"AccessToString",
4152-
GetScriptBlock(@"$toString = """";
4153-
$first = $true;
4154-
if ( ! $this.Access ) { return """" }
4155-
4156-
foreach($ace in $this.Access)
4157-
{
4158-
if($first)
4159-
{
4160-
$first = $false;
4161-
}
4162-
else
4163-
{
4164-
$tostring += ""`n"";
4165-
}
4166-
4167-
$toString += $ace.IdentityReference.ToString();
4168-
$toString += "" "";
4169-
$toString += $ace.AccessControlType.ToString();
4170-
$toString += "" "";
4171-
if($ace -is [System.Security.AccessControl.FileSystemAccessRule])
4172-
{
4173-
$toString += $ace.FileSystemRights.ToString();
4174-
}
4175-
elseif($ace -is [System.Security.AccessControl.RegistryAccessRule])
4176-
{
4177-
$toString += $ace.RegistryRights.ToString();
4178-
}
4179-
}
4180-
4181-
return $toString;"),
4182-
setterScript: null,
4183-
shouldCloneOnAccess: true),
4184-
typeMembers,
4185-
isOverride: false);
4186-
4187-
newMembers.Add(@"AuditToString");
4188-
AddMember(
4189-
errors,
4190-
typeName,
4191-
new PSScriptProperty(
4192-
@"AuditToString",
4193-
GetScriptBlock(@"$toString = """";
4194-
$first = $true;
4195-
if ( ! (& { Set-StrictMode -Version 1; $this.audit }) ) { return """" }
4196-
4197-
foreach($ace in (& { Set-StrictMode -Version 1; $this.audit }))
4198-
{
4199-
if($first)
4200-
{
4201-
$first = $false;
4202-
}
4203-
else
4204-
{
4205-
$tostring += ""`n"";
4206-
}
4207-
4208-
$toString += $ace.IdentityReference.ToString();
4209-
$toString += "" "";
4210-
$toString += $ace.AuditFlags.ToString();
4211-
$toString += "" "";
4212-
if($ace -is [System.Security.AccessControl.FileSystemAuditRule])
4213-
{
4214-
$toString += $ace.FileSystemRights.ToString();
4215-
}
4216-
elseif($ace -is [System.Security.AccessControl.RegistryAuditRule])
4217-
{
4218-
$toString += $ace.RegistryRights.ToString();
4219-
}
4220-
}
4221-
4222-
return $toString;"),
4223-
setterScript: null,
4224-
shouldCloneOnAccess: true),
4225-
typeMembers,
4226-
isOverride: false);
4227-
4228-
#endregion System.Security.AccessControl.ObjectSecurity
4229-
42304084
#region Microsoft.PowerShell.Commands.HistoryInfo
42314085

42324086
typeName = @"Microsoft.PowerShell.Commands.HistoryInfo";

test/powershell/Host/Startup.Tests.ps1

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ Describe "Validate start of console host" -Tag CI {
1515
'pwsh.dll'
1616
'System.Collections.Concurrent.dll'
1717
'System.Collections.dll'
18-
'System.Collections.NonGeneric.dll'
1918
'System.Collections.Specialized.dll'
2019
'System.ComponentModel.dll'
2120
'System.ComponentModel.Primitives.dll'

test/powershell/engine/ETS/TypeTable.Tests.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ Describe "Built-in type information tests" -Tag "CI" {
1919

2020
It "Should have correct number of built-in type items in type table" {
2121
$expected = if ($IsWindows) {
22-
273
23-
} else {
2422
272
23+
} else {
24+
271
2525
}
2626
$types.Count | Should -BeExactly $expected
2727
}

0 commit comments

Comments
 (0)