Skip to content

Commit

Permalink
Merge pull request #377 from maester365/fb_FunctionToLowerCase
Browse files Browse the repository at this point in the history
Convert function declarations to lowercase
  • Loading branch information
f-bader committed Jul 21, 2024
2 parents 9b6c8c5 + ff4a273 commit bec4dcd
Show file tree
Hide file tree
Showing 58 changed files with 121 additions and 121 deletions.
42 changes: 21 additions & 21 deletions build/eidsca/Update-EidscaTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,21 @@ param (
[string] $AadSecConfigUrl = 'https://raw.githubusercontent.com/Cloud-Architekt/AzureAD-Attack-Defense/AADSCAv4/config/EidscaConfig.json'
)

Function GetRelativeUri($graphUri) {
function GetRelativeUri($graphUri) {
$relativeUri = $graphUri -replace 'https://graph.microsoft.com/v1.0/', ''
$relativeUri = $relativeUri -replace 'https://graph.microsoft.com/beta/', ''
return $relativeUri
}

Function GetVersion($graphUri) {
function GetVersion($graphUri) {
$apiVersion = 'v1.0'
if ($graphUri.Contains('beta')) {
$apiVersion = 'beta'
}
return $apiVersion
}

Function GetRecommendedValue($RecommendedValue) {
function GetRecommendedValue($RecommendedValue) {
if($RecommendedValue -notlike "@('*,*')") {
$compareOperators = @(">=",">","<")
foreach ($compareOperator in $compareOperators) {
Expand All @@ -58,7 +58,7 @@ Function GetRecommendedValue($RecommendedValue) {
}
}

Function GetRecommendedValueMarkdown($RecommendedValueMarkdown) {
function GetRecommendedValueMarkdown($RecommendedValueMarkdown) {
if($RecommendedValueMarkdown -like "@('*,*')") {
$RecommendedValueMarkdown = $RecommendedValueMarkdown -replace "@\(", "" -replace "\)", ""
return "$RecommendedValueMarkdown"
Expand All @@ -67,7 +67,7 @@ Function GetRecommendedValueMarkdown($RecommendedValueMarkdown) {
}
}

Function GetCompareOperator($RecommendedValue) {
function GetCompareOperator($RecommendedValue) {
if ($RecommendedValue -like "@('*,*')") {
$compareOperator = [PSCustomObject]@{
name = 'in'
Expand Down Expand Up @@ -108,7 +108,7 @@ Function GetCompareOperator($RecommendedValue) {
return $compareOperator
}

Function GetPageTitle($uri) {
function GetPageTitle($uri) {
$isValidUri = ($uri -as [System.URI]).AbsoluteURI -ne $null

$title = ''
Expand All @@ -122,7 +122,7 @@ Function GetPageTitle($uri) {
return $title
}

Function GetPageMarkdownLink($uri) {
function GetPageMarkdownLink($uri) {
$output = $uri

$title = GetPageTitle($uri)
Expand All @@ -133,12 +133,12 @@ Function GetPageMarkdownLink($uri) {
return $output
}

Function GetGraphExplorerMarkDownLink($relativeUri, $apiVersion) {
function GetGraphExplorerMarkDownLink($relativeUri, $apiVersion) {
$graphExplorerUrl = "https://developer.microsoft.com/en-us/graph/graph-explorer?request=$relativeUri&method=GET&version=$apiVersion&GraphUrl=https://graph.microsoft.com"
return "[Open in Graph Explorer]($graphExplorerUrl)"
}

Function GetMitreUrl($item) {
function GetMitreUrl($item) {
$item = $item.Trim()

$urlPart = ''
Expand All @@ -161,7 +161,7 @@ Function GetMitreUrl($item) {
return $url
}

Function GetMitreTitle($item) {
function GetMitreTitle($item) {
$url = GetMitreUrl($item)
if ($null -eq $url) {
return $item
Expand All @@ -174,7 +174,7 @@ Function GetMitreTitle($item) {
return $title
}

Function GetMitreItems($items) {
function GetMitreItems($items) {
$output = ""
$isFirst = $true
foreach ($item in $items) {
Expand All @@ -189,7 +189,7 @@ Function GetMitreItems($items) {
return $output
}

Function GetMitreMarkdownLink($item) {
function GetMitreMarkdownLink($item) {
$url = GetMitreUrl($item)
if ($null -eq $url) {
return $item
Expand All @@ -199,7 +199,7 @@ Function GetMitreMarkdownLink($item) {
return $output
}

Function GetMitreMarkdownLinks($items) {
function GetMitreMarkdownLinks($items) {
$output = ""
$isFirst = $true
foreach ($item in $items) {
Expand All @@ -212,7 +212,7 @@ Function GetMitreMarkdownLinks($items) {
}
return $output
}
Function GetMitreDiagram($controlItem) {
function GetMitreDiagram($controlItem) {

if ($controlItem.MitreTactic.Length -le 0) {
return ''
Expand Down Expand Up @@ -253,7 +253,7 @@ mindmap
return $mermaid
}

Function GetMarkdownLink($uri, $title, [switch]$lookupTitle) {
function GetMarkdownLink($uri, $title, [switch]$lookupTitle) {
if([string]::IsNullOrEmpty($uri)) { return '' }
if($lookupTitle) {
$pageTitle = GetPageTitle($uri)
Expand All @@ -264,7 +264,7 @@ Function GetMarkdownLink($uri, $title, [switch]$lookupTitle) {
return "- [$title]($uri)"
}

Function GetPortalDeepLinkMarkdown($portalDeepLink) {
function GetPortalDeepLinkMarkdown($portalDeepLink) {
$result = $portalDeepLink
if (![string]::IsNullOrEmpty($portalDeepLink)) {
$domain = ($uri -as [System.URI]).Host
Expand All @@ -279,7 +279,7 @@ Function GetPortalDeepLinkMarkdown($portalDeepLink) {
return $result
}

Function UpdateTemplate($template, $control, $controlItem, $docName, $isDoc) {
function UpdateTemplate($template, $control, $controlItem, $docName, $isDoc) {
$relativeUri = GetRelativeUri($control.GraphUri)
$apiVersion = GetVersion($control.GraphUri)

Expand Down Expand Up @@ -361,23 +361,23 @@ Function UpdateTemplate($template, $control, $controlItem, $docName, $isDoc) {
}

# Returns the contents of a file named @template.txt at the given folder path
Function GetTemplate($folderPath, $templateFileName = "@template.txt") {
function GetTemplate($folderPath, $templateFileName = "@template.txt") {
$templateFilePath = Join-Path $folderPath $templateFileName
return Get-Content $templateFilePath -Raw
}

Function CreateFile($folderPath, $fileName, $content) {
function CreateFile($folderPath, $fileName, $content) {
$filePath = Join-Path $folderPath $fileName
$content | Out-File $filePath -Encoding utf8
}

Function GetEidscaPsFunctionName($checkId) {
function GetEidscaPsFunctionName($checkId) {
$powerShellFunctionName = "Test-Mt$($checkId)"
$powerShellFunctionName = $powerShellFunctionName.Replace("EIDSCA.", "Eidsca")
return $powerShellFunctionName
}

Function GeneratePublicFunction($folderPath, $controlIds) {
function GeneratePublicFunction($folderPath, $controlIds) {
$output = GetTemplate -folderPath $folderPath -templateFileName '@Test-MtEidscaControl.txt'
$output = $output -replace '%ArrayOfControlIds%', "'$($controlIds -replace '^.*\.' -join "','")'"
$output = $output -replace '%InternalFunctionNameTemplate%', (GetEidscaPsFunctionName -checkId 'EIDSCA.$CheckId')
Expand Down
2 changes: 1 addition & 1 deletion powershell/internal/Clear-ModuleVariable.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
This function will be called for each fresh run of Invoke-Maester.
#>

Function Clear-ModuleVariable {
function Clear-ModuleVariable {
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification='Module variables used in other functions.')]
param()

Expand Down
2 changes: 1 addition & 1 deletion powershell/internal/Get-GraphObjectMarkdown.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
Returns a markdown list of Conditional Access policies with deeplinks to the relevant CA blade in Entra portal.
#>

Function Get-GraphObjectMarkdown {
function Get-GraphObjectMarkdown {
[CmdletBinding()]
[OutputType([string])]
param(
Expand Down
2 changes: 1 addition & 1 deletion powershell/internal/Get-IsNewMaesterVersionAvailable.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
Get-IsNewMaesterVersionAvailable
#>

Function Get-IsNewMaesterVersionAvailable {
function Get-IsNewMaesterVersionAvailable {
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '', Justification = 'Colors are beautiful')]
[OutputType([bool])]
[CmdletBinding()]
Expand Down
2 changes: 1 addition & 1 deletion powershell/internal/Get-MtConfirmation.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Function Get-MtConfirmation {
function Get-MtConfirmation {
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '', Justification = 'Colors are beautiful')]
[CmdletBinding()]
param ($message)
Expand Down
2 changes: 1 addition & 1 deletion powershell/internal/Get-MtMaesterTestFolderPath.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Function Get-MtMaesterTestFolderPath {
function Get-MtMaesterTestFolderPath {
return Join-Path -Path $PSScriptRoot -ChildPath "../maester-tests"
}
2 changes: 1 addition & 1 deletion powershell/internal/Get-MtMarkdownReport.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Get-MtMarkdownReport $maesterResults
#>

Function Get-MtMarkdownReport {
function Get-MtMarkdownReport {
[CmdletBinding()]
param(
# The Maester test results returned from `Invoke-Pester -PassThru | ConvertTo-MtMaesterResult`
Expand Down
2 changes: 1 addition & 1 deletion powershell/internal/Get-MtUserInteractive.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Returns if the current session is interactive or is being run in a non-interactive environment (e.g. Azure DevOps Pipeline or GitHub Actions).
#>

Function Get-MtUserInteractive {
function Get-MtUserInteractive {
[CmdletBinding()]
[OutputType([bool])]
param ()
Expand Down
2 changes: 1 addition & 1 deletion powershell/internal/Invoke-MtGraphRequestCache.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.SYNOPSIS
Enhanced version of Invoke-MgGraphRequest that supports caching.
#>
Function Invoke-MtGraphRequestCache {
function Invoke-MtGraphRequestCache {
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
Expand Down
2 changes: 1 addition & 1 deletion powershell/internal/Reset-MtProgressView.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Resets the style of the progress bar to the previous state on Windows.
#>

Function Reset-MtProgressView {
function Reset-MtProgressView {
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '', Justification = 'TODO: Implement ShouldProcess')]
[CmdletBinding()]
param ()
Expand Down
2 changes: 1 addition & 1 deletion powershell/internal/Set-MtProgressView.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Set the style of the progress bar to classic on Windows for better compatibility with the console.
#>

Function Set-MtProgressView {
function Set-MtProgressView {
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '', Justification = 'TODO: Implement ShouldProcess')]
[CmdletBinding()]
param ()
Expand Down
2 changes: 1 addition & 1 deletion powershell/internal/Update-MtMaesterTests.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<#
#>
Function Update-MtMaesterTests {
function Update-MtMaesterTests {
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseSingularNouns', '', Justification = 'This command updates multiple tests')]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '', Justification = 'Colors are beautiful')]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '', Justification = 'TODO: Implement ShouldProcess')]
Expand Down
2 changes: 1 addition & 1 deletion powershell/internal/Write-MtProgress.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Show updates to the user on the current activity.
#>

Function Write-MtProgress {
function Write-MtProgress {
[CmdletBinding()]
Param (
# Specifies the first line of text in the heading above the status bar. This text describes the activity whose progress is being reported.
Expand Down
2 changes: 1 addition & 1 deletion powershell/internal/eidsca/@templateps1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
Returns the result of graph.microsoft.com/beta/%RelativeUri%.%CurrentValue% -%PwshCompareOperator% %RecommendedValue%
#>

Function %PSFunctionName% {
function %PSFunctionName% {
[CmdletBinding()]
[OutputType([bool])]
param()
Expand Down
4 changes: 2 additions & 2 deletions powershell/internal/eidsca/Test-MtEidscaAF01.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
Returns the result of graph.microsoft.com/beta/policies/authenticationMethodsPolicy/authenticationMethodConfigurations('Fido2').state -eq 'enabled'
#>

Function Test-MtEidscaAF01 {
function Test-MtEidscaAF01 {
[CmdletBinding()]
[OutputType([bool])]
param()



$result = Invoke-MtGraphRequest -RelativeUri "policies/authenticationMethodsPolicy/authenticationMethodConfigurations('Fido2')" -ApiVersion beta

Expand Down
4 changes: 2 additions & 2 deletions powershell/internal/eidsca/Test-MtEidscaAF02.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
Returns the result of graph.microsoft.com/beta/policies/authenticationMethodsPolicy/authenticationMethodConfigurations('Fido2').isSelfServiceRegistrationAllowed -eq 'true'
#>

Function Test-MtEidscaAF02 {
function Test-MtEidscaAF02 {
[CmdletBinding()]
[OutputType([bool])]
param()

if ( $EnabledAuthMethods -notcontains 'Fido2' ) {
Add-MtTestResultDetail -SkippedBecause 'Custom' -SkippedCustomReason 'Authentication method of FIDO2 security keys is not enabled.'
return $null
return $null
}

$result = Invoke-MtGraphRequest -RelativeUri "policies/authenticationMethodsPolicy/authenticationMethodConfigurations('Fido2')" -ApiVersion beta
Expand Down
4 changes: 2 additions & 2 deletions powershell/internal/eidsca/Test-MtEidscaAF03.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
Returns the result of graph.microsoft.com/beta/policies/authenticationMethodsPolicy/authenticationMethodConfigurations('Fido2').isAttestationEnforced -eq 'true'
#>

Function Test-MtEidscaAF03 {
function Test-MtEidscaAF03 {
[CmdletBinding()]
[OutputType([bool])]
param()

if ( $EnabledAuthMethods -notcontains 'Fido2' ) {
Add-MtTestResultDetail -SkippedBecause 'Custom' -SkippedCustomReason 'Authentication method of FIDO2 security keys is not enabled.'
return $null
return $null
}

$result = Invoke-MtGraphRequest -RelativeUri "policies/authenticationMethodsPolicy/authenticationMethodConfigurations('Fido2')" -ApiVersion beta
Expand Down
4 changes: 2 additions & 2 deletions powershell/internal/eidsca/Test-MtEidscaAF04.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
Returns the result of graph.microsoft.com/beta/policies/authenticationMethodsPolicy/authenticationMethodConfigurations('Fido2').keyRestrictions.isEnforced -eq 'true'
#>

Function Test-MtEidscaAF04 {
function Test-MtEidscaAF04 {
[CmdletBinding()]
[OutputType([bool])]
param()

if ( $EnabledAuthMethods -notcontains 'Fido2' ) {
Add-MtTestResultDetail -SkippedBecause 'Custom' -SkippedCustomReason 'Authentication method of FIDO2 security keys is not enabled.'
return $null
return $null
}

$result = Invoke-MtGraphRequest -RelativeUri "policies/authenticationMethodsPolicy/authenticationMethodConfigurations('Fido2')" -ApiVersion beta
Expand Down
4 changes: 2 additions & 2 deletions powershell/internal/eidsca/Test-MtEidscaAF05.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
Returns the result of graph.microsoft.com/beta/policies/authenticationMethodsPolicy/authenticationMethodConfigurations('Fido2').keyRestrictions.aaGuids -notcontains $null -eq 'true'
#>

Function Test-MtEidscaAF05 {
function Test-MtEidscaAF05 {
[CmdletBinding()]
[OutputType([bool])]
param()

if ( $EnabledAuthMethods -notcontains 'Fido2' -or (Test-MtEidscaAF04) -eq $false ) {
Add-MtTestResultDetail -SkippedBecause 'Custom' -SkippedCustomReason 'Authentication method of FIDO2 security keys is not enabled and key restriction not enforced.'
return $null
return $null
}

$result = Invoke-MtGraphRequest -RelativeUri "policies/authenticationMethodsPolicy/authenticationMethodConfigurations('Fido2')" -ApiVersion beta
Expand Down
4 changes: 2 additions & 2 deletions powershell/internal/eidsca/Test-MtEidscaAF06.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
Returns the result of graph.microsoft.com/beta/policies/authenticationMethodsPolicy/authenticationMethodConfigurations('Fido2').keyRestrictions.aaGuids -notcontains $null -and ($result.keyRestrictions.enforcementType -eq 'allow' -or $result.keyRestrictions.enforcementType -eq 'block') -eq 'true'
#>

Function Test-MtEidscaAF06 {
function Test-MtEidscaAF06 {
[CmdletBinding()]
[OutputType([bool])]
param()

if ( $EnabledAuthMethods -notcontains 'Fido2' -or (Test-MtEidscaAF04) -eq $false ) {
Add-MtTestResultDetail -SkippedBecause 'Custom' -SkippedCustomReason 'Authentication method of FIDO2 security keys is not enabled and key restriction not enforced.'
return $null
return $null
}

$result = Invoke-MtGraphRequest -RelativeUri "policies/authenticationMethodsPolicy/authenticationMethodConfigurations('Fido2')" -ApiVersion beta
Expand Down
Loading

0 comments on commit bec4dcd

Please sign in to comment.