Skip to content

Commit 7521adc

Browse files
🪲 [Fix]: Set-GitHubOutput using SecureString in GitHub Actions (#258)
## Description This pull request includes updates to the `Set-GitHubOutput` function and its corresponding tests to improve handling of secure strings. ### Enhancements to `Set-GitHubOutput` function: * Removed the `-Force` parameter from the `ConvertFrom-SecureString` command as it does not support the switch. (`src/functions/public/Commands/Set-GitHubOutput.ps1`) ### Improvements in test coverage: * Introduced new test cases to ensure the `Set-GitHubOutput` function handles secure strings and objects correctly without throwing errors. (`tests/GitHub.Tests.ps1`) ## Type of change <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] 📖 [Docs] - [ ] 🪲 [Fix] - [x] 🩹 [Patch] - [ ] ⚠️ [Security fix] - [ ] 🚀 [Feature] - [ ] 🌟 [Breaking change] ## Checklist <!-- Use the check-boxes [x] on the options that are relevant. --> - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas
1 parent b503faf commit 7521adc

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/functions/public/Commands/Set-GitHubOutput.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
$outputs = Get-GitHubOutput -Path $Path -AsHashtable
5151

5252
if ($Value -Is [securestring]) {
53-
$Value = $Value | ConvertFrom-SecureString -AsPlainText -Force
53+
$Value = $Value | ConvertFrom-SecureString -AsPlainText
5454
Add-Mask -Value $Value
5555
}
5656

tests/GitHub.Tests.ps1

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
'PSUseDeclaredVarsMoreThanAssignments', '',
33
Justification = 'Pester grouping syntax: known issue.'
44
)]
5+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
6+
'PSAvoidUsingConvertToSecureStringWithPlainText', '',
7+
Justification = 'Used to create a secure string for testing.'
8+
)]
59
[CmdletBinding()]
610
param()
711

@@ -205,6 +209,17 @@ Describe 'GitHub' {
205209
Set-GitHubOutput -Name 'MyName' -Value 'MyValue'
206210
} | Should -Not -Throw
207211
}
212+
It 'Set-GitHubOutput + SecureString - Should not throw' {
213+
{
214+
$secret = 'MyValue' | ConvertTo-SecureString -AsPlainText -Force
215+
Set-GitHubOutput -Name 'SecretName' -Value $secret
216+
} | Should -Not -Throw
217+
}
218+
It 'Set-GitHubOutput + Object - Should not throw' {
219+
{
220+
Set-GitHubOutput -Name 'Config' -Value (Get-GitHubConfig)
221+
} | Should -Not -Throw
222+
}
208223
It 'Get-GitHubOutput - Should not throw' {
209224
{
210225
Get-GitHubOutput

0 commit comments

Comments
 (0)