Skip to content
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

Support passing Arrays to Functions Using Piping #1344

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
89ad3b5
first drop
mdaneri Jun 27, 2024
12c383c
Add new test cases for piping
mdaneri Jun 27, 2024
d797a57
Address #1345
mdaneri Jun 29, 2024
91659b2
Merge remote-tracking branch 'upstream/develop' into fixing-piping-is…
mdaneri Jul 2, 2024
22f33a7
Fix post merge test errors
mdaneri Jul 2, 2024
d0e2ab6
Merge remote-tracking branch 'upstream/develop' into fixing-piping-is…
mdaneri Jul 3, 2024
5007a13
Merge remote-tracking branch 'upstream/develop' into fixing-piping-is…
mdaneri Jul 3, 2024
8ce571a
Merge remote-tracking branch 'upstream/develop' into fixing-piping-is…
mdaneri Jul 8, 2024
ee7f487
Merge branch 'develop' into fixing-piping-issues
mdaneri Jul 12, 2024
2367a86
Merge remote-tracking branch 'upstream/develop' into fixing-piping-is…
mdaneri Jul 14, 2024
00a443a
Merge remote-tracking branch 'upstream/develop' into fixing-piping-is…
mdaneri Jul 15, 2024
8646296
cleanup and verified the modifications
mdaneri Jul 19, 2024
29e9a09
Merge branch 'develop' into fixing-piping-issues
mdaneri Jul 20, 2024
2f9d1ca
Update Pode.psd1
mdaneri Jul 20, 2024
27b2ee7
Merge branch 'develop' into pr/1344
mdaneri Jul 20, 2024
0b86a49
update Locales
mdaneri Jul 20, 2024
2a32f67
Update OpenApi.Tests.ps1
mdaneri Jul 21, 2024
d107e5d
Update OpenApi.Tests.ps1
mdaneri Jul 21, 2024
8ca1229
Merge remote-tracking branch 'upstream/develop' into pr/1344
mdaneri Aug 21, 2024
1fd4c53
Merge branch 'develop' into fixing-piping-issues
mdaneri Aug 30, 2024
8af11f8
Merge remote-tracking branch 'upstream/develop' into pr/1344
mdaneri Aug 31, 2024
16b7530
Merge branch 'develop' into fixing-piping-issues
mdaneri Sep 2, 2024
254bb43
Merge remote-tracking branch 'upstream/develop' into fixing-piping-is…
mdaneri Sep 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions PSScriptAnalyzerSettings.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
@{
Severity = @('Error', 'Warning', 'Information')

Rules = @{
Rules = @{
PSReviewUnusedParameter = @{
CommandsToTraverse = @(
'Where-Object','Remove-PodeRoute'
'Where-Object', 'Remove-PodeRoute'
)
}
}
ExcludeRules = @( 'PSAvoidUsingPlainTextForPassword','PSUseShouldProcessForStateChangingFunctions',
'PSAvoidUsingUsernameAndPasswordParams','PSUseProcessBlockForPipelineCommand','PSAvoidUsingConvertToSecureStringWithPlainText','PSReviewUnusedParameter' )
ExcludeRules = @( 'PSAvoidUsingPlainTextForPassword', 'PSUseShouldProcessForStateChangingFunctions',
'PSAvoidUsingUsernameAndPasswordParams', 'PSAvoidUsingConvertToSecureStringWithPlainText', 'PSReviewUnusedParameter' )

}
2 changes: 1 addition & 1 deletion packers/choco/tools/ChocolateyUninstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ function Remove-PodeModule($path)
$path = Join-Path $path 'Pode'
if (Test-Path $path)
{
Write-Host "Deleting module directory: $($path)"
Write-Output "Deleting module directory: $($path)"
Remove-Item -Path $path -Recurse -Force | Out-Null
if (!$?) {
throw "Failed to delete: $path"
Expand Down
1 change: 1 addition & 0 deletions src/Locales/ar/Pode.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@
invalidAccessControlMaxAgeDurationExceptionMessage = 'مدة Access-Control-Max-Age غير صالحة المقدمة: {0}. يجب أن تكون أكبر من 0.'
openApiDefinitionAlreadyExistsExceptionMessage = 'تعريف OpenAPI باسم {0} موجود بالفعل.'
renamePodeOADefinitionTagExceptionMessage = "لا يمكن استخدام Rename-PodeOADefinitionTag داخل Select-PodeOADefinition 'ScriptBlock'."
fnDoesNotAcceptArrayAsPipelineInputExceptionMessage = "الدالة '{0}' لا تقبل مصفوفة كمدخل لأنبوب البيانات."
definitionTagChangeNotAllowedExceptionMessage = 'لا يمكن تغيير علامة التعريف لمسار.'
getRequestBodyNotAllowedExceptionMessage = 'لا يمكن أن تحتوي عمليات {0} على محتوى الطلب.'
}
1 change: 1 addition & 0 deletions src/Locales/de/Pode.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@
invalidAccessControlMaxAgeDurationExceptionMessage = 'Ungültige Access-Control-Max-Age-Dauer angegeben: {0}. Sollte größer als 0 sein.'
openApiDefinitionAlreadyExistsExceptionMessage = 'Die OpenAPI-Definition mit dem Namen {0} existiert bereits.'
renamePodeOADefinitionTagExceptionMessage = "Rename-PodeOADefinitionTag kann nicht innerhalb eines 'ScriptBlock' von Select-PodeOADefinition verwendet werden."
fnDoesNotAcceptArrayAsPipelineInputExceptionMessage = "Die Funktion '{0}' akzeptiert kein Array als Pipeline-Eingabe."
definitionTagChangeNotAllowedExceptionMessage = 'Definitionstag für eine Route kann nicht geändert werden.'
getRequestBodyNotAllowedExceptionMessage = '{0}-Operationen können keinen Anforderungstext haben.'
}
1 change: 1 addition & 0 deletions src/Locales/en-us/Pode.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@
invalidAccessControlMaxAgeDurationExceptionMessage = 'Invalid Access-Control-Max-Age duration supplied: {0}. Should be greater than 0.'
openApiDefinitionAlreadyExistsExceptionMessage = 'OpenAPI definition named {0} already exists.'
renamePodeOADefinitionTagExceptionMessage = "Rename-PodeOADefinitionTag cannot be used inside a Select-PodeOADefinition 'ScriptBlock'."
fnDoesNotAcceptArrayAsPipelineInputExceptionMessage = "The function '{0}' does not accept an array as pipeline input."
definitionTagChangeNotAllowedExceptionMessage = 'Definition Tag for a Route cannot be changed.'
getRequestBodyNotAllowedExceptionMessage = '{0} operations cannot have a Request Body.'
}
1 change: 1 addition & 0 deletions src/Locales/en/Pode.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@
invalidAccessControlMaxAgeDurationExceptionMessage = 'Invalid Access-Control-Max-Age duration supplied: {0}. Should be greater than 0.'
openApiDefinitionAlreadyExistsExceptionMessage = 'OpenAPI definition named {0} already exists.'
renamePodeOADefinitionTagExceptionMessage = "Rename-PodeOADefinitionTag cannot be used inside a Select-PodeOADefinition 'ScriptBlock'."
fnDoesNotAcceptArrayAsPipelineInputExceptionMessage = "The function '{0}' does not accept an array as pipeline input."
definitionTagChangeNotAllowedExceptionMessage = 'Definition Tag for a Route cannot be changed.'
getRequestBodyNotAllowedExceptionMessage = '{0} operations cannot have a Request Body.'
}
Expand Down
1 change: 1 addition & 0 deletions src/Locales/es/Pode.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@
invalidAccessControlMaxAgeDurationExceptionMessage = 'Duración inválida para Access-Control-Max-Age proporcionada: {0}. Debe ser mayor que 0.'
openApiDefinitionAlreadyExistsExceptionMessage = 'La definición de OpenAPI con el nombre {0} ya existe.'
renamePodeOADefinitionTagExceptionMessage = "Rename-PodeOADefinitionTag no se puede usar dentro de un 'ScriptBlock' de Select-PodeOADefinition."
fnDoesNotAcceptArrayAsPipelineInputExceptionMessage = "La función '{0}' no acepta una matriz como entrada de canalización."
definitionTagChangeNotAllowedExceptionMessage = 'La etiqueta de definición para una Route no se puede cambiar.'
getRequestBodyNotAllowedExceptionMessage = 'Las operaciones {0} no pueden tener un cuerpo de solicitud.'
}
1 change: 1 addition & 0 deletions src/Locales/fr/Pode.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@
invalidAccessControlMaxAgeDurationExceptionMessage = 'Durée Access-Control-Max-Age invalide fournie : {0}. Doit être supérieure à 0.'
openApiDefinitionAlreadyExistsExceptionMessage = 'La définition OpenAPI nommée {0} existe déjà.'
renamePodeOADefinitionTagExceptionMessage = "Rename-PodeOADefinitionTag ne peut pas être utilisé à l'intérieur d'un 'ScriptBlock' de Select-PodeOADefinition."
fnDoesNotAcceptArrayAsPipelineInputExceptionMessage = "La fonction '{0}' n'accepte pas un tableau en tant qu'entrée de pipeline."
definitionTagChangeNotAllowedExceptionMessage = 'Le tag de définition pour une Route ne peut pas être modifié.'
getRequestBodyNotAllowedExceptionMessage = 'Les opérations {0} ne peuvent pas avoir de corps de requête.'
}
Expand Down
1 change: 1 addition & 0 deletions src/Locales/it/Pode.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@
invalidAccessControlMaxAgeDurationExceptionMessage = 'Durata non valida fornita per Access-Control-Max-Age: {0}. Deve essere maggiore di 0.'
openApiDefinitionAlreadyExistsExceptionMessage = 'La definizione OpenAPI denominata {0} esiste già.'
renamePodeOADefinitionTagExceptionMessage = "Rename-PodeOADefinitionTag non può essere utilizzato all'interno di un 'ScriptBlock' di Select-PodeOADefinition."
fnDoesNotAcceptArrayAsPipelineInputExceptionMessage = "La funzione '{0}' non accetta una matrice come input della pipeline."
definitionTagChangeNotAllowedExceptionMessage = 'Il tag di definizione per una Route non può essere cambiato.'
getRequestBodyNotAllowedExceptionMessage = 'Le operazioni {0} non possono avere un corpo della richiesta.'
}
1 change: 1 addition & 0 deletions src/Locales/ja/Pode.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@
invalidAccessControlMaxAgeDurationExceptionMessage = '無効な Access-Control-Max-Age 期間が提供されました:{0}。0 より大きくする必要があります。'
openApiDefinitionAlreadyExistsExceptionMessage = '名前が {0} の OpenAPI 定義は既に存在します。'
renamePodeOADefinitionTagExceptionMessage = "Rename-PodeOADefinitionTag は Select-PodeOADefinition 'ScriptBlock' 内で使用できません。"
fnDoesNotAcceptArrayAsPipelineInputExceptionMessage = "関数 '{0}' は配列をパイプライン入力として受け付けません。"
definitionTagChangeNotAllowedExceptionMessage = 'Routeの定義タグは変更できません。'
getRequestBodyNotAllowedExceptionMessage = '{0}操作にはリクエストボディを含めることはできません。'
}
Expand Down
1 change: 1 addition & 0 deletions src/Locales/ko/Pode.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@
invalidAccessControlMaxAgeDurationExceptionMessage = '잘못된 Access-Control-Max-Age 기간이 제공되었습니다: {0}. 0보다 커야 합니다.'
openApiDefinitionAlreadyExistsExceptionMessage = '이름이 {0}인 OpenAPI 정의가 이미 존재합니다.'
renamePodeOADefinitionTagExceptionMessage = "Rename-PodeOADefinitionTag은 Select-PodeOADefinition 'ScriptBlock' 내에서 사용할 수 없습니다."
fnDoesNotAcceptArrayAsPipelineInputExceptionMessage = "함수 '{0}'은(는) 배열을 파이프라인 입력으로 받지 않습니다."
definitionTagChangeNotAllowedExceptionMessage = 'Route에 대한 정의 태그는 변경할 수 없습니다.'
getRequestBodyNotAllowedExceptionMessage = '{0} 작업에는 요청 본문이 있을 수 없습니다.'
}
1 change: 1 addition & 0 deletions src/Locales/nl/Pode.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@
invalidAccessControlMaxAgeDurationExceptionMessage = 'Ongeldige Access-Control-Max-Age duur opgegeven: {0}. Moet groter zijn dan 0.'
openApiDefinitionAlreadyExistsExceptionMessage = 'OpenAPI-definitie met de naam {0} bestaat al.'
renamePodeOADefinitionTagExceptionMessage = "Rename-PodeOADefinitionTag kan niet worden gebruikt binnen een Select-PodeOADefinition 'ScriptBlock'."
fnDoesNotAcceptArrayAsPipelineInputExceptionMessage = "De functie '{0}' accepteert geen array als pipeline-invoer."
definitionTagChangeNotAllowedExceptionMessage = 'Definitietag voor een route kan niet worden gewijzigd.'
getRequestBodyNotAllowedExceptionMessage = '{0}-operaties kunnen geen Request Body hebben.'
}
Expand Down
1 change: 1 addition & 0 deletions src/Locales/pl/Pode.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@
invalidAccessControlMaxAgeDurationExceptionMessage = 'Podano nieprawidłowy czas trwania Access-Control-Max-Age: {0}. Powinien być większy niż 0.'
openApiDefinitionAlreadyExistsExceptionMessage = 'Definicja OpenAPI o nazwie {0} już istnieje.'
renamePodeOADefinitionTagExceptionMessage = "Rename-PodeOADefinitionTag nie może być używany wewnątrz 'ScriptBlock' Select-PodeOADefinition."
fnDoesNotAcceptArrayAsPipelineInputExceptionMessage = "Funkcja '{0}' nie akceptuje tablicy jako wejścia potoku."
definitionTagChangeNotAllowedExceptionMessage = 'Tag definicji dla Route nie może zostać zmieniony.'
getRequestBodyNotAllowedExceptionMessage = 'Operacje {0} nie mogą mieć treści żądania.'
}
Expand Down
1 change: 1 addition & 0 deletions src/Locales/pt/Pode.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@
invalidAccessControlMaxAgeDurationExceptionMessage = 'Duração inválida fornecida para Access-Control-Max-Age: {0}. Deve ser maior que 0.'
openApiDefinitionAlreadyExistsExceptionMessage = 'A definição OpenAPI com o nome {0} já existe.'
renamePodeOADefinitionTagExceptionMessage = "Rename-PodeOADefinitionTag não pode ser usado dentro de um 'ScriptBlock' Select-PodeOADefinition."
fnDoesNotAcceptArrayAsPipelineInputExceptionMessage = "A função '{0}' não aceita uma matriz como entrada de pipeline."
definitionTagChangeNotAllowedExceptionMessage = 'A Tag de definição para uma Route não pode ser alterada.'
getRequestBodyNotAllowedExceptionMessage = 'As operações {0} não podem ter um corpo de solicitação.'
}
3 changes: 2 additions & 1 deletion src/Locales/zh/Pode.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@
invalidAccessControlMaxAgeDurationExceptionMessage = '提供的 Access-Control-Max-Age 时长无效:{0}。应大于 0。'
openApiDefinitionAlreadyExistsExceptionMessage = '名为 {0} 的 OpenAPI 定义已存在。'
renamePodeOADefinitionTagExceptionMessage = "Rename-PodeOADefinitionTag 不能在 Select-PodeOADefinition 'ScriptBlock' 内使用。"
fnDoesNotAcceptArrayAsPipelineInputExceptionMessage = "函数 '{0}' 不接受数组作为管道输入。"
definitionTagChangeNotAllowedExceptionMessage = 'Route的定义标签无法更改。'
getRequestBodyNotAllowedExceptionMessage = '{0} 操作不能包含请求体。'
}
}
67 changes: 35 additions & 32 deletions src/Private/Cryptography.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
$value = "MySecretValue"
$secret = "MySecretKey"
$hash = Invoke-PodeHMACSHA256Hash -Value $value -Secret $secret
Write-Host "HMAC-SHA256 hash: $hash"
Write-PodeHost "HMAC-SHA256 hash: $hash"

