Skip to content

Commit

Permalink
Removal of 450 Script Analyzer problems (#686)
Browse files Browse the repository at this point in the history
### The only real code change is in ReadSecrets
- If you precede a secret name with an asterisk in ReadSecrets/get, it
will be encrypted (as well as base64 encoded)
- Secrets used as SecureString in code will be requested as encrypted
(codeSignCertificatePassword and KeyVaultCertificatePassword) - allows
us to use ConvertTo-SecureString (without the -plaintext clause)
- Refactor connection to Azure KeyVault to only get credentials once and
keep clientSecret as secureString

This part also contains a bug fix that was introduced in
GetKeyVaultSecret during secrets refactoring (identified by secretName
parameter was never used)

### Whitespace only changes:
- Missing BOM on .ps1 files (all now have BOM - half didn't)
- Whitespace trailing lines (fixed everywhere)

### Suppressions:
- Suppress Analyzer on parameter blocks on test runners
- Suppress ConvertTo-SecureString (with plain text) in ReadSecretsHelper
- since we get GitHub secrets in clear text in code.
- Variables initialized in BeforeAll in tests
- Assigning isWindows, isMacOS and isLinux when running PS5

### Renaming functions to not use dash in names (must then follow
cmdlets)

### Removing actor+token from ReadSettings action as this is no longer
needed
- Functionality needing these have been moved to seperate actions

---------

Co-authored-by: freddydk <freddydk@users.noreply.github.com>
Co-authored-by: Maria Zhelezova <43066499+mazhelez@users.noreply.github.com>
  • Loading branch information
3 people authored Sep 5, 2023
1 parent 7d7c20d commit 3c466eb
Show file tree
Hide file tree
Showing 131 changed files with 770 additions and 699 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CleanupTempRepos.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Cleanup after failed E2E
name: Cleanup after failed E2E

on:
workflow_dispatch:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/Deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:
directCommit:
type: boolean
description: Push directly to the target branch. If not set, a PR will be created.
required: false
required: false
default: false
defaultBcContainerHelperVersion:
description: 'Which version of BcContainerHelper to use? (latest, preview, private, a specific version number or a direct download URL like https://github.com/freddydk/navcontainerhelper/archive/master.zip - leave empty to use latest)'
Expand All @@ -34,11 +34,11 @@ jobs:
steps:
- name: Validate Deployment
if: github.repository_owner == 'microsoft'
env:
env:
branch: ${{ github.event.inputs.branch }}
repository: ${{ github.repository }}
runId: ${{ github.run_id }}
run: |
run: |
if ($env:branch -match 'preview') {
Write-Host "Deploying to preview branch. No validation required"
} else {
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/E2E.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ jobs:
run: |
$errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0
. (Join-Path "." "e2eTests/SetupRepositories.ps1") -github -githubOwner '${{ needs.Check.outputs.githubowner }}' -token '${{ Secrets.E2EPAT }}' -bcContainerHelperVersion '${{ github.event.inputs.bcContainerHelperVersion }}'
Analyze:
runs-on: [ ubuntu-latest ]
needs: [ Check ]
Expand All @@ -127,8 +127,8 @@ jobs:
$testrunsJson = @{
"matrix" = @{
"include" = @(
@('private','public') | ForEach-Object {
"include" = @(
@('private','public') | ForEach-Object {
$visibility = $_
@('appSourceApp','PTE') | ForEach-Object {
$type = $_
Expand Down
8 changes: 4 additions & 4 deletions Actions/AL-Go-Helper.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Param(
Param(
[switch] $local
)

Expand Down Expand Up @@ -62,8 +62,11 @@ if ($isPsCore) {
else {
$byteEncodingParam = @{ "Encoding" = "byte" }
$allowUnencryptedAuthenticationParam = @{ }
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidAssignmentToAutomaticVariable', 'isWindows', Justification = 'Will only run on PS5')]
$isWindows = $true
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidAssignmentToAutomaticVariable', 'isLinux', Justification = 'Will only run on PS5')]
$isLinux = $false
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidAssignmentToAutomaticVariable', 'isMacOS', Justification = 'Will only run on PS5')]
$IsMacOS = $false
}

Expand Down Expand Up @@ -1603,9 +1606,6 @@ function CreateDevEnv {
throw "$_ is an illegal property in adminCenterApiCredentials setting"
}
}
if ($adminCenterApiCredentials.Keys -contains 'ClientSecret') {
$adminCenterApiCredentials.ClientSecret = ConvertTo-SecureString -String $adminCenterApiCredentials.ClientSecret -AsPlainText -Force
}
}
}
}
Expand Down
273 changes: 136 additions & 137 deletions Actions/AL-Go-TestRepoHelper.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function Test-Property {
function Test-Property {
Param(
[HashTable] $json,
[string] $settingsDescription,
Expand Down Expand Up @@ -71,7 +71,7 @@ function Test-Json {
# templateUrl should not be in Project or Workflow settings
Test-Property -settingsDescription $settingsDescription -json $json -key 'templateUrl' -maynot

# schedules and runs-on should not be in Project or Workflow settings
# schedules and runs-on should not be in Project or Workflow settings
'nextMajorSchedule','nextMinorSchedule','currentSchedule','githubRunner','runs-on' | ForEach-Object {
Test-Property -settingsDescription $settingsDescription -json $json -key $_ -shouldnot
}
Expand Down Expand Up @@ -118,7 +118,7 @@ function Test-ALGoRepository {
Param(
[string] $baseFolder = $ENV:GITHUB_WORKSPACE
)

if ($ENV:ALGoOrgSettings) {
Write-Host "Checking AL-Go Org Settings variable (ALGoOrgSettings)"
Test-JsonStr -jsonStr "$ENV:ALGoOrgSettings" -settingsDescription 'ALGoOrgSettings variable' -type 'Variable'
Expand Down Expand Up @@ -149,141 +149,140 @@ function Test-ALGoRepository {
}

function Write-Big {
Param(
[string] $str
)
$chars = @{
"0" = @'
___
/ _ \
| | | |
| | | |
| |_| |
\___/
'@.Split("`n")
"1" = @'
__
/_ |
| |
| |
| |
|_|
'@.Split("`n")
"2" = @'
___
|__ \
) |
/ /
/ /_
|____|
'@.Split("`n")
"3" = @'
____
|___ \
__) |
|__ <
___) |
|____/
'@.Split("`n")
"4" = @'
_ _
| || |
| || |_
|__ _|
| |
|_|
'@.Split("`n")
"5" = @'
_____
| ____|
| |__
|___ \
___) |
|____/
'@.Split("`n")
"6" = @'
__
/ /
/ /_
| '_ \
| (_) |
\___/
'@.Split("`n")
"7" = @'
______
|____ |
/ /
/ /
/ /
/_/
'@.Split("`n")
"8" = @'
___
/ _ \
| (_) |
> _ <
| (_) |
\___/
'@.Split("`n")
"9" = @'
___
/ _ \
| (_) |
\__, |
/ /
/_/
'@.Split("`n")
"." = @'
_
(_)
'@.Split("`n")
"v" = @'
__ __
\ \ / /
\ V /
\_(_)
'@.Split("`n")
"p" = @'
_____ _
| __ \ (_)
| |__) | __ _____ ___ _____ __
| ___/ '__/ _ \ \ / / |/ _ \ \ /\ / /
| | | | | __/\ V /| | __/\ V V /
|_| |_| \___| \_/ |_|\___| \_/\_/
'@.Split("`n")
"d" = @'
_____
| __ \
| | | | _____ __
| | | |/ _ \ \ / /
| |__| | __/\ V /
|_____/ \___| \_(_)
'@.Split("`n")
"a" = @'
_ _____ __ _____ _ _ _ _ _
/\ | | / ____| / _| / ____(_) | | | | | | |
/ \ | | ______| | __ ___ | |_ ___ _ __ | | __ _| |_| |__| |_ _| |__
/ /\ \ | | |______| | |_ |/ _ \ | _/ _ \| '__| | | |_ | | __| __ | | | | '_ \
/ ____ \| |____ | |__| | (_) | | || (_) | | | |__| | | |_| | | | |_| | |_) |
/_/ \_\______| \_____|\___/ |_| \___/|_| \_____|_|\__|_| |_|\__,_|_.__/
'@.Split("`n")
}

Param(
[string] $str
)
$chars = @{
"0" = @(
" ___ "
" / _ \ "
"| | | |"
"| | | |"
"| |_| |"
" \___/ "
)
"1" = @(
" __ "
"/_ |"
" | |"
" | |"
" | |"
" |_|"
)
"2" = @(
" ___ "
"|__ \ "
" ) |"
" / / "
" / /_ "
"|____|"
)
"3" = @(
" ____ "
"|___ \ "
" __) |"
" |__ < "
" ___) |"
"|____/ "
)
"4" = @(
" _ _ "
"| || | "
"| || |_ "
"|__ _|"
" | | "
" |_| "
)
"5" = @(
" _____ "
"| ____|"
"| |__ "
"|___ \ "
" ___) |"
"|____/ "
)
"6" = @(
" __ "
" / / "
" / /_ "
"| '_ \ "
"| (_) |"
" \___/ "
)
"7" = @(
" ______ "
"|____ |"
" / / "
" / / "
" / / "
" /_/ "
)
"8" = @(
" ___ "
" / _ \ "
"| (_) |"
" > _ < "
"| (_) |"
" \___/ "
)
"9" = @(
" ___ "
" / _ \ "
"| (_) |"
" \__, |"
" / / "
" /_/ "
)
"." = @(
" "
" "
" "
" "
" _ "
"(_)"
)
"v" = @(
" "
" "
"__ __"
"\ \ / /"
" \ V / "
" \_(_)"
)
"p" = @(
" _____ _ "
"| __ \ (_) "
"| |__) | __ _____ ___ _____ __"
"| ___/ '__/ _ \ \ / / |/ _ \ \ /\ / /"
"| | | | | __/\ V /| | __/\ V V / "
"|_| |_| \___| \_/ |_|\___| \_/\_/ "
)
"d" = @(
" _____ "
"| __ \ "
"| | | | _____ __"
"| | | |/ _ \ \ / /"
"| |__| | __/\ V / "
"|_____/ \___| \_(_)"
)
"a" = @(
" _ _____ __ _____ _ _ _ _ _ "
" /\ | | / ____| / _| / ____(_) | | | | | | | "
" / \ | | ______| | __ ___ | |_ ___ _ __ | | __ _| |_| |__| |_ _| |__ "
" / /\ \ | | |______| | |_ |/ _ \ | _/ _ \| '__| | | |_ | | __| __ | | | | '_ \ "
" / ____ \| |____ | |__| | (_) | | || (_) | | | |__| | | |_| | | | |_| | |_) | "
"/_/ \_\______| \_____|\___/ |_| \___/|_| \_____|_|\__|_| |_|\__,_|_.__/ "
)
}

0..5 | ForEach-Object {
$line = $_
$str.ToCharArray() | ForEach-Object {
if ($chars.Keys -contains $_) {
$ch = $chars."$_"
Write-Host -noNewline $ch[$line]
$lines = $chars."a".Count
for ($line = 0; $line -lt $lines; $line++) {
foreach ($ch in $str.ToCharArray()) {
if ($chars.Keys -contains $ch) {
$bigCh = $chars."$ch"
Write-Host -noNewline $bigCh[$line]
}
}
Write-Host
}
Write-Host
}
}
Loading

0 comments on commit 3c466eb

Please sign in to comment.