fix: support non-interactive signed downloads
This commit is contained in:
parent
845da21a9f
commit
436bf570a5
2 changed files with 27 additions and 9 deletions
|
|
@ -37,5 +37,9 @@ the acquisition workflow. It accepts authenticated download references over
|
|||
standard input, rejects path traversal, and verifies byte sizes before files
|
||||
enter PrivateStash. It never prints download credentials.
|
||||
|
||||
For non-interactive orchestration it also accepts one UTF-8 JSON request as a
|
||||
Base64 parameter. This prevents shell metacharacters in signed references from
|
||||
being interpreted as commands.
|
||||
|
||||
No project license has been selected yet. Until that decision is recorded,
|
||||
the contents are not offered under an open-source license.
|
||||
|
|
|
|||
|
|
@ -1,22 +1,20 @@
|
|||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$Root
|
||||
[string]$Root,
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$RequestBase64
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$rootPath = (Resolve-Path -LiteralPath $Root).Path
|
||||
$rootPrefix = $rootPath.TrimEnd([IO.Path]::DirectorySeparatorChar) + [IO.Path]::DirectorySeparatorChar
|
||||
|
||||
while (($line = [Console]::In.ReadLine()) -ne $null) {
|
||||
if ($line -eq '__END__') {
|
||||
break
|
||||
}
|
||||
if ([string]::IsNullOrWhiteSpace($line)) {
|
||||
continue
|
||||
}
|
||||
function Receive-Artifact {
|
||||
param([Parameter(Mandatory = $true)]$Item)
|
||||
|
||||
$item = $line | ConvertFrom-Json
|
||||
$item = $Item
|
||||
if (-not $item.relative_path -or -not $item.download_url) {
|
||||
throw 'Each input line must contain relative_path and download_url.'
|
||||
}
|
||||
|
|
@ -45,3 +43,19 @@ while (($line = [Console]::In.ReadLine()) -ne $null) {
|
|||
|
||||
Write-Output ("OK`t{0}`t{1}" -f $actualSize, $item.relative_path)
|
||||
}
|
||||
|
||||
if ($RequestBase64) {
|
||||
$json = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($RequestBase64))
|
||||
Receive-Artifact -Item ($json | ConvertFrom-Json)
|
||||
exit 0
|
||||
}
|
||||
|
||||
while (($line = [Console]::In.ReadLine()) -ne $null) {
|
||||
if ($line -eq '__END__') {
|
||||
break
|
||||
}
|
||||
if ([string]::IsNullOrWhiteSpace($line)) {
|
||||
continue
|
||||
}
|
||||
Receive-Artifact -Item ($line | ConvertFrom-Json)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue