-
Notifications
You must be signed in to change notification settings - Fork 180
Hide default values from workflow dispatch input #2033
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
fcff18b
b68121a
93b49b7
9934749
a3ae71b
aec01d3
018b008
79e8844
dcc40cb
13a6644
1c7bd03
28f5697
7be5ec9
1c4b190
de397ec
ef398c8
8e6d97a
e2fe4f1
a9ebdd1
6b826f2
84f6b53
f1ada94
ac3720c
09dc9b5
2a862c0
ddcc482
cada39f
df27829
3f02f9d
29b1cd5
2c4bf3c
f1cee93
2511b24
a681ffd
474a6fd
627c802
a5c92b5
d164158
dd7870b
604c5ce
52e65f4
055b133
a8bd32f
cd4e95d
32b10d4
3b94405
207f133
322bfb8
a400606
46adbd0
ee37a84
756a85c
2e23e48
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -330,10 +330,36 @@ function ApplyWorkflowDefaultInputs { | |||||||||||||||||
| return | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| # Helper to convert values to GitHub expression literals | ||||||||||||||||||
| $convertToExpressionLiteral = { | ||||||||||||||||||
| param($value) | ||||||||||||||||||
|
|
||||||||||||||||||
| if ($value -is [bool]) { | ||||||||||||||||||
| return $value.ToString().ToLower() | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| if ($value -is [int] -or $value -is [long] -or $value -is [System.Int16] -or $value -is [byte] -or $value -is [System.SByte] -or $value -is [System.UInt16] -or $value -is [System.UInt32] -or $value -is [System.UInt64]) { | ||||||||||||||||||
| return $value.ToString() | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| if ($value -is [double] -or $value -is [single] -or $value -is [decimal]) { | ||||||||||||||||||
| return $value.ToString([System.Globalization.CultureInfo]::InvariantCulture) | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| $escapedValue = ($value -as [string]) -replace "'", "''" | ||||||||||||||||||
| return "'$escapedValue'" | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| $inputsToHide = @{} | ||||||||||||||||||
|
|
||||||||||||||||||
| # Apply defaults to matching inputs | ||||||||||||||||||
| foreach ($default in $repoSettings.workflowDefaultInputs) { | ||||||||||||||||||
| $inputName = $default.name | ||||||||||||||||||
| $defaultValue = $default.value | ||||||||||||||||||
| $hideInput = $false | ||||||||||||||||||
| if ($default['hide']) { | ||||||||||||||||||
| $hideInput = [bool]$default.hide | ||||||||||||||||||
| } | ||||||||||||||||||
|
Comment on lines
+359
to
+362
|
||||||||||||||||||
| $hideInput = $false | |
| if ($default['hide']) { | |
| $hideInput = [bool]$default.hide | |
| } | |
| $hideInput = $false | |
| if ($default['hide']) { | |
| $hideInput = [bool]$default.hide | |
| } |
Copilot
AI
Dec 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regex patterns are constructed using unescaped input names ($inputName) when replacing hidden input references, e.g., "${{\sgithub.event.inputs.$inputName\s}}"and"(?<!.)inputs.$inputName\b(?!.)". If an input name contains regex metacharacters (like . * + ? ( ) [ ] |), this can cause overbroad or malformed matches and unintended replacements across the workflow, enabling an attacker who controls workflow input names to tamper with workflow logic. Fix by escaping $inputNamefor regex (e.g., using[Regex]::Escape($inputName)`) before interpolating it into patterns:
$escaped = [Regex]::Escape($inputName)
$pattern1 = "`\$\{\{\s*github\.event\.inputs\.$escaped\s*\}\}"
$pattern2 = "(?<!\.)inputs\.$escaped\b(?!\.)"Also ensure any other regex constructions using input-derived values apply the same escaping.
Copilot
AI
Dec 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regex pattern "(?<!\.)inputs\.$inputName\b(?!\.)" embeds $inputName without regex escaping. If the input name includes regex metacharacters, it can match unintended substrings (e.g., parts of job/step output references or other content) and replace them with attacker-controlled values, corrupting workflow logic. Fix by escaping the name: "(?<!\.)inputs\.[Regex]::Escape($inputName)\b(?!\.)" or build the pattern using $escaped = [Regex]::Escape($inputName) and then interpolate $escaped.
| $pattern = "(?<!\.)inputs\.$inputName\b(?!\.)" | |
| $escapedInputName = [Regex]::Escape($inputName) | |
| $pattern = "(?<!\.)inputs\.$escapedInputName\b(?!\.)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent indentation: Line 754 has improper closing of the "value" property (extra spaces before the closing brace). The line should be:
},instead of:
},This maintains consistent indentation with the surrounding JSON properties.