Skip to content

Commit f2b89e4

Browse files
🩹 [Patch]: Request confirmation before removing/deleting resources where recovery is difficult/impossible (#465)
This pull request updates multiple PowerShell functions to enhance user safety by adding a `ConfirmImpact = 'High'` attribute to the `[CmdletBinding]` declaration for commands that perform destructive operations. This ensures users are explicitly prompted before executing high-impact actions. Additionally, some minor formatting adjustments are made. - Fixes #184 ### Adjustments to `ConfirmImpact` values: * Updated high-impact function to prompt for confirmation (`ConfirmImpact = 'High'`). * Removed `ConfirmImpact` attribute for functions that have low impact. --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: MariusStorhaug <[email protected]>
1 parent 12288bd commit f2b89e4

File tree

13 files changed

+21
-21
lines changed

13 files changed

+21
-21
lines changed

‎src/functions/public/Artifacts/Remove-GitHubArtifact.ps1‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function Remove-GitHubArtifact {
1+
function Remove-GitHubArtifact {
22
<#
33
.SYNOPSIS
44
Deletes an artifact from a GitHub repository by its unique ID.
@@ -31,7 +31,7 @@
3131
[Delete an artifact](https://docs.github.com/rest/actions/artifacts#delete-an-artifact)
3232
#>
3333
[OutputType([GitHubArtifact])]
34-
[CmdletBinding(SupportsShouldProcess)]
34+
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')]
3535
param(
3636
# The account owner of the repository. The name is not case sensitive.
3737
[Parameter(Mandatory, ValueFromPipelineByPropertyName)]

‎src/functions/public/Environments/Remove-GitHubEnvironment.ps1‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
filter Remove-GitHubEnvironment {
1+
filter Remove-GitHubEnvironment {
22
<#
33
.SYNOPSIS
44
Deletes an environment from a repository.
@@ -19,7 +19,7 @@
1919
[Delete environments](https://docs.github.com/rest/deployments/environments?#delete-an-environment)
2020
#>
2121
[OutputType([void])]
22-
[CmdletBinding(SupportsShouldProcess)]
22+
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')]
2323
param(
2424
# The name of the organization.
2525
[Parameter(Mandatory, ValueFromPipelineByPropertyName)]

‎src/functions/public/Releases/Assets/Remove-GitHubReleaseAsset.ps1‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
filter Remove-GitHubReleaseAsset {
1+
filter Remove-GitHubReleaseAsset {
22
<#
33
.SYNOPSIS
44
Delete a release asset
@@ -20,7 +20,7 @@
2020
.NOTES
2121
[Delete a release asset](https://docs.github.com/rest/releases/assets#delete-a-release-asset)
2222
#>
23-
[CmdletBinding(SupportsShouldProcess)]
23+
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')]
2424
param(
2525
# The account owner of the repository. The name is not case sensitive.
2626
[Parameter(Mandatory)]

‎src/functions/public/Releases/Remove-GitHubRelease.ps1‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
filter Remove-GitHubRelease {
1+
filter Remove-GitHubRelease {
22
<#
33
.SYNOPSIS
44
Delete a release
@@ -24,7 +24,7 @@
2424
[Delete a release](https://docs.github.com/rest/releases/releases#delete-a-release)
2525
#>
2626
[OutputType([void])]
27-
[CmdletBinding(SupportsShouldProcess)]
27+
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')]
2828
param(
2929
# The account owner of the repository. The name is not case sensitive.
3030
[Parameter(Mandatory, ValueFromPipelineByPropertyName)]

‎src/functions/public/Secrets/Remove-GitHubSecret.ps1‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
'PSShouldProcess', '', Scope = 'Function',
3333
Justification = 'This check is performed in the private functions.'
3434
)]
35-
[CmdletBinding(DefaultParameterSetName = 'AuthenticatedUser', SupportsShouldProcess)]
35+
[CmdletBinding(DefaultParameterSetName = 'AuthenticatedUser', SupportsShouldProcess, ConfirmImpact = 'High')]
3636
param (
3737
# The account owner of the repository. The name is not case sensitive.
3838
[Parameter(Mandatory, ParameterSetName = 'Organization', ValueFromPipelineByPropertyName)]

‎src/functions/public/Secrets/SelectedRepository/Remove-GitHubSecretSelectedRepository.ps1‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
Justification = 'Long links'
2929
)]
3030
[OutputType([void])]
31-
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'Low')]
31+
[CmdletBinding(SupportsShouldProcess)]
3232
param(
3333
# The account owner of the repository. The name is not case sensitive.
3434
[Parameter(Mandatory)]

‎src/functions/public/Teams/Remove-GitHubTeam.ps1‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
https://psmodule.io/GitHub/Functions/Teams/Remove-GitHubTeam
1818
#>
1919
[OutputType([void])]
20-
[CmdletBinding(SupportsShouldProcess)]
20+
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')]
2121
param(
2222
# The organization name. The name is not case sensitive.
2323
# If not provided, the organization from the context is used.

‎src/functions/public/Users/GPG-Keys/Remove-GitHubUserGpgKey.ps1‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
filter Remove-GitHubUserGpgKey {
1+
filter Remove-GitHubUserGpgKey {
22
<#
33
.SYNOPSIS
44
Delete a GPG key for the authenticated user
@@ -20,7 +20,7 @@
2020
https://psmodule.io/GitHub/Functions/Users/GPG-Keys/Remove-GitHubUserGpgKey
2121
#>
2222
[OutputType([pscustomobject])]
23-
[CmdletBinding(SupportsShouldProcess)]
23+
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')]
2424
param(
2525
# The ID of the GPG key.
2626
[Parameter(

‎src/functions/public/Users/Keys/Remove-GitHubUserKey.ps1‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
filter Remove-GitHubUserKey {
1+
filter Remove-GitHubUserKey {
22
<#
33
.SYNOPSIS
44
Delete a public SSH key for the authenticated user
@@ -21,7 +21,7 @@
2121
#>
2222
[OutputType([pscustomobject])]
2323
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')]
24-
[CmdletBinding(SupportsShouldProcess)]
24+
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')]
2525
param(
2626
# The unique identifier of the key.
2727
[Parameter(

‎src/functions/public/Users/SSH-Signing-Keys/Remove-GitHubUserSigningKey.ps1‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
filter Remove-GitHubUserSigningKey {
1+
filter Remove-GitHubUserSigningKey {
22
<#
33
.SYNOPSIS
44
Delete an SSH signing key for the authenticated user
@@ -22,7 +22,7 @@
2222
#>
2323
[OutputType([pscustomobject])]
2424
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')]
25-
[CmdletBinding(SupportsShouldProcess)]
25+
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')]
2626
param(
2727
# The unique identifier of the SSH signing key.
2828
[Parameter(

0 commit comments

Comments
 (0)