Skip to content

Commit 74de0dd

Browse files
Thread api-version from input JSON to tsp-client emitter options (#53750)
* Initial plan * Add support for passing apiVersion to tsp-client as emitter option Co-authored-by: JoshLove-msft <[email protected]> * Add validation for apiVersion to prevent command injection Co-authored-by: JoshLove-msft <[email protected]> * Fix regex pattern for apiVersion validation Co-authored-by: JoshLove-msft <[email protected]> * Add warning when sdkReleaseType is provided in input JSON Co-authored-by: JoshLove-msft <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: JoshLove-msft <[email protected]>
1 parent 5bef319 commit 74de0dd

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

eng/scripts/Invoke-GenerateAndBuildV2.ps1

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ $repoHttpsUrl = $inputJson.repoHttpsUrl
4242
$downloadUrlPrefix = $inputJson.installInstructionInput.downloadUrlPrefix
4343
$autorestConfig = $inputJson.autorestConfig
4444
$relatedTypeSpecProjectFolder = $inputJson.relatedTypeSpecProjectFolder
45+
$apiVersion = $inputJson.apiVersion
46+
$sdkReleaseType = $inputJson.sdkReleaseType
47+
48+
if ($sdkReleaseType) {
49+
Write-Warning "sdkReleaseType is not supported by .NET and user will need to update the package version manually"
50+
}
4551

4652
$autorestConfigYaml = ""
4753
if ($autorestConfig) {
@@ -150,6 +156,14 @@ if ($relatedTypeSpecProjectFolder) {
150156
if ($swaggerDir) {
151157
$tspclientCommand += " --local-spec-repo $typespecFolder"
152158
}
159+
if ($apiVersion) {
160+
# Validate apiVersion format to prevent command injection - allow alphanumeric, dots, and dashes
161+
if ($apiVersion -match '^[a-zA-Z0-9.-]+$') {
162+
$tspclientCommand += " --emitter-options `"api-version=$apiVersion`""
163+
} else {
164+
Write-Warning "apiVersion '$apiVersion' contains invalid characters and will be skipped. Only alphanumeric characters, dots, and dashes are allowed."
165+
}
166+
}
153167
Write-Host $tspclientCommand
154168
Invoke-Expression $tspclientCommand
155169

0 commit comments

Comments
 (0)