Skip to content

Commit

Permalink
Merge pull request #138 from webmd-health-services/bugfix/internal-us…
Browse files Browse the repository at this point in the history
…ages-show-refactored-warning

Fixed: internal usages of registry functions show refactored warning …
  • Loading branch information
splatteredbits authored Aug 18, 2023
2 parents 775a63f + 4b735f6 commit 5badde7
Show file tree
Hide file tree
Showing 11 changed files with 114 additions and 102 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@

# Carbon Changelog

## 2.15.1

> Released 17 Aug 2023
Fixed: warnings written about registry functions moving to new module that users can't do anything to remove (from
internal usages).


## 2.15.0

> Released 16 Aug 2023
Expand Down
2 changes: 1 addition & 1 deletion Carbon/Carbon.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
RootModule = 'Carbon.psm1'

# Version number of this module.
ModuleVersion = '2.15.0'
ModuleVersion = '2.15.1'

# ID used to uniquely identify this module
GUID = '075d9444-c01b-48c3-889a-0b3490716fa2'
Expand Down
12 changes: 6 additions & 6 deletions Carbon/Carbon.psm1.Import.Obsolete.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ function Get-CRegistryKeyValue
-ModuleName 'Carbon.Registry'
}

if( -not (Test-CRegistryKeyValue -Path $Path -Name $Name) )
if( -not (Test-CRegistryKeyValue -Path $Path -Name $Name -NoWarn) )
{
return $null
}
Expand Down Expand Up @@ -2680,7 +2680,7 @@ function Remove-CRegistryKeyValue
-ModuleName 'Carbon.Registry'
}