This example computes the HMAC-SHA256 hash for the value "MySecretValue" using the secret key "MySecretKey".
.NOTES
Expand Down Expand Up @@ -87,7 +87,7 @@ function Invoke-PodeHMACSHA256Hash {
$value = "MySecretValue"
$secret = "MySecretKey"
$hash = Invoke-PodeHMACSHA384Hash -Value $value -Secret $secret
Write-Host "Private HMAC-SHA384 hash: $hash"
Write-PodeHost "Private HMAC-SHA384 hash: $hash"

This example computes the private HMAC-SHA384 hash for the value "MySecretValue" using the secret key "MySecretKey".

Expand Down Expand Up @@ -152,7 +152,7 @@ function Invoke-PodeHMACSHA384Hash {
$value = "MySecretValue"
$secret = "MySecretKey"
$hash = Invoke-PodeHMACSHA512Hash -Value $value -Secret $secret
Write-Host "Private HMAC-SHA512 hash: $hash"
Write-PodeHost "Private HMAC-SHA512 hash: $hash"

This example computes the private HMAC-SHA512 hash for the value "MySecretValue" using the secret key "MySecretKey".

Expand Down Expand Up @@ -346,12 +346,13 @@ function Invoke-PodeValueSign {
[switch]
$Strict
)
process {
if ($Strict) {
$Secret = ConvertTo-PodeStrictSecret -Secret $Secret
}

if ($Strict) {
$Secret = ConvertTo-PodeStrictSecret -Secret $Secret
return "s:$($Value).$(Invoke-PodeHMACSHA256Hash -Value $Value -Secret $Secret)"
}

return "s:$($Value).$(Invoke-PodeHMACSHA256Hash -Value $Value -Secret $Secret)"
}

function Invoke-PodeValueUnsign {
Expand All @@ -371,32 +372,33 @@ function Invoke-PodeValueUnsign {
[switch]
$Strict
)
process {
# the signed value must start with "s:"
if (!$Value.StartsWith('s:')) {
return $null
}

# the signed value must start with "s:"
if (!$Value.StartsWith('s:')) {
return $null
}
# the signed value must contain a dot - splitting value and signature
$Value = $Value.Substring(2)
$periodIndex = $Value.LastIndexOf('.')
if ($periodIndex -eq -1) {
return $null
}

# the signed value must contain a dot - splitting value and signature
$Value = $Value.Substring(2)
$periodIndex = $Value.LastIndexOf('.')
if ($periodIndex -eq -1) {
return $null
}
if ($Strict) {
$Secret = ConvertTo-PodeStrictSecret -Secret $Secret
}

if ($Strict) {
$Secret = ConvertTo-PodeStrictSecret -Secret $Secret
}
# get the raw value and signature
$raw = $Value.Substring(0, $periodIndex)
$sig = $Value.Substring($periodIndex + 1)

# get the raw value and signature
$raw = $Value.Substring(0, $periodIndex)
$sig = $Value.Substring($periodIndex + 1)
if ((Invoke-PodeHMACSHA256Hash -Value $raw -Secret $Secret) -ne $sig) {
return $null
}

if ((Invoke-PodeHMACSHA256Hash -Value $raw -Secret $Secret) -ne $sig) {
return $null
return $raw
}

return $raw
}

function Test-PodeValueSigned {
Expand All @@ -415,13 +417,14 @@ function Test-PodeValueSigned {
[switch]
$Strict
)
process {
if ([string]::IsNullOrEmpty($Value)) {
return $false
}

if ([string]::IsNullOrEmpty($Value)) {
return $false
$result = Invoke-PodeValueUnsign -Value $Value -Secret $Secret -Strict:$Strict
return ![string]::IsNullOrEmpty($result)
}

$result = Invoke-PodeValueUnsign -Value $Value -Secret $Secret -Strict:$Strict
return ![string]::IsNullOrEmpty($result)
}

function ConvertTo-PodeStrictSecret {
Expand Down
Loading