Skip to content

Commit 5eef4ac

Browse files
authored
Disallow invoking Run-ALPipeline with keepContainer without specifying credential (#3375)
If `keepContainer` is specified, `credential` must also be specified, as otherwise the container will be created with a random password and there will be no way to access it.
1 parent 0b0218d commit 5eef4ac

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

AppHandling/Run-AlPipeline.ps1

+12-10
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ function CheckRelativePath([string] $baseFolder, [string] $sharedFolder, $path,
411411
$path
412412
}
413413

414-
Function UpdateLaunchJson {
414+
function UpdateLaunchJson {
415415
Param(
416416
[string] $launchJsonFile,
417417
[System.Collections.Specialized.OrderedDictionary] $launchSettings
@@ -485,6 +485,17 @@ if ($sharedFolder -and !(Test-Path $sharedFolder -PathType Container)) {
485485
throw "If sharedFolder is specified, it must be an existing folder"
486486
}
487487

488+
if($keepContainer -and !$credential) {
489+
# If keepContainer is specified, credentials must also be specified, as otherwise the container will be created with a random password and there will be no way to access it.
490+
throw "If keepContainer is specified, you must also specify credentials"
491+
}
492+
493+
if(!$credential) {
494+
# Create a random password to use, as the container will not be kept after the pipeline finishes.
495+
$password = GetRandomPassword
496+
$credential= (New-Object pscredential 'admin', (ConvertTo-SecureString -String $password -AsPlainText -Force))
497+
}
498+
488499
if ($memoryLimit -eq "") {
489500
$memoryLimit = "8G"
490501
}
@@ -662,15 +673,6 @@ Write-Host -NoNewLine -ForegroundColor Yellow "useCompilerFolder "
662673
Write-Host -NoNewLine -ForegroundColor Yellow "artifactCachePath "; Write-Host $artifactCachePath
663674
Write-Host -NoNewLine -ForegroundColor Yellow "useDevEndpoint "; Write-Host $useDevEndpoint
664675
Write-Host -NoNewLine -ForegroundColor Yellow "Auth "; Write-Host $auth
665-
Write-Host -NoNewLine -ForegroundColor Yellow "Credential ";
666-
if ($credential) {
667-
Write-Host "Specified"
668-
}
669-
else {
670-
$password = GetRandomPassword
671-
Write-Host "Username: admin, Password: ***"
672-
$credential= (New-Object pscredential 'admin', (ConvertTo-SecureString -String $password -AsPlainText -Force))
673-
}
674676
Write-Host -NoNewLine -ForegroundColor Yellow "CompanyName "; Write-Host $companyName
675677
Write-Host -NoNewLine -ForegroundColor Yellow "MemoryLimit "; Write-Host $memoryLimit
676678
Write-Host -NoNewLine -ForegroundColor Yellow "FailOn "; Write-Host $failOn

ReleaseNotes.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Check-BcContainerHelperPermissions didn't work on PS7
88
Issue #3379 Adding -installCertificateOnHost to New-BcContainer didn't work when running PS7 (silently failed)
99
Issue #3376 Regression - Download-Artifacts stopped downloading pre-requisites
1010
Issue 3371 Unable to get companyname from Windows Users when running tests
11+
Disallow invoking Run-ALPipeline with `keepContainer` without specifying credentials to use
1112

1213
6.0.6
1314
Include Microsoft_Business Foundation Test Libraries.app when importing test libraries (and tests)
@@ -26,7 +27,7 @@ Proof of concept support for hosting artifacts as Universal Packages
2627
Add new function Get-BcNuGetPackageId to get a NuGet Package Id based on publisher, name, id and version
2728
Issue 3301 Run-AlValidation fails running AppsourceCop "Could not load type 'System.Object' from assembly 'System.Private.CoreLib'
2829
Give better error message if GitHub CLI, GIT or dotnet is not installed
29-
Issue 3301 Run-AlValidation fails running AppsourceCop "Could not load type 'System.Object' from assembly 'System.Private.CoreLib' (Regression in 6.0.4)
30+
Issue 3301 Run-AlValidation fails running AppsourceCop "Could not load type 'System.Object' from assembly 'System.Private.CoreLib' (Regression in 6.0.4)
3031
Issue 3313 Strange error in Copy-BcEnvironment
3132
Issue 3318 Download-BcNuGetPackageToFolder fails when no dependencies defined
3233
Add Stacktrace output to high level functions Download-BcNuGetPackageToFolder and Get-BcNuGetPackage

0 commit comments

Comments
 (0)