-
Notifications
You must be signed in to change notification settings - Fork 34
✨ Add macOS FileVault, Gatekeeper, and SIP resources #7059
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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,47 @@ | ||
| // Copyright (c) Mondoo, Inc. | ||
| // SPDX-License-Identifier: BUSL-1.1 | ||
|
|
||
| package resources | ||
|
|
||
| import ( | ||
| "io" | ||
| "strings" | ||
|
|
||
| "go.mondoo.com/mql/v13/providers/os/connection/shared" | ||
| ) | ||
|
|
||
| func (m *mqlMacosFilevault) status() (string, error) { | ||
| conn := m.MqlRuntime.Connection.(shared.Connection) | ||
|
|
||
| cmd, err := conn.RunCommand("fdesetup status") | ||
| if err != nil { | ||
| return "", err | ||
| } | ||
|
|
||
| data, err := io.ReadAll(cmd.Stdout) | ||
| if err != nil { | ||
| return "", err | ||
| } | ||
|
|
||
| // fdesetup status outputs lines like: | ||
| // "FileVault is On." | ||
| // "FileVault is Off." | ||
| // "Encryption in progress: Percent completed = 50.0" | ||
| // "Decryption in progress: Percent completed = 50.0" | ||
| output := strings.TrimSpace(string(data)) | ||
|
|
||
| // Return the first line which contains the primary status | ||
| lines := strings.SplitN(output, "\n", 2) | ||
| return strings.TrimSpace(lines[0]), nil | ||
| } | ||
|
|
||
| func (m *mqlMacosFilevault) enabled() (bool, error) { | ||
| status, err := m.status() | ||
| if err != nil { | ||
| return false, err | ||
| } | ||
|
|
||
| // FileVault is considered enabled if it's on or encryption is in progress | ||
| return strings.Contains(status, "FileVault is On") || | ||
| strings.Contains(status, "Encryption in progress"), nil | ||
| } | ||
mondoo-code-review[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or 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,39 @@ | ||
| // Copyright (c) Mondoo, Inc. | ||
| // SPDX-License-Identifier: BUSL-1.1 | ||
|
|
||
| package resources | ||
|
|
||
| import ( | ||
| "io" | ||
| "strings" | ||
|
|
||
| "go.mondoo.com/mql/v13/providers/os/connection/shared" | ||
| ) | ||
|
|
||
| func (m *mqlMacosGatekeeper) status() (string, error) { | ||
| conn := m.MqlRuntime.Connection.(shared.Connection) | ||
|
|
||
| cmd, err := conn.RunCommand("spctl --status") | ||
| if err != nil { | ||
| return "", err | ||
| } | ||
|
|
||
| data, err := io.ReadAll(cmd.Stdout) | ||
| if err != nil { | ||
| return "", err | ||
| } | ||
|
|
||
| // spctl --status outputs: | ||
| // "assessments enabled" (Gatekeeper on) | ||
| // "assessments disabled" (Gatekeeper off) | ||
| return strings.TrimSpace(string(data)), nil | ||
| } | ||
|
|
||
| func (m *mqlMacosGatekeeper) enabled() (bool, error) { | ||
| status, err := m.status() | ||
| if err != nil { | ||
| return false, err | ||
| } | ||
|
|
||
| return strings.Contains(status, "assessments enabled"), nil | ||
| } | ||
mondoo-code-review[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or 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,44 @@ | ||
| // Copyright (c) Mondoo, Inc. | ||
| // SPDX-License-Identifier: BUSL-1.1 | ||
|
|
||
| package resources | ||
|
|
||
| import ( | ||
| "io" | ||
| "strings" | ||
|
|
||
| "go.mondoo.com/mql/v13/providers/os/connection/shared" | ||
| ) | ||
|
|
||
| func (m *mqlMacosSip) status() (string, error) { | ||
| conn := m.MqlRuntime.Connection.(shared.Connection) | ||
|
|
||
| cmd, err := conn.RunCommand("csrutil status") | ||
| if err != nil { | ||
| return "", err | ||
| } | ||
|
|
||
| data, err := io.ReadAll(cmd.Stdout) | ||
| if err != nil { | ||
| return "", err | ||
| } | ||
|
|
||
| // csrutil status outputs: | ||
| // "System Integrity Protection status: enabled." | ||
| // "System Integrity Protection status: disabled." | ||
| // May also include individual configuration flags on separate lines | ||
| output := strings.TrimSpace(string(data)) | ||
|
|
||
| // Return the first line which contains the primary status | ||
| lines := strings.SplitN(output, "\n", 2) | ||
| return strings.TrimSpace(lines[0]), nil | ||
| } | ||
|
|
||
| func (m *mqlMacosSip) enabled() (bool, error) { | ||
| status, err := m.status() | ||
| if err != nil { | ||
| return false, err | ||
| } | ||
|
|
||
| return strings.Contains(status, "enabled"), nil | ||
mondoo-code-review[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
mondoo-code-review[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
mondoo-code-review[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.