Skip to content

Commit

Permalink
Fix for missing PKI key pairs in SSH check
Browse files Browse the repository at this point in the history
ref: #88
  • Loading branch information
dz0ny committed Dec 13, 2021
1 parent 9a0f7a7 commit e60984d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
27 changes: 16 additions & 11 deletions Pareto/Checks/Access Security/SSHKeys.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,23 @@ class SSHKeysCheck: ParetoCheck {
}

override func checkPasses() -> Bool {
let files = try? FileManager.default.contentsOfDirectory(at: sshPath, includingPropertiesForKeys: nil)
for pub in (files!.filter { $0.pathExtension == "pub" }) {
let privateKey = pub.path.replacingOccurrences(of: ".pub", with: "")
if !itExists(privateKey) {
continue
}
if !isPasswordEnabled(withKey: privateKey) {
os_log("Checking %{public}s", pub.path)
sshKey = pub.lastPathComponent.replacingOccurrences(of: ".pub", with: "")
return false
do {
let files = try FileManager.default.contentsOfDirectory(at: sshPath, includingPropertiesForKeys: nil).filter { $0.pathExtension == "pub" }
for pub in files {
let privateKey = pub.path.replacingOccurrences(of: ".pub", with: "")
if !itExists(privateKey) {
continue
}
if !isPasswordEnabled(withKey: privateKey) {
os_log("Checking %{public}s", pub.path)
sshKey = pub.lastPathComponent.replacingOccurrences(of: ".pub", with: "")
return false
}
}
return true
} catch {
os_log("Failed to check SSH keys %{public}s", error.localizedDescription)
return true
}
return true
}
}
2 changes: 1 addition & 1 deletion Pareto/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>3626</string>
<string>3629</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
Expand Down

0 comments on commit e60984d

Please sign in to comment.