-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Add windows.optionalfeatures resource
Related-to #3705 Signed-off-by: Christian Zunker <[email protected]>
- Loading branch information
Showing
9 changed files
with
1,119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,3 +91,4 @@ vulnerabilityassessmentsettings | |
vulnmgmt | ||
wil | ||
xssmatchstatement | ||
optionalfeature |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright (c) Mondoo, Inc. | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
|
||
package windows | ||
|
||
import ( | ||
"encoding/json" | ||
"io" | ||
) | ||
|
||
const QUERY_OPTIONAL_FEATURES = "Get-WindowsOptionalFeature -Online -FeatureName * | Select-Object -Property FeatureName,DisplayName,Description,State | ConvertTo-Json" | ||
|
||
type WindowsOptionalFeature struct { | ||
Name string `json:"FeatureName"` | ||
DisplayName string `json:"DisplayName"` | ||
Description string `json:"Description"` | ||
Enabled bool `json:"Enabled"` | ||
State int64 `json:"State"` | ||
} | ||
|
||
func ParseWindowsOptionalFeatures(input io.Reader) ([]WindowsOptionalFeature, error) { | ||
data, err := io.ReadAll(input) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
// for empty result set do not get the '{}', therefore lets abort here | ||
if len(data) == 0 { | ||
return []WindowsOptionalFeature{}, nil | ||
} | ||
|
||
var winFeatures []WindowsOptionalFeature | ||
err = json.Unmarshal(data, &winFeatures) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
for i := range winFeatures { | ||
if winFeatures[i].State == 2 { | ||
winFeatures[i].Enabled = true | ||
} | ||
} | ||
|
||
return winFeatures, nil | ||
} |
Oops, something went wrong.