PSRule.Rules.Azure/BaselineToc.Doc.ps1

79 строки
2.6 KiB
PowerShell
Исходник Постоянная ссылка Обычный вид История

# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
Export-PSDocumentConvention 'NameBaseline' -Process {
$PSDocs.Document.InstanceName = $PSDocs.TargetObject.Name;
}
2023-02-11 06:34:05 +03:00
Document 'baseline' -If { $PSDocs.TargetObject.Name -ne 'Azure.MCSB.v1' } {
$baselineName = $PSDocs.TargetObject.Name;
$obsolete = $PSDocs.TargetObject.metadata.annotations.obsolete -eq $True;
Write-Verbose -Message "[Baseline] -- Processing baseline: $baselineName";
Write-Verbose -Message "[Baseline] -- Baseline is obsolete: $obsolete";
Title $baselineName;
Metadata $PSDocs.TargetObject.metadata.annotations
if ($obsolete) {
'<!-- OBSOLETE -->'
}
$rules = $PSDocs.TargetObject.Rules | Sort-Object -Property Name;
$ruleCount = $rules.Length;
$PSDocs.TargetObject.Synopsis;
Write-Verbose -Message "[Baseline] -- Found $ruleCount rules.";
Section 'Rules' -If { $ruleCount -gt 0 } {
"The following rules are included within the ``$baselineName`` baseline.";
"This baseline includes a total of $ruleCount rules.";
$rules | Table -Property @{ Name = 'Name'; Expression = {
"[$($_.Name)](../rules/$($_.Name).md)"
}}, Synopsis, @{ Name = 'Severity'; Expression = {
$_.Info.Annotations.severity
}}
}
}
2023-02-11 06:34:05 +03:00
Document 'Azure.MCSB.Baseline' -If { $PSDocs.TargetObject.Name -eq 'Azure.MCSB.v1' } {
2023-02-11 06:34:05 +03:00
$baselineName = $PSDocs.TargetObject.Name;
$obsolete = $PSDocs.TargetObject.metadata.annotations.obsolete -eq $True;
$experimental = $PSDocs.TargetObject.metadata.annotations.experimental -eq $True;
2023-02-11 06:34:05 +03:00
Write-Verbose -Message "[Baseline] -- Processing baseline: $baselineName";
Write-Verbose -Message "[Baseline] -- Baseline is obsolete: $obsolete";
Write-Verbose -Message "[Baseline] -- Baseline is experimental: $experimental";
2023-02-11 06:34:05 +03:00
Title $baselineName;
Metadata $PSDocs.TargetObject.metadata.annotations
if ($experimental) {
'<!-- EXPERIMENTAL -->'
}
2023-02-11 06:34:05 +03:00
if ($obsolete) {
'<!-- OBSOLETE -->'
}
$rules = $PSDocs.TargetObject.Rules | Sort-Object -Property Name;
2023-02-11 06:34:05 +03:00
$ruleCount = $rules.Length;
$PSDocs.TargetObject.Synopsis;
Write-Verbose -Message "[Baseline] -- Found $ruleCount rules.";
Section 'Controls' -If { $ruleCount -gt 0 } {
"The following rules are included within the ``$baselineName`` baseline.";
"This baseline includes a total of $ruleCount rules.";
2023-02-11 06:34:05 +03:00
$rules | Table -Property @{ Name = 'Name'; Expression = {
"[$($_.Name)](../rules/$($_.Name).md)"
2023-02-11 06:34:05 +03:00
}}, Synopsis, @{ Name = 'Severity'; Expression = {
$_.Info.Annotations.severity
}}
}
}