Skip to content

Commit

Permalink
Improve SIP detection by using csrutil
Browse files Browse the repository at this point in the history
  • Loading branch information
F1248 committed Dec 30, 2024
1 parent 819f1de commit 0d48695
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Genius/Extensions/Swift/Bool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ extension Bool: DataInitializable {
guard
let string = string.map({ $0[($0.range(of: ":", options: .backwards)?.upperBound ?? $0.startIndex)...] })?.lowercased()
else { return nil }
if string.contains(any: [
if string.contains(anyWholeWord: [
"yes",
"on",
"true",
"enabled",
]) {
self = true
} else if string.contains(any: [
} else if string.contains(anyWholeWord: [
"no",
"off",
"false",
Expand Down
8 changes: 6 additions & 2 deletions Genius/Extensions/Swift/StringProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@ extension StringProtocol {
self.init(data)
}

func contains(any strings: [some StringProtocol]) -> Bool {
strings.contains(where: contains)
func contains(anyWholeWord strings: [String]) -> Bool {
strings.contains { contains(wholeWord: $0) }
}

func contains(wholeWord: String) -> Bool {
components(separatedBy: .alphanumerics.inverted).contains(wholeWord)
}

func remove(_ string: some StringProtocol) -> String {
Expand Down
2 changes: 1 addition & 1 deletion Genius/Models/SystemInformation/MaintenanceChecks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ extension SystemInformation {
enum MalwareProtection {

static let systemIntegrityProtection = SystemInformationData<Bool?>(
{ Bool(SystemProfiler.software?["system_integrity"] as? String) },
{ Bool(Process("/usr/bin/csrutil", ["status"])?.runSafe()) },
applicable: Software.OS.bootMode.value !=? .recovery
)
static let firewall = SystemInformationData<Bool?>(
Expand Down

0 comments on commit 0d48695

Please sign in to comment.