Skip to content

Commit 58cef75

Browse files
vaindclaude
andcommitted
Add dependency name validation in update-dependency.ps1
Added validation to ensure CMake dependency names follow proper naming conventions and prevent potential regex injection attacks. Dependency names must start with a letter and contain only alphanumeric characters, underscores, dots, or hyphens. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent df907ad commit 58cef75

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

updater/scripts/update-dependency.ps1

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,14 @@ Set-StrictMode -Version latest
2020
. "$PSScriptRoot/common.ps1"
2121

2222
# Parse CMake file with dependency name
23-
if ($Path -match '^(.+\.cmake)(#.+)?$') {
23+
if ($Path -match '^(.+\.cmake)(#(.+))?$') {
2424
$Path = $Matches[1] # Set Path to file for existing logic
25-
if ($Matches[2]) {
26-
$cmakeDep = $Matches[2].TrimStart('#')
25+
if ($Matches[3]) {
26+
$cmakeDep = $Matches[3]
27+
# Validate dependency name follows CMake naming conventions
28+
if ($cmakeDep -notmatch '^[a-zA-Z][a-zA-Z0-9_.-]*$') {
29+
throw "Invalid CMake dependency name: '$cmakeDep'. Must start with letter and contain only alphanumeric, underscore, dot, or hyphen."
30+
}
2731
} else {
2832
$cmakeDep = $null # Will auto-detect
2933
}

0 commit comments

Comments
 (0)