Module/Rule.VsphereVssSecurity/Convert/Methods.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
#region Method Functions

<#
    .SYNOPSIS
        This function parses the fix text to find the boolean value of ForgedTransmits, then sets the value.
 
    .PARAMETER RawString
        An array of the raw string data taken from the STIG setting.
#>

function Get-VsphereForgedTransmits
{
    [CmdletBinding()]
    [OutputType([object])]
    param
    (
        [Parameter(Mandatory = $true)]
        [psobject]
        $FixText
    )

    if ($FixText -match 'Get-VirtualSwitch')
    {
        $vsphereForgedTransmits = ($FixText | Select-String -Pattern '(?<=ForgedTransmits\s)(.\w+)').Matches.Value
    }

    if ($null -ne $vsphereForgedTransmits)
    {
        Write-Verbose -Message $("[$($MyInvocation.MyCommand.Name)] Found ForgedTransmits value: {0}" -f $vsphereForgedTransmits)
        return $vsphereForgedTransmits
    }
    else
    {
        return $null
    }
}
<#
    .SYNOPSIS
        This function parses the fix text to find the boolean value of MacChanges, then sets the value.
 
    .PARAMETER RawString
        An array of the raw string data taken from the STIG setting.
#>

function Get-VsphereMacChange
{
    [CmdletBinding()]
    [OutputType([object])]
    param
    (
        [Parameter(Mandatory = $true)]
        [psobject]
        $FixText
    )

    if ($FixText -match 'Get-VirtualSwitch')
    {
        $vsphereMacChange = ($FixText | Select-String -Pattern '(?<=MacChanges\s)(.\w+)').Matches.Value
    }

    if ($null -ne $vsphereMacChange)
    {
        Write-Verbose -Message $("[$($MyInvocation.MyCommand.Name)] Found MacChanges value: {0}" -f $vsphereMacChange)
        return $vsphereMacChange
    }
    else
    {
        return $null
    }
}
<#
    .SYNOPSIS
        This function parses the fix text to find the boolean value of AllowPromiscuous, then sets the value.
 
    .PARAMETER RawString
        An array of the raw string data taken from the STIG setting.
#>

function Get-VsphereAllowPromiscuous
{
    [CmdletBinding()]
    [OutputType([object])]
    param
    (
        [Parameter(Mandatory = $true)]
        [psobject]
        $FixText
    )

    if ($FixText -match 'Get-VirtualSwitch')
    {
        $vsphereAllowPromiscuous = ($FixText | Select-String -Pattern '(?<=AllowPromiscuous\s)(.\w+)').Matches.Value
    }

    if ($null -ne $vsphereAllowPromiscuous)
    {
        Write-Verbose -Message $("[$($MyInvocation.MyCommand.Name)] Found AllowPromiscuous value: {0}" -f $vsphereAllowPromiscuous)
        return $vsphereAllowPromiscuous
    }
    else
    {
        return $null
    }
}