forked from Azure/PSRule.Rules.Azure
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BaselineToc.Doc.ps1
78 lines (58 loc) · 2.65 KB
/
BaselineToc.Doc.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
Export-PSDocumentConvention 'NameBaseline' -Process {
$PSDocs.Document.InstanceName = $PSDocs.TargetObject.Name;
}
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
}}
}
}
Document 'Azure.MCSB.Baseline' -If { $PSDocs.TargetObject.Name -eq 'Azure.MCSB.v1' } {
$baselineName = $PSDocs.TargetObject.Name;
$obsolete = $PSDocs.TargetObject.metadata.annotations.obsolete -eq $True;
$experimental = $PSDocs.TargetObject.metadata.annotations.experimental -eq $True;
Write-Verbose -Message "[Baseline] -- Processing baseline: $baselineName";
Write-Verbose -Message "[Baseline] -- Baseline is obsolete: $obsolete";
Write-Verbose -Message "[Baseline] -- Baseline is experimental: $experimental";
Title $baselineName;
Metadata $PSDocs.TargetObject.metadata.annotations
if ($experimental) {
'<!-- EXPERIMENTAL -->'
}
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 'Controls' -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
}}
}
}