if( (Test-CRegistryKeyValue -Path $Path -Name $Name) )
if( (Test-CRegistryKeyValue -Path $Path -Name $Name -NoWarn) )
{
if( $pscmdlet.ShouldProcess( ('Item: {0} Property: {1}' -f $Path,$Name), 'Remove Property' ) )
{
Expand Down Expand Up @@ -3103,16 +3103,16 @@ function Set-CRegistryKeyValue
'MultiString' { $value = $Strings }
}

Install-CRegistryKey -Path $Path
Install-CRegistryKey -Path $Path -NoWarn

if( $Force )
{
Remove-CRegistryKeyValue -Path $Path -Name $Name
Remove-CRegistryKeyValue -Path $Path -Name $Name -NoWarn
}

if( Test-CRegistryKeyValue -Path $Path -Name $Name )
if( Test-CRegistryKeyValue -Path $Path -Name $Name -NoWarn )
{
$currentValue = Get-CRegistryKeyValue -Path $Path -Name $Name
$currentValue = Get-CRegistryKeyValue -Path $Path -Name $Name -NoWarn
if( $currentValue -ne $value )
{
Write-Verbose -Message ("[{0}@{1}] {2} -> {3}'" -f $Path,$Name,$currentValue,$value)
Expand Down
10 changes: 5 additions & 5 deletions Carbon/Functions/Disable-IEEnhancedSecurityConfiguration.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ function Disable-CIEEnhancedSecurityConfiguration
{
<#
.SYNOPSIS
Disables Internet Explorer's Enhanced Security Configuration.
Disables Internet Explorer's Enhanced Security Configuration.
.DESCRIPTION
By default, Windows locks down Internet Explorer so that users can't visit certain sites. This function disables that enhanced security. This is necessary if you have automated processes that need to run and interact with Internet Explorer.
You may also need to call `Enable-CIEActivationPermission`, so that processes have permission to start Internet Explorer.
.EXAMPLE
Disable-CIEEnhancedSecurityConfiguration
.LINK
Expand Down Expand Up @@ -40,13 +40,13 @@ function Disable-CIEEnhancedSecurityConfiguration
Write-Warning ('Applying Enhanced Security Configuration registry key ''{0}'' not found.' -f $hklmPath)
return
}
Set-CRegistryKeyValue -Path $hklmPath -Name 'IsInstalled' -DWord 0
Set-CRegistryKeyValue -Path $hklmPath -Name 'IsInstalled' -DWord 0 -NoWarn
}

Write-Verbose ('Calling iesetup.dll hardening methods.')
Rundll32 iesetup.dll, IEHardenLMSettings
Rundll32 iesetup.dll, IEHardenUser
Rundll32 iesetup.dll, IEHardenAdmin
Rundll32 iesetup.dll, IEHardenAdmin

foreach( $path in $paths )
{
Expand Down
14 changes: 7 additions & 7 deletions Carbon/Functions/Enable-IEActivationPermission.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ function Enable-CIEActivationPermission
<#
.SYNOPSIS
Grants all users permission to start/launch Internet Explorer.
.DESCRIPTION
By default, unprivileged users can't launch/start Internet Explorer. This prevents those users from using Internet Explorer to run automated, browser-based tests. This function modifies Windows so that all users can launch Internet Explorer.
You may also need to call Disable-CIEEnhancedSecurityConfiguration, so that Internet Explorer is allowed to visit all websites.
.EXAMPLE
Enable-CIEActivationPermission
Expand All @@ -36,11 +36,11 @@ function Enable-CIEActivationPermission

if( $PSCmdlet.ShouldProcess( 'Internet Explorer', 'enabling launch and activation permission' ) )
{
Set-CRegistryKeyValue -Path $ieRegPath -Name '(Default)' -String "Internet Explorer(Ver 1.0)"
Set-CRegistryKeyValue -Path $ieRegPath64 -Name '(Default)' -String "Internet Explorer(Ver 1.0)"
Set-CRegistryKeyValue -Path $ieRegPath -Name '(Default)' -String "Internet Explorer(Ver 1.0)" -NoWarn
Set-CRegistryKeyValue -Path $ieRegPath64 -Name '(Default)' -String "Internet Explorer(Ver 1.0)" -NoWarn

Set-CRegistryKeyValue -Path $ieRegPath -Name 'LaunchPermission' -Binary $binarySD.binarySD
Set-CRegistryKeyValue -Path $ieRegPath64 -Name 'LaunchPermission' -Binary $binarySD.binarySD
Set-CRegistryKeyValue -Path $ieRegPath -Name 'LaunchPermission' -Binary $binarySD.binarySD -NoWarn
Set-CRegistryKeyValue -Path $ieRegPath64 -Name 'LaunchPermission' -Binary $binarySD.binarySD -NoWarn
}
}

Expand Down
48 changes: 24 additions & 24 deletions Carbon/Functions/Get-ComSecurityDescriptor.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,41 @@ function Get-CComSecurityDescriptor
<#
.SYNOPSIS
Gets a WMI Win32_SecurityDescriptor default security or security limits object for COM Access or Launch and Activation permissions.
.DESCRIPTION
There are four available security descriptors. Default security and security limits for Access Permissions and Launch and Activation Permissions. This method returns a Win32_SecurityDescriptor for the given area and security type.
The `AsComAccessRule` parameter will return a `Carbon.Security.ComAccessRule` object for each of the access control entries in the security descriptor's ACL.
.LINK
http://msdn.microsoft.com/en-us/library/windows/desktop/aa394402.aspx
.LINK
Get-CComPermission
.EXAMPLE
Get-CComSecurityDescriptor -Access -Default
Gets the default security descriptor for COM Access Permissions.
.EXAMPLE
Get-CComSecurityDescriptor -Access -Limits
Gets the security limits descriptor for COM Access Permissions.
.EXAMPLE
Get-CComSecurityDescriptor -LaunchAndActivation -Default
Gets the default security descriptor for COM Launch and Activation Permissions.
.EXAMPLE
Get-CComSecurityDescriptor -LaunchAndActivation -Limits
Gets the security limits descriptor for COM Launch and Activation Permissions.
.EXAMPLE
Get-CComSecurityDescriptor -Access -Default -AsComAccessRule
Returns a `Carbon.Security.ComAccessRule` object for each of the access control entries in the Access Permissions's default security descriptor.
#>
[CmdletBinding()]
Expand All @@ -48,38 +48,38 @@ function Get-CComSecurityDescriptor
[Switch]
# Returns a securty descriptor for one of the Access Permissions security types.
$Access,

[Parameter(Mandatory=$true,ParameterSetName='DefaultLaunchPermission')]
[Parameter(Mandatory=$true,ParameterSetName='MachineLaunchRestriction')]
[Switch]
# Returns a security descriptor for one of the Launch and Activation Permissions security types.
$LaunchAndActivation,

[Parameter(Mandatory=$true,ParameterSetName='DefaultAccessPermission')]
[Parameter(Mandatory=$true,ParameterSetName='DefaultLaunchPermission')]
[Switch]
# Returns the default security descriptor.
$Default,

[Parameter(Mandatory=$true,ParameterSetName='MachineAccessRestriction')]
[Parameter(Mandatory=$true,ParameterSetName='MachineLaunchRestriction')]
[Switch]
# Returns the security limits descriptor.
$Limits,

[Switch]
# Returns `Carbon.Security.ComAccessRule` objects instead of a security descriptor.
$AsComAccessRule
)

Set-StrictMode -Version 'Latest'

Use-CallerPreference -Cmdlet $PSCmdlet -Session $ExecutionContext.SessionState

$regValueName = $pscmdlet.ParameterSetName
$bytes = Get-CRegistryKeyValue -Path $ComRegKeyPath -Name $regValueName

$bytes = Get-CRegistryKeyValue -Path $ComRegKeyPath -Name $regValueName -NoWarn

$converter = New-Object Management.ManagementClass 'Win32_SecurityDescriptorHelper'

if( -not $bytes -and $pscmdlet.ParameterSetName -eq 'DefaultAccessPermission')
Expand All @@ -95,18 +95,18 @@ function Get-CComSecurityDescriptor
{
$sd = $converter.BinarySDToWin32SD( $bytes )
}

if( $AsComAccessRule )
{
$sd.Descriptor.DACL |
$sd.Descriptor.DACL |
ForEach-Object {

if( -not $_.Trustee.Domain -and -not $_.Trustee.Name )
{
Write-Debug ('Unresolved trustee: SID: {0}' -f $_.Trustee.SidString)
return
}

$identity = New-Object Security.Principal.NTAccount $_.Trustee.Domain,$_.Trustee.Name
$rights = [Carbon.Security.ComAccessRights]$_.AccessMask
$controlType = [Security.AccessControl.AccessControlType]$_.AceType
Expand Down
Loading

0 comments on commit 5badde7

Please sign in to comment.