Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

Background Items marks a job whose command is worth a second look

Țugui Dragoș8321bdf6141e
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index f235c3bf..dc5060eb 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -49431,6 +49431,112 @@
}
}
},
+ "It runs a script written into its own file rather than a program on disk. Software installed on purpose can do this too." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Položka spouští skript zapsaný přímo v jejím vlastním souboru, ne program na disku. Totéž může dělat i záměrně nainstalovaný software."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Es führt statt eines Programms auf dem Datenträger ein Skript aus, das direkt in seiner eigenen Datei steht. Auch absichtlich installierte Software kann das tun."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Ejecuta un script escrito dentro de su propio archivo en lugar de un programa del disco. El software instalado a propósito también puede hacerlo."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Il exécute un script écrit dans son propre fichier plutôt qu’un programme présent sur le disque. Un logiciel installé volontairement peut aussi le faire."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Esegue uno script scritto nel suo stesso file anziché un programma presente sul disco. Anche un software installato di proposito può farlo."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "ディスク上のプログラムではなく、自身のファイルに書き込まれたスクリプトを実行します。意図的にインストールしたソフトウェアでも、同じことをする場合があります。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "이 항목은 디스크에 있는 프로그램이 아니라 자체 파일에 작성된 스크립트를 실행합니다. 의도적으로 설치한 소프트웨어도 이렇게 할 수 있습니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Het voert een script uit dat in het eigen bestand is geschreven, in plaats van een programma op de schijf. Software die bewust is geïnstalleerd, kan dit ook doen."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Ta rzecz uruchamia skrypt zapisany w jej własnym pliku, a nie program na dysku. Oprogramowanie zainstalowane celowo też może tak działać."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Ele executa um script escrito no próprio arquivo, em vez de um programa no disco. Software instalado intencionalmente também pode fazer isso."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Rulează un script scris în propriul fișier, nu un program de pe disc. Și software‑ul instalat intenționat poate face acest lucru."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Он запускает скрипт, записанный прямо в его файле, а не программу на диске. Так может делать и намеренно установленное ПО."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Det kör ett skript som är skrivet i den egna filen i stället för ett program på skivan. Programvara som installerats avsiktligt kan också göra så."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Diskteki bir program yerine kendi dosyasına yazılmış bir betik çalıştırıyor. Bilerek yüklenen yazılımlar da bunu yapabilir."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Він запускає скрипт, записаний прямо у власному файлі, а не виконуваний файл на диску. Так може робити й ПЗ, інстальоване навмисно."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "它运行的是写在其自身文件中的脚本,而不是磁盘上的程序。有意安装的软件也可能这样做。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "它執行的是寫在自身檔案中的指令碼,而非磁碟上的程式。刻意安裝的軟體也可能這樣做。"
+ }
+ }
+ }
+ },
"It still leads to something on this Mac." : {
"localizations" : {
"cs" : {
@@ -50307,6 +50413,218 @@
}
}
},
+ "Its command decodes base64, which keeps what it runs from being read at a glance. Software installed on purpose can do this too." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Příkaz položky dekóduje base64, takže to, co spouští, nelze přečíst na první pohled. Totéž může dělat i záměrně nainstalovaný software."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Sein Befehl decodiert base64, sodass sich nicht auf einen Blick lesen lässt, was er ausführt. Auch absichtlich installierte Software kann das tun."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Su comando descodifica base64, lo que impide leer de un vistazo lo que ejecuta. El software instalado a propósito también puede hacerlo."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Sa commande décode du base64, ce qui empêche de voir d’un coup d’œil ce qu’elle exécute. Un logiciel installé volontairement peut aussi le faire."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Il suo comando decodifica testo in base64, così ciò che esegue non si può leggere a colpo d’occhio. Anche un software installato di proposito può farlo."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "コマンドがbase64をデコードするため、実行される内容をひと目で読み取ることができません。意図的にインストールしたソフトウェアでも、同じことをする場合があります。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "이 항목의 명령은 base64를 디코딩하므로 실행하는 내용을 한눈에 읽을 수 없습니다. 의도적으로 설치한 소프트웨어도 이렇게 할 수 있습니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Het commando decodeert base64, waardoor wat het uitvoert niet in één oogopslag te lezen is. Software die bewust is geïnstalleerd, kan dit ook doen."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Polecenie tej rzeczy dekoduje base64, przez co tego, co uruchamia, nie da się odczytać na pierwszy rzut oka. Oprogramowanie zainstalowane celowo też może tak działać."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "O comando dele decodifica base64, o que impede ler de relance o que ele executa. Software instalado intencionalmente também pode fazer isso."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Comanda sa decodează base64, astfel încât ce rulează nu poate fi citit dintr‑o privire. Și software‑ul instalat intenționat poate face acest lucru."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Его команда декодирует base64, из-за чего то, что она запускает, не прочитать с первого взгляда. Так может делать и намеренно установленное ПО."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Kommandot avkodar base64, vilket gör att det som körs inte kan läsas med en snabb blick. Programvara som installerats avsiktligt kan också göra så."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Komutu base64 kodunu çözüyor, bu da çalıştırdığı şeyin bir bakışta okunmasını engelliyor. Bilerek yüklenen yazılımlar da bunu yapabilir."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Його команда декодує base64, тож з першого погляду не видно, що саме вона запускає. Так може робити й ПЗ, інстальоване навмисно."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "它的命令会解码base64,因此它运行的内容无法一眼看出。有意安装的软件也可能这样做。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "它的指令會解碼base64,讓人無法一眼看出它執行的內容。刻意安裝的軟體也可能這樣做。"
+ }
+ }
+ }
+ },
+ "Its command downloads from the internet each time it runs. Software installed on purpose can do this too." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Příkaz položky při každém spuštění stahuje data z internetu. Totéž může dělat i záměrně nainstalovaný software."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Sein Befehl lädt bei jeder Ausführung etwas aus dem Internet. Auch absichtlich installierte Software kann das tun."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Su comando descarga contenido de internet cada vez que se ejecuta. El software instalado a propósito también puede hacerlo."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Sa commande télécharge du contenu depuis Internet à chaque exécution. Un logiciel installé volontairement peut aussi le faire."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Il suo comando scarica da internet ogni volta che viene eseguito. Anche un software installato di proposito può farlo."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "コマンドが実行されるたびにインターネットからダウンロードします。意図的にインストールしたソフトウェアでも、同じことをする場合があります。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "이 항목의 명령은 실행될 때마다 인터넷에서 다운로드합니다. 의도적으로 설치한 소프트웨어도 이렇게 할 수 있습니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Het commando downloadt iets van het internet telkens wanneer het wordt uitgevoerd. Software die bewust is geïnstalleerd, kan dit ook doen."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Polecenie tej rzeczy przy każdym uruchomieniu pobiera dane z internetu. Oprogramowanie zainstalowane celowo też może tak działać."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "O comando dele baixa conteúdo da internet sempre que é executado. Software instalado intencionalmente também pode fazer isso."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Comanda sa descarcă de pe internet de fiecare dată când rulează. Și software‑ul instalat intenționat poate face acest lucru."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Его команда загружает данные из интернета при каждом запуске. Так может делать и намеренно установленное ПО."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Kommandot hämtar från internet varje gång det körs. Programvara som installerats avsiktligt kan också göra så."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Komutu, her çalıştığında internetten indirme yapıyor. Bilerek yüklenen yazılımlar da bunu yapabilir."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Його команда викачує дані з інтернету під час кожного запуску. Так може робити й ПЗ, інстальоване навмисно."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "它的命令每次运行时都会从互联网下载内容。有意安装的软件也可能这样做。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "它的指令每次執行時都會從網際網路下載內容。刻意安裝的軟體也可能這樣做。"
+ }
+ }
+ }
+ },
"Its maker has deprecated it." : {
"localizations" : {
"cs" : {
@@ -51155,6 +51473,112 @@
}
}
},
+ "Its program sits in a temporary folder, where any program on this Mac can write. Software installed on purpose can do this too." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Program, který položka spouští, je v dočasné složce, kam může zapisovat kterýkoli program v tomto Macu. Totéž může dělat i záměrně nainstalovaný software."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Sein Programm liegt in einem temporären Ordner, in den jedes Programm auf diesem Mac schreiben kann. Auch absichtlich installierte Software kann das tun."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Su programa está en una carpeta temporal, donde cualquier programa de este Mac puede escribir. El software instalado a propósito también puede hacerlo."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Son programme se trouve dans un dossier temporaire, où n’importe quel programme de ce Mac peut écrire. Un logiciel installé volontairement peut aussi le faire."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Il suo programma si trova in una cartella temporanea, dove qualsiasi programma su questo Mac può scrivere. Anche un software installato di proposito può farlo."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "プログラムが一時フォルダにあり、そこにはこのMac上のどのプログラムでも書き込めます。意図的にインストールしたソフトウェアでも、同じことをする場合があります。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "이 항목의 프로그램은 이 Mac의 모든 프로그램이 쓸 수 있는 임시 폴더에 있습니다. 의도적으로 설치한 소프트웨어도 이렇게 할 수 있습니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Het programma staat in een tijdelijke map, waarin elk programma op deze Mac kan schrijven. Software die bewust is geïnstalleerd, kan dit ook doen."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Program tej rzeczy znajduje się w folderze tymczasowym, w którym może zapisywać każdy program na tym Macu. Oprogramowanie zainstalowane celowo też może tak działać."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "O programa que ele executa fica em uma pasta temporária, onde qualquer programa deste Mac pode gravar. Software instalado intencionalmente também pode fazer isso."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Programul său se află într‑un dosar temporar, în care poate scrie orice program de pe acest Mac. Și software‑ul instalat intenționat poate face acest lucru."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Его программа находится во временной папке, в которую может записывать любая программа на этом Mac. Так может делать и намеренно установленное ПО."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Programmet ligger i en tillfällig mapp, där alla program på den här datorn kan skriva. Programvara som installerats avsiktligt kan också göra så."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Programı, bu Mac’teki her programın yazabildiği geçici bir klasörde duruyor. Bilerek yüklenen yazılımlar da bunu yapabilir."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Його виконуваний файл лежить у тимчасовій папці, куди може записувати будь-яка програма на цьому Mac. Так може робити й ПЗ, інстальоване навмисно."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "它的程序位于临时文件夹中,这台Mac上的任何程序都可以在那里写入。有意安装的软件也可能这样做。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "它的程式位於暫存檔案夾中,這部Mac上的任何程式都能寫入該處。刻意安裝的軟體也可能這樣做。"
+ }
+ }
+ }
+ },
"Its source no longer matches what Homebrew first checked, so the maker’s repository may have been tampered with." : {
"localizations" : {
"cs" : {
@@ -131101,6 +131525,112 @@
}
}
},
+ "Unusual command" : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Neobvyklý příkaz"
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Ungewöhnlicher Befehl"
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Comando inusual"
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Commande inhabituelle"
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Comando insolito"
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "通常とは異なるコマンド"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "일반적이지 않은 명령"
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Ongebruikelijk commando"
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nietypowe polecenie"
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Comando incomum"
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Comandă neobișnuită"
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Необычная команда"
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Ovanligt kommando"
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Alışılmadık komut"
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Незвична команда"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "不寻常的命令"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "不尋常的指令"
+ }
+ }
+ }
+ },
"Up to date" : {
"localizations" : {
"cs" : {
diff --git a/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItem.swift b/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItem.swift
index 4d2bba57..d192b6f8 100644
--- a/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItem.swift
+++ b/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItem.swift
@@ -44,6 +44,8 @@ public struct BackgroundItem: Sendable, Hashable, Identifiable {
/// True for a file launchd can't load: not a property list, or one without a `Label`. It is named by its file,
/// and nothing but moving it is offered.
public var isUnreadable = false
+ /// What in the job's command is worth a second look, if anything.
+ public var unusualCommand: UnusualCommand?
/// Includes the file's path, because two files can declare one label (a per-user copy beside the
/// system-wide one), and each file needs a row of its own.
diff --git a/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItems.swift b/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItems.swift
index bbfa4ede..61815775 100644
--- a/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItems.swift
+++ b/Packages/PeelCore/Sources/PeelCore/BackgroundItems/BackgroundItems.swift
@@ -168,7 +168,8 @@ public enum BackgroundItems {
isOrphan: ownership.isOrphan(label: job.label, program: job.program, owner: owner),
state: loaded.state(of: job.label, kind),
isDisabled: loaded.override(of: job.label, kind) ?? job.isDisabled,
- isOwnerConfirmed: owner?.isConfirmed ?? false
+ isOwnerConfirmed: owner?.isConfirmed ?? false,
+ unusualCommand: UnusualCommand(arguments: job.arguments)
))
}
}
@@ -252,7 +253,8 @@ public enum BackgroundItems {
isOrphan: ownership.isOrphan(label: candidate.label, program: program, owner: owner),
state: loaded.state(of: candidate.label, candidate.kind),
isDisabled: loaded.override(of: candidate.label, candidate.kind) ?? false,
- isOwnerConfirmed: owner?.isConfirmed ?? false
+ isOwnerConfirmed: owner?.isConfirmed ?? false,
+ unusualCommand: UnusualCommand(arguments: job?.arguments ?? program.map { [$0] } ?? [])
)
}
@@ -266,6 +268,8 @@ public enum BackgroundItems {
struct JobDefinition {
let label: String
let program: String?
+ /// The program and its arguments, as launchd runs them.
+ let arguments: [String]
let runsAtLoad: Bool
let keepsAlive: Bool
let isDisabled: Bool
@@ -282,8 +286,10 @@ struct JobDefinition {
init?(_ plist: [String: Any]) {
guard let label = plist["Label"] as? String, !label.isEmpty else { return nil }
self.label = label
- // Reads only the first argument: a cast to `[String]` fails when any argument is not a string.
+ // Reads each argument alone: a cast to `[String]` fails when any argument is not a string.
+ let listed = (plist["ProgramArguments"] as? [Any])?.compactMap { $0 as? String } ?? []
program = plist["Program"] as? String ?? (plist["ProgramArguments"] as? [Any])?.first as? String
+ arguments = (plist["Program"] as? String).map { [$0] + listed.dropFirst() } ?? listed
keepsAlive = (plist["KeepAlive"] as? Bool) ?? (plist["KeepAlive"] is [String: Any])
// `man launchd.plist`, KeepAlive: "The use of this key implicitly implies RunAtLoad".
runsAtLoad = (plist["RunAtLoad"] as? Bool ?? false) || keepsAlive
diff --git a/Packages/PeelCore/Sources/PeelCore/BackgroundItems/UnusualCommand.swift b/Packages/PeelCore/Sources/PeelCore/BackgroundItems/UnusualCommand.swift
new file mode 100644
index 00000000..501afafa
--- /dev/null
+++ b/Packages/PeelCore/Sources/PeelCore/BackgroundItems/UnusualCommand.swift
@@ -0,0 +1,39 @@
+import Foundation
+internal import PeelPrivileged
+
+/// What in a job's command is worth a second look, read from the command's shape and never from a name. It claims
+/// nothing about the job: software installed on purpose can do any of these.
+public enum UnusualCommand: String, Sendable, Hashable {
+ /// The program sits in a temporary folder, which any process on the Mac can write to.
+ case runsFromATemporaryFolder
+ /// The command downloads, with `curl` or `wget`.
+ case downloads
+ /// The command decodes base64, a way to carry a script that can't be read at a glance.
+ case decodesBase64
+ /// A shell or an interpreter runs code written into the job's own file, after `-c` or `-e`.
+ case runsCodeFromItsSettings
+
+ private static let temporaryFolders = ["/tmp", "/private/tmp", "/var/tmp", "/private/var/tmp"]
+ private static let downloaders: Set = ["curl", "wget"]
+ private static let interpreters: Set = [
+ "sh", "bash", "zsh", "dash", "ksh", "csh", "tcsh", "fish",
+ "python", "python3", "perl", "ruby", "node", "php", "osascript",
+ ]
+
+ /// `arguments` are the program and its arguments, as launchd runs them.
+ init?(arguments: [String]) {
+ guard let program = arguments.first else { return nil }
+ let name = (program as NSString).lastPathComponent
+ if Self.temporaryFolders.contains(where: { PathComponents.isPath(program, inside: $0) }) {
+ self = .runsFromATemporaryFolder
+ } else if Self.downloaders.contains(name) {
+ self = .downloads
+ } else if arguments.contains(where: { $0.contains("base64") }) {
+ self = .decodesBase64
+ } else if Self.interpreters.contains(name), arguments.dropFirst().contains(where: ["-c", "-e"].contains) {
+ self = .runsCodeFromItsSettings
+ } else {
+ return nil
+ }
+ }
+}
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/BackgroundItemActionsTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/BackgroundItemActionsTests.swift
index 75c97ee2..8995ebad 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/BackgroundItemActionsTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/BackgroundItemActionsTests.swift
@@ -128,6 +128,32 @@ struct DeclaredBackgroundItemsTests {
)
}
+ /// launchd runs a program with the arguments after it, and a program named apart from them (`Program`) takes the
+ /// place of the first. The whole command is read for its shape.
+ @Test func readsTheWholeCommandOfAJob() throws {
+ let directory = try TemporaryDirectory()
+ let fetches: [String: Any] = [
+ "Label": "org.example.fetch", "ProgramArguments": ["/usr/bin/curl", "-fsSL", "https://example.org"],
+ ]
+ let named: [String: Any] = [
+ "Label": "org.example.named", "Program": "/bin/sh", "ProgramArguments": ["sh", "-c", "true"],
+ ]
+ for (label, plist) in ["org.example.fetch": fetches, "org.example.named": named] {
+ let data = try PropertyListSerialization.data(fromPropertyList: plist, format: .xml, options: 0)
+ try directory.file("home/Library/LaunchAgents/\(label).plist", contents: data)
+ }
+ let agent = try job("org.example.agent", program: "/bin/sleep")
+ try directory.file("home/Library/LaunchAgents/org.example.agent.plist", contents: agent)
+
+ let ownership = BackgroundItemOwnership(installedApps: [])
+ let items = BackgroundItems.declared(in: environment(directory), ownership: ownership)
+
+ let shapes = Dictionary(uniqueKeysWithValues: items.map { ($0.label, $0.unusualCommand) })
+ #expect(shapes["org.example.fetch"] == .downloads)
+ #expect(shapes["org.example.named"] == .runsCodeFromItsSettings)
+ #expect(shapes["org.example.agent"] == .some(nil))
+ }
+
/// A file in these folders that can't be read as a job, not a property list or one without a `Label`, is one
/// launchd can't load. It is listed under its file name so it can be moved to the Trash, and nothing else is
/// offered for it.
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/UnusualCommandTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/UnusualCommandTests.swift
new file mode 100644
index 00000000..c84d7bbe
--- /dev/null
+++ b/Packages/PeelCore/Tests/PeelCoreTests/UnusualCommandTests.swift
@@ -0,0 +1,25 @@
+import Foundation
+@testable import PeelCore
+import Testing
+
+struct UnusualCommandTests {
+ /// A command is worth a second look for its shape, never for a name: what it runs, from where, and how.
+ @Test func readsTheShapeOfAJobsCommand() {
+ let cases: [([String], UnusualCommand?)] = [
+ (["/usr/bin/curl", "-fsSL", "https://example.org/x.sh"], .downloads),
+ (["/usr/local/bin/wget", "-q", "https://example.org/x"], .downloads),
+ (["/bin/sh", "-c", "echo hello"], .runsCodeFromItsSettings),
+ (["/usr/bin/osascript", "-e", "display dialog \"hi\""], .runsCodeFromItsSettings),
+ (["/usr/bin/python3", "-c", "print(1)"], .runsCodeFromItsSettings),
+ (["/private/tmp/org.example.helper", "--daemon"], .runsFromATemporaryFolder),
+ (["/tmp/helper"], .runsFromATemporaryFolder),
+ (["/bin/bash", "/Library/Scripts/run.sh", "base64", "--decode"], .decodesBase64),
+ (["/Applications/Example.app/Contents/MacOS/Example", "--background"], nil),
+ (["/bin/sh", "/Library/Application Support/Example/start.sh"], nil),
+ (["/usr/bin/open", "-e", "/Users/Shared/notes.txt"], nil),
+ ]
+ for (arguments, expected) in cases {
+ #expect(UnusualCommand(arguments: arguments) == expected, "\(arguments)")
+ }
+ }
+}
diff --git a/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift b/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift
index 15a3c03f..739f3715 100644
--- a/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift
+++ b/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift
@@ -253,6 +253,14 @@ struct BackgroundItemDetailView: View {
detail: Text("The program it starts is gone, and no installed app claims it.")
)
}
+ if let unusual = item.unusualCommand {
+ NoteBadge(
+ title: Text("Unusual command"), systemImage: "exclamationmark.magnifyingglass",
+ tint: .orange,
+ name: String(localized: "Unusual command"),
+ detail: Text(unusual.explanation)
+ )
+ }
if needsHelper {
Badge(title: Text("Needs administrator access"), systemImage: "lock", tint: .secondary)
}
@@ -343,3 +351,18 @@ struct BackgroundItemDetailView: View {
}
}
+
+extension UnusualCommand {
+ var explanation: LocalizedStringResource {
+ switch self {
+ case .runsFromATemporaryFolder:
+ "Its program sits in a temporary folder, where any program on this Mac can write. Software installed on purpose can do this too."
+ case .downloads:
+ "Its command downloads from the internet each time it runs. Software installed on purpose can do this too."
+ case .decodesBase64:
+ "Its command decodes base64, which keeps what it runs from being read at a glance. Software installed on purpose can do this too."
+ case .runsCodeFromItsSettings:
+ "It runs a script written into its own file rather than a program on disk. Software installed on purpose can do this too."
+ }
+ }
+}
diff --git a/Peel/Views/BackgroundItems/BackgroundItemList.swift b/Peel/Views/BackgroundItems/BackgroundItemList.swift
index 1024da6f..b2fa0ffc 100644
--- a/Peel/Views/BackgroundItems/BackgroundItemList.swift
+++ b/Peel/Views/BackgroundItems/BackgroundItemList.swift
@@ -149,6 +149,12 @@ private struct BackgroundItemRow: View {
.foregroundStyle(.secondary)
.lineLimit(1)
}
+ if item.unusualCommand != nil {
+ WarningLabel(title: Text("Unusual command"))
+ .font(.caption)
+ .foregroundStyle(.secondary)
+ .lineLimit(1)
+ }
}
}
.padding(.vertical, 2)