Patch-Runde über einen Ordner und Firmware-Hinweise für Switches

Patch-Runde (Palette): Updates gestaffelt, erst ein Host, dann nach
Freigabe (w) der Rest einzeln. Vorher/nachher Dienste, Ports,
fehlgeschlagene Units und neue Logfehler; Neustart einzeln mit Warten
auf neue Boot-ID; jede Auffälligkeit hält an. Start nur nach zweimal j.

Firmware-Hinweise (F6 s am Netzwerkgerät, Palette für Ordner): CVEs je
Produkt aus der NVD (nur Produktname wird gesendet), Versionsprüfung
lokal, KEV, „behoben ab“. Zuordnung advisory.cpe in den Befehlssätzen.
Doku, Webseite und Kurzreferenz mitgezogen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018i4GUj1JqSmBpmAhAgpD8W
This commit is contained in:
Claude committed 2026-11-14 07:58:58 +00:00
1 parent e268a1c1aa
commit d77faf467f
51 files changed
+2862 -21

No files matched your search

+4 -1
View File
@@ -69,6 +69,8 @@ passen, werden verworfen (ein Toast nennt die IP einmal), weil sich UDP-Absender
nicht als Beweis. Die Liste: Palette *Logwache: Meldungen* oder `w` im Log-Blick; ⏎ springt zum Muster im Log-Blick des Hosts, `x` blendet es als Rauschen aus. Fehlanmeldungen (SSH, Windows 4625) zählen ab 20 in 10 Minuten als Fehler; Link-down-Meldungen behalten die Schwere des Geräts (Cisco `LINK-3` = Fehler).
- **Ordner-Scan** (Palette *Ordner-Scan*): der Log-Blick für alle Hosts eines Ordners auf einmal, nur lesend und ohne Rückfragen (6 gleichzeitig; Server über SSH, Windows über WinRM, Switches über ihre Shell). Eine Zeile pro Host mit kritisch/Fehler/Warnungen, neuen Mustern und dem wichtigsten Muster, dazu *Gemeinsam*: Muster, die auf mehreren Hosts auftauchen. `c` kopiert das Ergebnis als Markdown; die Grundlinie für *Was ist neu?* wird pro Host gespeichert. Als Zeitplan (Art *Ordner-Scan (Logs)*) läuft er z. B. jede Nacht; das Ergebnis steht im Zeitplan und unter *Ordner-Scan: letztes Ergebnis*.
- **Sicherheitscheck (OSV)** (`s` in F6, Palette *Sicherheitscheck*): liest über die offene Sitzung die installierten Pakete eines Linux-Servers, nur lesend (Debian/Ubuntu, RHEL/Rocky/Alma, SUSE, Alpine; mit `sudo -n` auch laufende Docker-/Podman-Container), und gleicht sie mit der öffentlichen [OSV](https://osv.dev)-Datenbank ab. Den Rechner verlassen nur Paketnamen und Versionen, nie Hostnamen oder Terminalinhalt. Das Ergebnis zeigt nur, was zählt: je Paket die höchste Bewertung, ob es eine reparierte Version gibt, ob die CVE auf der CISA-Liste aktiv ausgenutzter Lücken (KEV) steht und ob ein laufender Dienst mit offenem Port das Paket nutzt (`sshd :22`). Was die Distribution als geringfügig einstuft, wird gezählt, aber nicht gezeigt. ⏎ Details, `u` fügt den Update-Befehl für dieses Paket am Prompt ein (nicht ausgeführt), `k` lässt die KI das Risiko in Klartext erklären, `f` nur reparierbare, `x`/`X` nimmt einen Befund für den Host oder den ganzen Ordner hin (kommt zurück, sobald eine neue CVE dazukommt), `n` zeigt hingenommene, `c` kopiert als Markdown. In F6 steht eine Zeile *Sicherheit* mit dem letzten Ergebnis. Beim ersten Mal fragt sshTermy *online* (fragt die OSV-API, klein) oder *offline* (lädt die Datenbank je Distribution einmal am Tag, z. B. 80 MB für Debian; von deinen Paketen verlässt nichts den Rechner); Einstellungen › *Sicherheitscheck (OSV)* ändert das und setzt einen Firmen-Spiegel. Palette *Sicherheitscheck: alle Server im Ordner* prüft einen ganzen Ordner (4 gleichzeitig, eine Zeile pro Host); als Zeitplan (Art *Sicherheitscheck (OSV)*) läuft er z. B. wöchentlich und meldet sich nur, wenn etwas Neues hoch, kritisch oder KEV ist.
- **Firmware-Hinweise für Switches und Firewalls** (`s` in F6 am Netzwerkgerät, Palette *Firmware-Hinweise*): OSV kennt keine Hersteller-Firmware, deshalb fragt sshTermy die NVD (NIST) nach allen CVEs des Produkts (FortiOS, Cisco IOS/IOS XE/NX-OS/ASA, Junos, RouterOS, ArubaOS-Switch/CX, PAN-OS, Arista EOS, SonicOS, OPNsense, pfSense, Sophos, WatchGuard, EXOS, EdgeOS) und prüft die Version selbst. Gesendet wird nur der Produktname, nie die Firmware-Version oder das Gerät. Zeigt Bewertung, aktiv ausgenutzt (CISA KEV), *behoben ab*-Version und ob eine CVE nur bestimmte Modelle betrifft, dazu die Seite mit den Sicherheitsmeldungen des Herstellers. Die Ordner-Variante verbindet sich nicht: Sie nutzt Hersteller und Firmware, die F6 zuletzt gelesen hat. Welches NVD-Produkt zu einem Befehlssatz gehört, steht in dessen YAML (`advisory.cpe`) und lässt sich korrigieren oder ergänzen. Ein kostenloser NVD-API-Schlüssel (Einstellungen › *Sicherheitscheck*) macht es etwa zehnmal schneller; Ergebnisse bleiben 24 h im Zwischenspeicher.
- **Patch-Runde** (Palette *Patch-Runde*): spielt Updates gestaffelt über einen Ordner ein. Du wählst den Ordner, alle Updates oder nur die Pakete mit Lücken aus dem Sicherheitscheck, Neustart wenn nötig oder nicht, und den ersten Host (Test-Hosts werden zuerst vorgeschlagen). Nach zweimal `j` bekommt der erste Host die Updates allein; dann hält die Runde an und `w` setzt mit dem Rest fort, einer nach dem anderen. Vor und nach jedem Host vergleicht sshTermy laufende Dienste, lauschende Ports, fehlgeschlagene Units und neue Fehler im Log; Neustarts laufen einzeln und warten, bis der Host zurück ist (neue Boot-ID). Jede Auffälligkeit hält die Runde an. `x` beendet nach dem laufenden Host (nie mitten im Update), `c` kopiert den Bericht. Braucht root oder sudo (ohne Passwort, gespeichertes Passwort oder einmal gefragt).
- **Config-Sicherung für Switches**: `b` sichert die laufende Konfiguration (`show running-config`; Junos `show configuration | display set`, RouterOS `/export`, FortiOS `show full-configuration`, UniFi `cat /tmp/system.cfg`) verschlüsselt auf dem Rechner, `d` zeigt den Diff zum vorherigen Stand, unveränderte Stände werden nicht doppelt gespeichert.
Nächtlich geht es per Zeitplan (`z`, Art „Config-Sicherung“) für einen ganzen Ordner. **Regeln für Switch-Configs**
(Palette → Einstellungen): `+^ntp server` muss vorkommen, `-telnet-server` darf nicht; jede Sicherung wird geprüft,
@@ -370,7 +372,8 @@ sshtermy mcp # MCP-Server für KI-Clients (stdin/stdout), siehe „
| | Alt+1…4 | Folgebefehl einfügen (ohne Enter; rote zweimal) |
| | Alt+0 | nach einem Fehlschlag: KI erklärt Ursache und schlägt einen Fix vor |
| | Alt+E | Log-Blick: Auffälligkeiten in den Logs (⏎ Zeilen, 1…4 prüfen, k KI erklärt, b KI-Lagebericht, x/X ausblenden, n Was ist neu?, t Zeitleiste, z Zeitraum, w Logwache, s Syslog am Switch einrichten) |
| | F6 → s | Sicherheitscheck (OSV): ⏎ Details, u Update-Befehl einfügen, k KI erklärt, f nur reparierbare, x/X für Host/Ordner hinnehmen, n hingenommene, r neu, o Ordner, c kopieren |
| | F6 → s | am Switch/an der Firewall: Firmware-Hinweise (NVD), c kopieren · am Server: Sicherheitscheck (OSV): ⏎ Details, u Update-Befehl einfügen, k KI erklärt, f nur reparierbare, x/X für Host/Ordner hinnehmen, n hingenommene, r neu, o Ordner, c kopieren |
| | Palette *Patch-Runde* | Updates gestaffelt über einen Ordner: j j starten, w nach dem ersten Host weiter, x nach dem laufenden Host beenden, c Bericht kopieren |
| | Alt+K / Alt+J | KI-Begleiter: Stufe Aus · Leise · Gesprächig · Coach / Begleiter-Leiste |
| | Alt+V | Vorgang über mehrere Fenster: die KI sieht alle verbundenen Fenster |
| Vorgang (Alt+V) | Leertaste / ← → / ⏎ | Fenster wählen / was die KI sieht / Vorgang starten, Frage senden |
+4 -1
View File
@@ -68,6 +68,8 @@ sshTermy is a lean terminal application (TUI, a single file, ~9 MB, no installer
lets them in. The AI status report treats syslog lines as hints, not as proof. The list: palette *Log watch: alerts* or `w` in the log view; ⏎ jumps to the pattern in the host's log view, `x` hides it as noise. Failed sign-ins (SSH, Windows 4625) count as an error from 20 in 10 minutes; link-down messages keep the device's severity (Cisco `LINK-3` = error).
- **Folder scan** (palette *Folder scan*): the log view for every host in a folder at once, read-only and without prompts (6 at a time; servers over SSH, Windows over WinRM, switches via their shell). One line per host with critical/errors/warnings, new patterns and the top pattern, plus *Shared*: patterns that show up on several hosts. `c` copies the result as Markdown; the baseline for *What's new?* is saved per host. As a schedule (kind *Folder scan (logs)*) it runs e.g. every night; the result is in the schedule and under *Folder scan: last result*.
- **Security check (OSV)** (`s` in F6, palette *Security check*): reads the installed packages of a Linux server over the open session, read-only (Debian/Ubuntu, RHEL/Rocky/Alma, SUSE, Alpine; with `sudo -n` also running Docker/Podman containers), and compares them with the public [OSV](https://osv.dev) database. Only package names and versions leave your computer, never host names or terminal content. The result lists only what matters: per package the highest score, whether a fixed version exists, whether the CVE is on the CISA list of actively exploited vulnerabilities (KEV) and whether a running service with an open port uses it (`sshd :22`). Findings the distribution rates as minor are counted but not shown. ⏎ details, `u` inserts the update command for that package at the prompt (not run), `k` lets the AI explain the risk in plain words, `f` only fixable, `x`/`X` accept a finding for the host or the whole folder (comes back when a new CVE appears), `n` shows accepted ones, `c` copies as Markdown. F6 shows a *Security* line with the last result. First use asks *online* (asks the OSV API, small) or *offline* (downloads the database per distribution once a day, e.g. 80 MB for Debian; nothing about your packages leaves the computer); Settings › *Security check (OSV)* changes it and sets a company mirror. Palette *Security check: all servers in folder* checks a whole folder (4 at a time, one line per host); as a schedule (kind *Security check (OSV)*) it runs e.g. weekly and only notifies when something new is high, critical or KEV.
- **Firmware advisories for switches and firewalls** (`s` in F6 on a network device, palette *Firmware advisories*): OSV does not know vendor firmware, so sshTermy asks the NVD (NIST) for all CVEs of the product (FortiOS, Cisco IOS/IOS XE/NX-OS/ASA, Junos, RouterOS, ArubaOS-Switch/CX, PAN-OS, Arista EOS, SonicOS, OPNsense, pfSense, Sophos, WatchGuard, EXOS, EdgeOS) and checks the version itself. Only the product name is sent, never the firmware version or the device. Shows score, actively exploited (CISA KEV), *fixed in* version and whether a CVE only affects certain models, plus the vendor's advisory page. The folder variant does not connect: it uses vendor and firmware as last read by F6. Which NVD product belongs to a command set is in its YAML (`advisory.cpe`), so you can fix or add it. Optional free NVD API key (Settings › *Security check*) makes it about ten times faster; results are cached for 24 h.
- **Patch round** (palette *Patch round*): installs updates across a folder in stages. You choose the folder, all updates or only the packages with vulnerabilities from the security check, reboot if needed or not, and the first host (test hosts are suggested first). After pressing `j` twice, the first host gets the updates alone; then the round pauses and `w` continues with the rest, one after the other. Before and after each host sshTermy compares running services, listening ports, failed units and new errors in the log; reboots happen one at a time and wait for the host to come back (new boot ID). Any finding pauses the round. `x` stops after the current host (never in the middle of an update), `c` copies the report. Needs root or sudo (without password, stored password, or asked once).
- **Config backup for switches**: `b` saves the running configuration (`show running-config`; Junos `show configuration | display set`, RouterOS `/export`, FortiOS `show full-configuration`, UniFi `cat /tmp/system.cfg`) encrypted on your computer, `d` shows the diff to the previous state, unchanged states are not stored twice.
Nightly runs go through a schedule (`z`, type “Config backup”) for a whole folder. **Switch config rules**
(palette → Settings): `+^ntp server` must appear, `-telnet-server` must not; every backup is checked,
@@ -360,7 +362,8 @@ sshtermy mcp # MCP server for AI clients (stdin/stdout), see “sshT
| | Alt+1…4 | insert follow-up command (without Enter; red ones twice) |
| | Alt+0 | after a failure: the AI explains the cause and suggests a fix |
| | Alt+E | log view: anomalies in the logs (⏎ lines, 1…4 check, k AI explains, b AI status report, x/X hide, n what's new, t timeline, z period, w log watch, s syslog setup on switches) |
| | F6 → s | security check (OSV): ⏎ details, u insert update command, k AI explains, f only fixable, x/X accept for host/folder, n accepted, r again, o folder, c copy |
| | F6 → s | on a switch/firewall: firmware advisories (NVD), c copy · on a server: security check (OSV): ⏎ details, u insert update command, k AI explains, f only fixable, x/X accept for host/folder, n accepted, r again, o folder, c copy |
| | Palette *Patch round* | staged updates across a folder: j j start, w continue after the first host, x stop after the current host, c copy report |
| | Alt+K / Alt+J | AI companion: level off · quiet · chatty · coach / companion sidebar |
| | Alt+V | task across several windows: the AI sees all linked windows |
| Task (Alt+V) | Space / ← → / ⏎ | choose windows / what the AI sees / start task, send question |
+4
View File
@@ -37,3 +37,7 @@ samples:
firmware: 4.28.3M
model: DCS-7050SX-64-F
mem: 25
# Firmware-Sicherheitshinweise: Produkt in der NVD (nur der Produktname wird gesendet).
advisory:
cpe: [cpe:2.3:o:arista:eos]
url: https://www.arista.com/en/support/advisories-notices
+5
View File
@@ -19,3 +19,8 @@ logs:
syslog:
steps: [configure terminal, 'logging {{ip}} udp {{port}}', end]
save: write memory
# Firmware-Sicherheitshinweise: Produkt in der NVD (nur der Produktname wird gesendet).
advisory:
cpe: [cpe:2.3:o:arubanetworks:arubaos-cx]
version: '(\d+\.\d+\.\d+)'
url: https://www.arubanetworks.com/support-services/security-bulletins/
+4
View File
@@ -58,3 +58,7 @@ samples:
name: fw1
cpu: 4
mem: 38
# Firmware-Sicherheitshinweise: Produkt in der NVD (nur der Produktname wird gesendet).
advisory:
cpe: [cpe:2.3:a:cisco:adaptive_security_appliance_software]
url: https://sec.cloudapps.cisco.com/security/center/publicationListing.x
+4
View File
@@ -36,3 +36,7 @@ samples:
firmware: 15.2(7)E4
model: WS-C2960X-48FPD-L
name: sw1
# Firmware-Sicherheitshinweise: Produkt in der NVD (nur der Produktname wird gesendet).
advisory:
cpe: [cpe:2.3:o:cisco:ios, cpe:2.3:o:cisco:ios_xe]
url: https://sec.cloudapps.cisco.com/security/center/publicationListing.x
+4
View File
@@ -46,3 +46,7 @@ samples:
name: leaf1
cpu: 5
mem: 34
# Firmware-Sicherheitshinweise: Produkt in der NVD (nur der Produktname wird gesendet).
advisory:
cpe: [cpe:2.3:o:cisco:nx-os]
url: https://sec.cloudapps.cisco.com/security/center/publicationListing.x
+4
View File
@@ -9,3 +9,7 @@ detect:
danger:
- rx: '^\s*(load\s+\S|rollback\s+\d)'
reason: überschreibt die Gerätekonfiguration
# Firmware-Sicherheitshinweise: Produkt in der NVD (nur der Produktname wird gesendet).
advisory:
cpe: [cpe:2.3:o:ui:edgeos]
url: https://community.ui.com/releases
@@ -27,3 +27,7 @@ syslog:
danger:
- rx: '^\s*(unconfigure\s+switch|delete\s+vlan|unconfigure\s+vlan|use\s+image)\b'
reason: löscht Konfiguration oder Speicher des Geräts
# Firmware-Sicherheitshinweise: Produkt in der NVD (nur der Produktname wird gesendet).
advisory:
cpe: [cpe:2.3:o:extremenetworks:exos]
url: https://www.extremenetworks.com/support/security-advisories
+5
View File
@@ -25,3 +25,8 @@ syslog:
danger:
- rx: '^\s*(execute\s+(restore|batch|disk\s+format|factoryreset2|erase-disk))\b'
reason: überschreibt die Gerätekonfiguration
# Firmware-Sicherheitshinweise: Produkt in der NVD (nur der Produktname wird gesendet).
advisory:
cpe: [cpe:2.3:o:fortinet:fortios]
version: '(\d+\.\d+\.\d+)'
url: https://www.fortiguard.com/psirt
+5
View File
@@ -21,3 +21,8 @@ logs:
syslog:
steps: [configure, 'set system syslog host {{ip}} any warning', 'set system syslog host {{ip}} port {{port}}', commit and-quit]
abort: [rollback, exit configuration-mode]
# Firmware-Sicherheitshinweise: Produkt in der NVD (nur der Produktname wird gesendet).
advisory:
cpe: [cpe:2.3:o:juniper:junos]
version: '(?i)(\d+\.\d+[a-z]\d+(?:-s\d+)?)'
url: https://supportportal.juniper.net/
+4
View File
@@ -15,3 +15,7 @@ commands:
cmd: pfctl -si
pick: '(?im)^Status:\s*(\w+)'
read: ['^opnsense-version$']
# Firmware-Sicherheitshinweise: Produkt in der NVD (nur der Produktname wird gesendet).
advisory:
cpe: [cpe:2.3:a:opnsense:opnsense]
url: https://opnsense.org/
+4
View File
@@ -55,3 +55,7 @@ samples:
name: PA-220
cpu: 4
mem: 75
# Firmware-Sicherheitshinweise: Produkt in der NVD (nur der Produktname wird gesendet).
advisory:
cpe: [cpe:2.3:o:paloaltonetworks:pan-os]
url: https://security.paloaltonetworks.com/
+4
View File
@@ -20,3 +20,7 @@ danger:
reason: leert oder deaktiviert die Firewall
- rx: '\b(/etc/rc\.initial\.defaults|rc\.initial\.defaults)\b'
reason: löscht Konfiguration oder Speicher des Geräts
# Firmware-Sicherheitshinweise: Produkt in der NVD (nur der Produktname wird gesendet).
advisory:
cpe: [cpe:2.3:a:netgate:pfsense]
url: https://docs.netgate.com/advisories/
+5
View File
@@ -38,3 +38,8 @@ samples:
Boot Image: Primary
expect:
firmware: WC.16.10.0009
# Firmware-Sicherheitshinweise: Produkt in der NVD (nur der Produktname wird gesendet).
advisory:
cpe: [cpe:2.3:o:arubanetworks:arubaos-switch]
version: '(\d+\.\d+\.\d+)'
url: https://www.arubanetworks.com/support-services/security-bulletins/
+5
View File
@@ -26,3 +26,8 @@ syslog:
danger:
- rx: '^\s*/?(ip\s+firewall\s+\S+\s+remove|interface\s+\S*\s*remove|user\s+remove|ip\s+address\s+remove)\b'
reason: entfernt Konfiguration (VLAN, Routing, Zugang)
# Firmware-Sicherheitshinweise: Produkt in der NVD (nur der Produktname wird gesendet).
advisory:
cpe: [cpe:2.3:o:mikrotik:routeros]
version: '(\d+(?:\.\d+)+)'
url: https://mikrotik.com/download/changelogs
+4
View File
@@ -16,3 +16,7 @@ syslog:
danger:
- rx: '^\s*(restart\s*$|import\s+config\b|restore\s+settings\b)'
reason: überschreibt die Gerätekonfiguration
# Firmware-Sicherheitshinweise: Produkt in der NVD (nur der Produktname wird gesendet).
advisory:
cpe: [cpe:2.3:o:sonicwall:sonicos]
url: https://psirt.global.sonicwall.com/
+4
View File
@@ -12,3 +12,7 @@ parse:
firmware: '(?i)(SFOS\s+[\d.]+(?:\s+MR-\d+)?)'
syslog:
note: "Sophos Firewall: System services › Log settings › Syslog servers › Hinzufügen (IP, UDP, Port)."
# Firmware-Sicherheitshinweise: Produkt in der NVD (nur der Produktname wird gesendet).
advisory:
cpe: [cpe:2.3:o:sophos:sfos]
url: https://www.sophos.com/en-us/security-advisories
+3
View File
@@ -27,3 +27,6 @@ syslog:
danger:
- rx: '(\bsyswrapper\.sh\s+restore-default\b|^\s*set-default\s*$)'
reason: löscht Konfiguration oder Speicher des Geräts
# Firmware-Sicherheitshinweise: Produkt in der NVD (nur der Produktname wird gesendet).
advisory:
url: https://community.ui.com/releases
+4
View File
@@ -13,3 +13,7 @@ parse:
name: '(?im)^\s*system name\s*:\s*(\S+)'
syslog:
note: "WatchGuard: Policy Manager › Setup › Logging › Syslog-Server (IP, Port)."
# Firmware-Sicherheitshinweise: Produkt in der NVD (nur der Produktname wird gesendet).
advisory:
cpe: [cpe:2.3:o:watchguard:fireware]
url: https://www.watchguard.com/wgrd-psirt/advisories
+32 -2
View File
@@ -80,8 +80,9 @@ type Set struct {
Parse Parse `yaml:"parse,omitempty"`
Logs Logs `yaml:"logs,omitempty"`
Syslog Syslog `yaml:"syslog,omitempty"`
Read []string `yaml:"read,omitempty"` // nur eingebaut: weitere Lesebefehle (ganze Zeile)
Danger []Danger `yaml:"danger,omitempty"` // zusätzliche Gefahrenregeln
Advisory Advisory `yaml:"advisory,omitempty"` // Firmware-Sicherheitshinweise (NVD)
Read []string `yaml:"read,omitempty"` // nur eingebaut: weitere Lesebefehle (ganze Zeile)
Danger []Danger `yaml:"danger,omitempty"` // zusätzliche Gefahrenregeln
Variants []Variant `yaml:"variants,omitempty"`
Samples []Sample `yaml:"samples,omitempty"`
@@ -93,6 +94,17 @@ type Set struct {
famEff string // geerbte Familie (Install)
}
// Advisory: woran sshTermy Sicherheitsmeldungen zur Firmware findet.
// CPE: Produkt in der NVD („cpe:2.3:o:fortinet:fortios“), mehrere bei
// Produktfamilien (Cisco IOS und IOS XE). Version: Suchmuster mit einer
// Gruppe, das aus der Firmware-Angabe die Version in NVD-Schreibweise holt.
// URL: Seite des Herstellers mit Sicherheitsmeldungen und Downloads.
type Advisory struct {
CPE []string `yaml:"cpe,omitempty"`
Version string `yaml:"version,omitempty"`
URL string `yaml:"url,omitempty"`
}
// Detect: Merkmale, an denen man das System erkennt (Suchmuster).
type Detect struct {
Banner []string `yaml:"banner,omitempty"` // SSH-Kennung
@@ -360,6 +372,7 @@ func (s *Set) Validate() error {
s.checkParse("parse", s.Parse, bad)
s.checkLogs("logs", s.Logs, bad)
checkSyslog("syslog", s.Syslog, bad)
checkAdvisory(s.Advisory, bad)
if len(s.Variants) > maxVariants {
bad("höchstens %d Varianten", maxVariants)
}
@@ -558,3 +571,20 @@ func SyslogSteps(steps []string, ip string, port int) ([]string, error) {
}
return out, nil
}
var reCPE = regexp.MustCompile(`^cpe:2\.3:[aoh]:[a-z0-9_\-.]+:[a-z0-9_\-.]+$`)
func checkAdvisory(a Advisory, bad func(string, ...any)) {
if len(a.CPE) > 4 {
bad("advisory.cpe: höchstens 4 Produkte")
}
for _, c := range a.CPE {
if !reCPE.MatchString(c) {
bad("advisory.cpe „%s“: Form cpe:2.3:o:hersteller:produkt", c)
}
}
pat("advisory.version", a.Version, false, bad)
if a.URL != "" && (!strings.HasPrefix(a.URL, "https://") || strings.ContainsAny(a.URL, " \t\n\"'<>")) {
bad("advisory.url: nur https-Adressen")
}
}
+9
View File
@@ -304,6 +304,15 @@ func overlay(dst, src *Set, top bool) {
overParse(&dst.Parse, src.Parse)
overLogs(&dst.Logs, src.Logs)
overSyslog(&dst.Syslog, src.Syslog)
if len(src.Advisory.CPE) > 0 {
dst.Advisory.CPE = src.Advisory.CPE
}
if src.Advisory.Version != "" {
dst.Advisory.Version = src.Advisory.Version
}
if src.Advisory.URL != "" {
dst.Advisory.URL = src.Advisory.URL
}
dst.Danger = append(dst.Danger, src.Danger...)
dst.Variants = src.Variants
}
+4
View File
@@ -1194,6 +1194,10 @@ type VulnConfig struct {
Mirror string `json:"mirror,omitempty"`
// NoContainers: laufende Container nicht mitprüfen.
NoContainers bool `json:"no_containers,omitempty"`
// NVDKey: API-Schlüssel der NVD (Firmware-Hinweise; ohne geht es
// langsamer). NVDURL: eigener Spiegel/Proxy der NVD-API.
NVDKey Secret `json:"nvd_key,omitempty"`
NVDURL string `json:"nvd_url,omitempty"`
// Ignore: als „betrifft uns nicht“ ausgeblendet.
Ignore []VulnIgnore `json:"ignore,omitempty"`
}
+123
View File
@@ -0,0 +1,123 @@
package i18n
// Patch-Runde und Firmware-Hinweise (ui/patchround.go, ui/firmware.go).
func init() {
for k, v := range enPatch {
en[k] = v
}
}
var enPatch = map[string]string{
"Sicherheitscheck · Switch: Firmware": "security check · switch: firmware",
"starten (Ordner, erster Host)": "start (folder, first host)",
"nach Prüfung weiter": "continue after checking",
"nach diesem Host beenden": "stop after this host",
"Bericht kopieren": "copy report",
" Letzte Ausgabe:": " Last output:",
" · behoben ab %s": " · fixed in %s",
" · nur bestimmte Modelle": " · certain models only",
"%d gering": "%d low",
"%s mit Auffälligkeiten. Runde angehalten.": "%s has findings. Round paused.",
"(1) = erster Host. Verglichen werden laufende Dienste, offene Ports, fehlgeschlagene Units und neue Fehler im Log (letzte Stunde gegen die 24 h davor). c kopiert den Bericht.": "(1) = first host. Compared: running services, open ports, failed units and new errors in the log (last hour against the 24 h before). c copies the report.",
"Alle verfügbaren Updates": "All available updates",
"Auffälligkeiten": "Findings",
"Der erste Host (Kanarienvogel) bekommt die Updates allein. Danach hält die Runde an und du entscheidest mit w, ob der Rest folgt. Am besten ein Test- oder unwichtiger Host.": "The first host (canary) gets the updates alone. Then the round pauses and you decide with w whether the rest follows. Best a test or less important host.",
"Die NVD kennt keine CVEs zu diesem Produkt. Vermutlich stimmt die Zuordnung (advisory.cpe im Befehlssatz) nicht: das heißt nicht, dass die Firmware sicher ist.": "The NVD knows no CVEs for this product. The mapping (advisory.cpe in the command set) is probably wrong: this does not mean the firmware is safe.",
"Dienste gestoppt": "Services stopped",
"Einzelheiten: Tab des Geräts öffnen, F6 › s. Firmware-Stand aus der letzten Abfrage in F6.": "Details: open the device's tab, F6 › s. Firmware as last read in F6.",
"Erster Host ist durch, ohne Auffälligkeiten.": "First host is done, no findings.",
"Erster Host mit Auffälligkeiten. Bitte ansehen, bevor es weitergeht.": "First host has findings. Please look before continuing.",
"Firmware nicht geprüft · s fragt die NVD": "firmware not checked · s asks the NVD",
"Firmware unbekannt (einmal F6 öffnen)": "firmware unknown (open F6 once)",
"Firmware unbekannt: erst r drücken (liest Modell und Firmware)": "Firmware unknown: press r first (reads model and firmware)",
"Firmware-Hinweise: ": "Firmware advisories: ",
"Firmware-Hinweise: NVD-API-Schlüssel": "Firmware advisories: NVD API key",
"Firmware-Hinweise: Netzwerkgeräte im Ordner": "Firmware advisories: network devices in folder",
"Firmware-Hinweise: Switches und Firewalls im Ordner …": "Firmware advisories: switches and firewalls in folder …",
"Firmware-Hinweise: letztes Ergebnis": "Firmware advisories: last result",
"Geprüft: %s (%d CVEs zum Produkt in der NVD) · %s": "Checked: %s (%d CVEs for the product in the NVD) · %s",
"Hersteller": "Vendor",
"Hersteller unbekannt (einmal F6 öffnen)": "vendor unknown (open F6 once)",
"Hersteller unbekannt: erst r drücken (liest Modell und Firmware)": "Vendor unknown: press r first (reads model and firmware)",
"Host suchen …": "Search host …",
"Keine Linux-Server (SSH) für eine Patch-Runde": "No Linux servers (SSH) for a patch round",
"Keine Switches oder Firewalls gespeichert": "No switches or firewalls saved",
"Kostenlos unter nvd.nist.gov/developers/request-an-api-key. Mit Schlüssel geht die Abfrage etwa zehnmal schneller. Leer = ohne Schlüssel.": "Free at nvd.nist.gov/developers/request-an-api-key. With a key the query is about ten times faster. Empty = no key.",
"NVD kennt das Produkt nicht": "NVD does not know the product",
"NVD kennt das Produkt nicht – CPE im Befehlssatz prüfen": "NVD does not know the product – check the CPE in the command set",
"NVD nicht erreichbar, älterer Stand": "NVD unreachable, older data",
"NVD nicht erreichbar, älterer Stand aus dem Zwischenspeicher.": "NVD unreachable, older data from the cache.",
"NVD ohne Schlüssel": "NVD without key",
"NVD-API-Schlüssel (Firmware-Hinweise) …": "NVD API key (firmware advisories) …",
"NVD-Schlüssel gespeichert": "NVD key saved",
"NVD: Produkt nicht gefunden": "NVD: product not found",
"Neu starten, wenn nötig (einzeln, mit Warten auf Rückkehr)": "Reboot if needed (one at a time, waiting for return)",
"Neue Fehler im Log": "New errors in the log",
"Neustart, wenn nötig": "reboot if needed",
"Nicht neu starten, nur melden": "Don't reboot, just report",
"Noch keine Patch-Runde gelaufen": "No patch round has run yet",
"Nur Pakete mit Lücken aus dem Sicherheitscheck": "Only packages with vulnerabilities from the security check",
"Ordner: %s\nHosts (%d): %s\nErster Host: %s\nEinspielen: %s · %s": "Folder: %s\nHosts (%d): %s\nFirst host: %s\nInstall: %s · %s",
"Patch-Runde": "Patch round",
"Patch-Runde angehalten: ": "Patch round paused: ",
"Patch-Runde fertig: %d ohne Auffälligkeiten, %d mit": "Patch round done: %d without findings, %d with",
"Patch-Runde starten?": "Start patch round?",
"Patch-Runde: ": "Patch round: ",
"Patch-Runde: Neustart?": "Patch round: reboot?",
"Patch-Runde: Ordner wählen": "Patch round: choose folder",
"Patch-Runde: Stand und Bericht": "Patch round: status and report",
"Patch-Runde: Updates gestaffelt über einen Ordner …": "Patch round: staged updates across a folder …",
"Patch-Runde: erster Host fertig, w setzt fort": "Patch round: first host done, w continues",
"Patch-Runde: erster Host mit Auffälligkeiten": "Patch round: first host has findings",
"Patch-Runde: was einspielen?": "Patch round: what to install?",
"Patch-Runde: welcher Host zuerst?": "Patch round: which host first?",
"Ports nicht mehr offen": "Ports no longer open",
"Quelle: NVD (NIST) und CISA-Liste aktiv ausgenutzter Lücken. Die NVD ordnet Versionen nicht immer genau zu: Hersteller-Meldung prüfen.": "Source: NVD (NIST) and the CISA list of actively exploited vulnerabilities. The NVD does not always map versions exactly: check the vendor advisory.",
"Runde beendet.": "Round ended.",
"Sicherheitsmeldungen des Herstellers: ": "Vendor security advisories: ",
"Units fehlgeschlagen": "Units failed",
"Update-Befehl endete mit %d": "Update command exited with %d",
"Updates gestaffelt: erst ein Host, dann nach deiner Freigabe der Rest, einer nach dem anderen. Vorher und nachher prüft sshTermy Dienste, Ports und Logs. Braucht root oder sudo.": "Staged updates: first one host, then after your go-ahead the rest, one after the other. Before and after, sshTermy checks services, ports and logs. Needs root or sudo.",
"Verbindet sich nicht: nutzt Hersteller und Firmware, die F6 zuletzt gelesen hat. An die NVD geht nur der Produktname (z. B. fortios), nie Version oder Gerät.": "Does not connect: uses vendor and firmware as last read by F6. Only the product name goes to the NVD (e.g. fortios), never version or device.",
"alle Updates": "all updates",
"alle verfügbaren Updates": "all available updates",
"behoben ab": "fixed in",
"behoben ab %s · s zeigt mehr": "fixed in %s · s shows more",
"braucht eine Eingabe (%s), die Patch-Runde meldet sich ohne Rückfrage an": "needs input (%s), the patch round signs in without prompts",
"erfolgt": "done",
"erst ein Host": "one host first",
"frage die NVD nach %s …": "asking the NVD for %s …",
"frage die NVD …": "asking the NVD …",
"geschützt": "protected",
"gesetzt": "set",
"j = starten · n = abbrechen": "y = start · n = cancel",
"kein Neustart": "no reboot",
"kein Update-Befehl für diese Paketverwaltung": "no update command for this package manager",
"keine NVD-Zuordnung für diesen Hersteller": "no NVD mapping for this vendor",
"keine bekannte Paketverwaltung (apt, dnf, yum, zypper, apk)": "no known package manager (apt, dnf, yum, zypper, apk)",
"keine bekannten Lücken": "no known vulnerabilities",
"krit": "crit",
"liest Zustand …": "reading state …",
"lässt Dienste hochkommen …": "letting services come up …",
"läuft · x = nach diesem Host beenden · Esc = Fenster zu (läuft weiter)": "running · x = stop after this host · Esc = close window (keeps running)",
"nach %s nicht zurückgekommen": "did not come back after %s",
"nicht gestartet": "not started",
"nur Pakete aus dem Sicherheitscheck": "only packages from the security check",
"nur Pakete mit Lücken aus dem Sicherheitscheck": "only packages with vulnerabilities from the security check",
"nötig": "needed",
"ohne Neustart": "without reboot",
"prüft …": "checking …",
"seit": "since",
"spielt Updates ein …": "installing updates …",
"sshTermy führt die Updates mit root-Rechten aus. Nach dem ersten Host hält die Runde an.": "sshTermy runs the updates with root rights. After the first host the round pauses.",
"startet neu …": "rebooting …",
"sudo braucht ein Passwort, das nicht stimmt oder fehlt": "sudo needs a password that is wrong or missing",
"sudo-Passwort für %s@%s (Patch-Runde)": "sudo password for %s@%s (patch round)",
"w = weiter mit %d Hosts · x = Runde beenden · Esc = Fenster zu (Runde wartet)": "w = continue with %d hosts · x = end round · Esc = close window (round waits)",
"wartet auf Rückkehr …": "waiting for return …",
"| Gerät | Hersteller | Firmware | KEV | kritisch | hoch | behoben ab | Hinweis |\n|---|---|---|---|---|---|---|---|\n": "| Device | Vendor | Firmware | KEV | critical | high | fixed in | Note |\n|---|---|---|---|---|---|---|---|\n",
"| Host | Stand | Pakete | Neustart | Auffälligkeiten |\n|---|---|---|---|---|\n": "| Host | Status | Packages | Reboot | Findings |\n|---|---|---|---|---|\n",
"übersprungen: kein Sicherheitscheck mit Updates": "skipped: no security check with updates",
"„Nur Pakete mit Lücken“ nimmt je Host die Pakete aus dem letzten Sicherheitscheck, für die es ein Update gibt. Hosts ohne Sicherheitscheck werden dann übersprungen.": "“Only packages with vulnerabilities” takes, per host, the packages from the last security check that have an update. Hosts without a security check are then skipped.",
"▲ %d davon sind als produktiv geschützt.": "▲ %d of them are protected as production.",
}
+276
View File
@@ -0,0 +1,276 @@
// Package patchrun: Bausteine für die Patch-Runde über einen Ordner.
//
// Eine Runde spielt Updates gestaffelt ein: erst ein Host (Kanarienvogel),
// dann nach Freigabe der Rest, einer nach dem anderen. Vor und nach dem
// Update hält sie einen Zustand fest (laufende Dienste, lauschende Ports,
// fehlgeschlagene Units, Boot-Kennung) und vergleicht beide. Hier stehen nur
// die Skripte, das Lesen ihrer Ausgabe und der Vergleich; Verbinden und
// Ablauf macht die Oberfläche.
package patchrun
import (
"fmt"
"sort"
"strings"
)
// Manager: Paketverwaltung auf dem Host.
type Manager string
const (
MgrNone Manager = ""
MgrApt Manager = "apt"
MgrDnf Manager = "dnf"
MgrYum Manager = "yum"
MgrZypper Manager = "zypper"
MgrApk Manager = "apk"
MgrMicro Manager = "microdnf" // schlanke RHEL-Abbilder
)
// StateScript: liest den Zustand, nur lesend. Ausgabe Zeile für Zeile
// „schlüssel=wert“.
const StateScript = `export LC_ALL=C
[ "$(id -u)" = 0 ] && echo "root=1"
if command -v apt-get >/dev/null 2>&1; then echo "pm=apt"
elif command -v dnf >/dev/null 2>&1; then echo "pm=dnf"
elif command -v yum >/dev/null 2>&1; then echo "pm=yum"
elif command -v zypper >/dev/null 2>&1; then echo "pm=zypper"
elif command -v apk >/dev/null 2>&1; then echo "pm=apk"
elif command -v microdnf >/dev/null 2>&1; then echo "pm=microdnf"
fi
[ -r /proc/sys/kernel/random/boot_id ] && echo "boot=$(cat /proc/sys/kernel/random/boot_id)"
echo "kernel=$(uname -r)"
if command -v systemctl >/dev/null 2>&1; then
systemctl list-units --type=service --state=running --no-legend --plain 2>/dev/null | awk '{print "svc="$1}'
systemctl list-units --state=failed --no-legend --plain 2>/dev/null | awk '{print "fail="$1}'
elif command -v rc-status >/dev/null 2>&1; then
rc-status -s 2>/dev/null | awk '/started/ {print "svc="$1}'
fi
if command -v ss >/dev/null 2>&1; then
ss -ltnH 2>/dev/null | awk '{print "port="$4}'
elif command -v netstat >/dev/null 2>&1; then
netstat -ltn 2>/dev/null | awk '/LISTEN/ {print "port="$4}'
fi
[ -f /var/run/reboot-required ] && echo "reboot=1"
if command -v needs-restarting >/dev/null 2>&1; then
needs-restarting -r >/dev/null 2>&1; [ $? -eq 1 ] && echo "reboot=1"
fi
if command -v zypper >/dev/null 2>&1; then
zypper -q ps -s 2>/dev/null | grep -qi "reboot is required\|neustart" && echo "reboot=1"
fi
if [ -f /etc/alpine-release ] && [ -d /lib/modules ]; then
ls /lib/modules 2>/dev/null | grep -qx "$(uname -r)" || echo "reboot=1"
fi
exit 0
`
// State: Zustand eines Hosts zu einem Zeitpunkt.
type State struct {
Root bool
Manager Manager
Boot string
Kernel string
Services []string // laufende Dienste
Failed []string // fehlgeschlagene Units
Ports []string // lauschende TCP-Ports „addr:port“
Reboot bool // Neustart nötig
}
// ParseState liest die Ausgabe von StateScript.
func ParseState(out string) State {
var s State
seen := map[string]bool{}
add := func(dst *[]string, k, v string) {
if v == "" || seen[k+v] {
return
}
seen[k+v] = true
*dst = append(*dst, v)
}
for _, ln := range strings.Split(out, "\n") {
k, v, ok := strings.Cut(strings.TrimSpace(ln), "=")
if !ok {
continue
}
switch k {
case "root":
s.Root = v == "1"
case "pm":
s.Manager = Manager(v)
case "boot":
s.Boot = v
case "kernel":
s.Kernel = v
case "svc":
add(&s.Services, k, v)
case "fail":
add(&s.Failed, k, v)
case "port":
add(&s.Ports, k, normPort(v))
case "reboot":
s.Reboot = s.Reboot || v == "1"
}
}
sort.Strings(s.Services)
sort.Strings(s.Failed)
sort.Strings(s.Ports)
return s
}
// normPort: „0.0.0.0:22“, „[::]:22“, „*:22“ → gleiche Schreibweise, damit
// IPv4/IPv6-Doppel nicht als zwei Ports zählen.
func normPort(v string) string {
i := strings.LastIndexByte(v, ':')
if i < 0 {
return v
}
addr, port := v[:i], v[i+1:]
switch strings.Trim(addr, "[]") {
case "0.0.0.0", "::", "*", "":
return "*:" + port
}
if strings.HasPrefix(addr, "127.") || addr == "[::1]" || addr == "::1" {
return "lo:" + port
}
return addr + ":" + port
}
// Diff: was nach dem Update anders ist als vorher.
type Diff struct {
StoppedServices []string // liefen vorher, jetzt nicht
NewFailed []string // jetzt fehlgeschlagen, vorher nicht
ClosedPorts []string // waren offen, jetzt nicht
Rebooted bool
}
// Problems: Zahl der Auffälligkeiten.
func (d Diff) Problems() int { return len(d.StoppedServices) + len(d.NewFailed) + len(d.ClosedPorts) }
// Compare vergleicht vorher und nachher.
func Compare(before, after State) Diff {
d := Diff{Rebooted: before.Boot != "" && after.Boot != "" && before.Boot != after.Boot}
d.StoppedServices = minus(before.Services, after.Services)
d.NewFailed = minus(after.Failed, before.Failed)
d.ClosedPorts = minus(before.Ports, after.Ports)
return d
}
func minus(a, b []string) []string {
in := map[string]bool{}
for _, x := range b {
in[x] = true
}
var out []string
for _, x := range a {
if !in[x] {
out = append(out, x)
}
}
return out
}
// Scope: welche Updates eine Runde einspielt.
type Scope int
const (
ScopeAll Scope = iota // alle verfügbaren Updates
ScopeSecurity // nur Pakete aus dem Sicherheitscheck (bzw. dnf --security)
)
// UpdateScript: Skript, das als root läuft. pkgs nur bei ScopeSecurity
// (Binärpakete aus dem Sicherheitscheck). "" = nichts zu tun oder unbekannte
// Paketverwaltung.
func UpdateScript(m Manager, scope Scope, pkgs []string) string {
q := quoteAll(pkgs)
if scope == ScopeSecurity && len(pkgs) == 0 {
return ""
}
switch m {
case MgrApt:
pre := "export DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=a LC_ALL=C\napt-get update -q || exit $?\n"
opts := "-y -q -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold"
if scope == ScopeSecurity {
return pre + "apt-get install --only-upgrade " + opts + " " + q + "\n"
}
return pre + "apt-get upgrade " + opts + "\n"
case MgrDnf, MgrYum, MgrMicro:
if scope == ScopeSecurity {
return "LC_ALL=C " + string(m) + " -y upgrade " + q + "\n"
}
return "LC_ALL=C " + string(m) + " -y upgrade\n"
case MgrZypper:
if scope == ScopeSecurity {
return "LC_ALL=C zypper -n --non-interactive update " + q + "\n"
}
return "LC_ALL=C zypper -n --non-interactive update\n"
case MgrApk:
if scope == ScopeSecurity {
return "apk update -q || exit $?\napk upgrade " + q + "\n"
}
return "apk update -q || exit $?\napk upgrade\n"
}
return ""
}
// RebootScript: Neustart in einer Sekunde, damit die Sitzung noch sauber
// endet.
const RebootScript = `(sleep 1; if command -v systemctl >/dev/null 2>&1; then systemctl reboot; else reboot; fi) >/dev/null 2>&1 &
exit 0
`
func quoteAll(ps []string) string {
q := make([]string, 0, len(ps))
for _, p := range ps {
if p == "" || strings.ContainsAny(p, " \t\n") {
continue
}
q = append(q, "'"+strings.ReplaceAll(p, "'", `'\''`)+"'")
}
return strings.Join(q, " ")
}
// Tail: die letzten n Zeilen (für den Bericht).
func Tail(out string, n int) string {
lines := strings.Split(strings.TrimRight(out, "\n"), "\n")
if len(lines) > n {
lines = append([]string{fmt.Sprintf("… (%d Zeilen)", len(lines)-n)}, lines[len(lines)-n:]...)
}
return strings.Join(lines, "\n")
}
// Upgraded: Pakete, die laut Ausgabe aktualisiert wurden (grob, für den
// Bericht; 0 = unbekannt oder nichts).
func Upgraded(m Manager, out string) int {
n := 0
for _, ln := range strings.Split(out, "\n") {
ln = strings.TrimSpace(ln)
switch m {
case MgrApt:
if strings.HasPrefix(ln, "Unpacking ") {
n++
}
case MgrDnf, MgrYum:
if strings.HasPrefix(ln, "Upgrading ") || strings.HasPrefix(ln, "Upgrade ") && strings.Contains(ln, "Package") {
continue
}
if strings.HasPrefix(ln, "Upgraded:") {
continue
}
if strings.HasPrefix(ln, "Verifying ") {
n++
}
case MgrZypper:
if strings.HasPrefix(ln, "(") && strings.Contains(ln, "Installing:") {
n++
}
case MgrApk:
if strings.HasPrefix(ln, "(") && strings.Contains(ln, "Upgrading ") {
n++
}
}
}
if m == MgrDnf || m == MgrYum {
n /= 2 // „Verifying“ je Paket für neu und alt
}
return n
}
+72
View File
@@ -0,0 +1,72 @@
package patchrun
import (
"strings"
"testing"
)
func TestParseAndCompare(t *testing.T) {
before := ParseState(`root=1
pm=apt
boot=aaa
svc=ssh.service
svc=nginx.service
svc=cron.service
port=0.0.0.0:22
port=[::]:22
port=0.0.0.0:80
port=127.0.0.1:5432
reboot=0
`)
if before.Manager != MgrApt || !before.Root || len(before.Ports) != 3 || before.Reboot {
t.Fatalf("vorher falsch gelesen: %+v", before)
}
after := ParseState(`pm=apt
boot=bbb
svc=ssh.service
svc=cron.service
fail=nginx.service
port=*:22
port=127.0.0.1:5432
reboot=1
`)
d := Compare(before, after)
if !d.Rebooted || d.Problems() != 3 {
t.Fatalf("Vergleich: %+v", d)
}
if d.StoppedServices[0] != "nginx.service" || d.NewFailed[0] != "nginx.service" || d.ClosedPorts[0] != "*:80" {
t.Fatalf("Vergleich: %+v", d)
}
if !after.Reboot {
t.Fatal("Neustart nötig nicht erkannt")
}
}
func TestUpdateScript(t *testing.T) {
if s := UpdateScript(MgrApt, ScopeAll, nil); !strings.Contains(s, "apt-get upgrade -y") || !strings.Contains(s, "DEBIAN_FRONTEND=noninteractive") {
t.Fatal(s)
}
s := UpdateScript(MgrApt, ScopeSecurity, []string{"openssl", "libssl3", "bad name"})
if !strings.Contains(s, "--only-upgrade") || !strings.Contains(s, "'openssl' 'libssl3'") || strings.Contains(s, "bad") {
t.Fatal(s)
}
if UpdateScript(MgrDnf, ScopeSecurity, nil) != "" {
t.Fatal("ohne Pakete nichts tun")
}
if !strings.Contains(UpdateScript(MgrMicro, ScopeAll, nil), "microdnf -y upgrade") {
t.Fatal("microdnf")
}
if UpdateScript(MgrNone, ScopeAll, nil) != "" {
t.Fatal("unbekannt")
}
}
func TestUpgradedCount(t *testing.T) {
out := "Unpacking openssl (3.0.15-1~deb12u1) over (3.0.11-1~deb12u2) ...\nUnpacking libssl3:amd64 (3.0.15) over (3.0.11) ...\nSetting up openssl\n"
if n := Upgraded(MgrApt, out); n != 2 {
t.Fatal(n)
}
if !strings.HasPrefix(Tail("a\nb\nc\nd", 2), "… (2") {
t.Fatal(Tail("a\nb\nc\nd", 2))
}
}
+18 -1
View File
@@ -2,6 +2,7 @@ package store
import (
"encoding/json"
"strings"
"os"
"path/filepath"
)
@@ -55,7 +56,9 @@ func (s *Store) VulnReports() map[string]json.RawMessage {
return out
}
for k, v := range s.vbase.m {
out[k] = v
if !strings.HasPrefix(k, fwPrefix) {
out[k] = v
}
}
return out
}
@@ -86,3 +89,17 @@ func (s *Store) SetVulnReport(connID string, v json.RawMessage) error {
}
return os.Rename(p+".tmp", p)
}
// Firmware-Hinweise (NVD) für Netzwerkgeräte liegen in derselben Datei,
// unter „fw|<Verbindung>“.
const fwPrefix = "fw|"
// FirmwareReport: letzte Firmware-Prüfung eines Netzwerkgeräts (nil = keine).
func (s *Store) FirmwareReport(connID string) json.RawMessage {
return s.VulnReport(fwPrefix + connID)
}
// SetFirmwareReport speichert die Firmware-Prüfung (nil löscht).
func (s *Store) SetFirmwareReport(connID string, v json.RawMessage) error {
return s.SetVulnReport(fwPrefix+connID, v)
}
+8
View File
@@ -104,6 +104,8 @@ type App struct {
vfold vulnFolderState // Sicherheitscheck über einen Ordner (vulnfolder.go)
vsum map[string]vulnSum
voff *vuln.Offline // Offline-Datenbank (bleibt im Speicher)
fwchk fwState // Firmware-Hinweise (firmware.go)
patch patchState // Patch-Runde (patchround.go)
compUse companionUsage // Begleiter: Anfragen, Tokens (companion.go)
recap *recapState // Begleiter: laufender Rückblick
windowed bool // im eigenen Fenster (internal/gui), SetWindowed
@@ -633,6 +635,12 @@ func (a *App) featureMsg(msg tea.Msg) (tea.Cmd, bool) {
if cmd, ok := a.vulnMsgs(msg); ok {
return cmd, true
}
if cmd, ok := a.firmwareMsgs(msg); ok {
return cmd, true
}
if cmd, ok := a.patchMsgs(msg); ok {
return cmd, true
}
if cmd, ok := a.vulnFolderMsg(msg); ok {
return cmd, true
}
+530
View File
@@ -0,0 +1,530 @@
package ui
import (
"context"
"encoding/json"
"fmt"
"sort"
"strings"
"time"
"charm.land/bubbles/v2/textinput"
tea "charm.land/bubbletea/v2"
"github.com/db9979/sshtermy/internal/cmdset"
"github.com/db9979/sshtermy/internal/domain"
"github.com/db9979/sshtermy/internal/hostinfo"
"github.com/db9979/sshtermy/internal/i18n"
"github.com/db9979/sshtermy/internal/vuln"
)
// Firmware-Hinweise für Switches, Firewalls und Router (F6 s am
// Netzwerkgerät, Palette „Firmware-Hinweise“). OSV kennt keine
// Hersteller-Firmware; sshTermy fragt deshalb die NVD nach allen CVEs des
// Produkts (CPE aus dem Befehlssatz, advisory.cpe) und prüft die Version
// selbst. Nach außen geht nur der Produktname. Für einen Ordner reicht der
// gespeicherte Firmware-Stand aus dem Systemprofil, es wird nicht verbunden.
type fwTarget struct {
conn domain.Connection
vendor string // Befehlssatz
model string
firmware string
}
type fwResult struct {
t fwTarget
rep *vuln.FirmwareReport
err string
url string // Seite des Herstellers
}
type fwState struct {
seq int
busy bool
step string
title string
single bool
res []fwResult
cancel context.CancelFunc
}
type fwStepMsg struct {
seq int
step string
}
type fwDoneMsg struct {
seq int
res []fwResult
}
// fwProduct: CVEs zu einem Produkt (in Tests austauschbar).
var fwProduct = func(a *App) func(ctx context.Context, product string, step func(string)) ([]vuln.NVDCVE, bool, error) {
cfg := a.st.Settings().Vuln
n := &vuln.NVD{HTTP: vuln.HTTP{Cache: vulnCacheDir()}, URL: strings.TrimSpace(cfg.NVDURL), Key: cfg.NVDKey.Reveal()}
return n.Product
}
// fwKEV: Liste aktiv ausgenutzter Lücken (in Tests austauschbar).
var fwKEV = func(ctx context.Context) vuln.KEV {
k, _ := vuln.LoadKEV(ctx, &vuln.HTTP{Cache: vulnCacheDir()})
return k
}
// fwAdvisory: CPE-Angaben des Befehlssatzes.
func fwAdvisory(vendor, model, firmware string) cmdset.Advisory {
return hostinfo.SetOf(hostinfo.Vendor(vendor), model, firmware).Advisory
}
// fwTargetOf: Gerät aus einer Sitzung (F6) bzw. einer Verbindung (Profil).
func fwTargetOf(s *session) (fwTarget, bool) {
t := fwTarget{conn: s.conn, vendor: s.prof.Dialect, model: s.prof.Model, firmware: s.prof.Version}
if s.host.vendor != hostinfo.VendorUnknown {
t.vendor = string(s.host.vendor)
}
if sw := s.host.sw; sw != nil {
if sw.Vendor != hostinfo.VendorUnknown {
t.vendor = string(sw.Vendor)
}
t.model, t.firmware = orDefault(sw.Model, t.model), orDefault(sw.Firmware, t.firmware)
}
return t, t.vendor != "" && t.vendor != "network"
}
func fwTargetConn(c domain.Connection) (fwTarget, bool) {
if c.Profile == nil || c.Profile.Family != domain.FamilyNetwork {
return fwTarget{conn: c}, false
}
p := *c.Profile
return fwTarget{conn: c, vendor: string(hostVendor(p)), model: p.Model, firmware: p.Version}, true
}
// openFirmware: F6 s am Netzwerkgerät.
func (a *App) openFirmware(s *session) tea.Cmd {
t, ok := fwTargetOf(s)
if !ok {
s.host.err = i18n.T("Hersteller unbekannt: erst r drücken (liest Modell und Firmware)")
return nil
}
if t.firmware == "" {
s.host.err = i18n.T("Firmware unbekannt: erst r drücken (liest Modell und Firmware)")
return nil
}
return a.runFirmware(s.conn.Alias, []fwTarget{t}, true)
}
// netConnsIn: Netzwerkgeräte im Ordner.
func (a *App) netConnsIn(folder string) []domain.Connection {
var out []domain.Connection
for _, c := range a.st.Connections() {
if !domain.InFolder(c.Group, folder) {
continue
}
if c.Device == domain.DeviceNetwork || (c.Profile != nil && c.Profile.Family == domain.FamilyNetwork) {
out = append(out, c)
}
}
return out
}
// openFirmwareFolder: Palette „Firmware-Hinweise: Netzwerkgeräte im Ordner“.
func (a *App) openFirmwareFolder() tea.Cmd {
count := map[string]int{}
for _, c := range a.netConnsIn("") {
count[""]++
p := c.Group
for p != "" {
count[p]++
i := strings.LastIndex(p, domain.PathSep)
if i < 0 {
break
}
p = p[:i]
}
}
if count[""] == 0 {
a.flash(i18n.T("Keine Switches oder Firewalls gespeichert"))
return nil
}
var paths []string
for p := range count {
if p != "" {
paths = append(paths, p)
}
}
sort.Strings(paths)
items := []pickItem{{value: "\x00all", label: i18n.T("Alle Verbindungen"), hint: fmt.Sprint(count[""])}}
for _, p := range paths {
items = append(items, pickItem{value: p, label: p, hint: fmt.Sprint(count[p]), indent: strings.Count(p, domain.PathSep)})
}
cur := ""
if a.scr == scrManager {
if r, ok := a.mgrCur(); ok {
if r.isFolder() {
cur = r.node.Path
} else {
cur = r.conn.Group
}
}
}
a.pick = newPicker(i18n.T("Firmware-Hinweise: Netzwerkgeräte im Ordner"), i18n.T("Ordner suchen …"), items, cur, func(it pickItem) tea.Cmd {
f := it.value
if f == "\x00all" {
f = ""
}
var ts []fwTarget
for _, c := range a.netConnsIn(f) {
t, _ := fwTargetConn(c)
ts = append(ts, t)
}
where := f
if where == "" {
where = i18n.T("alle Verbindungen")
}
return a.runFirmware(where, ts, false)
})
a.pick.help = i18n.T("Verbindet sich nicht: nutzt Hersteller und Firmware, die F6 zuletzt gelesen hat. An die NVD geht nur der Produktname (z. B. fortios), nie Version oder Gerät.")
return nil
}
func (a *App) runFirmware(title string, ts []fwTarget, single bool) tea.Cmd {
f := &a.fwchk
if f.cancel != nil {
f.cancel()
}
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Minute)
*f = fwState{seq: f.seq + 1, busy: true, title: title, single: single, cancel: cancel, step: i18n.T("frage die NVD …")}
seq, ev := f.seq, a.events
get := fwProduct(a)
go func() {
defer cancel()
ev <- fwDoneMsg{seq: seq, res: firmwareCheck(ctx, ts, get, fwKEV, func(s string) { ev <- fwStepMsg{seq, s} })}
}()
a.showFirmware()
return nil
}
// firmwareCheck: je Produkt einmal fragen, dann jedes Gerät prüfen.
func firmwareCheck(ctx context.Context, ts []fwTarget, get func(context.Context, string, func(string)) ([]vuln.NVDCVE, bool, error),
kevf func(context.Context) vuln.KEV, step func(string)) []fwResult {
type prod struct {
cves []vuln.NVDCVE
stale bool
err error
}
cache := map[string]*prod{}
var kev vuln.KEV
res := make([]fwResult, len(ts))
for i, t := range ts {
r := fwResult{t: t}
adv := fwAdvisory(t.vendor, t.model, t.firmware)
r.url = adv.URL
switch {
case t.vendor == "" || t.vendor == "network":
r.err = i18n.T("Hersteller unbekannt (einmal F6 öffnen)")
case t.firmware == "":
r.err = i18n.T("Firmware unbekannt (einmal F6 öffnen)")
case len(adv.CPE) == 0:
r.err = i18n.T("keine NVD-Zuordnung für diesen Hersteller")
}
if r.err != "" {
res[i] = r
continue
}
if kev == nil {
kev = kevf(ctx)
if kev == nil {
kev = vuln.KEV{}
}
}
var hits []vuln.FirmwareHit
var total int
var stale bool
var rep *vuln.FirmwareReport
for _, cpe := range adv.CPE {
p := cache[cpe]
if p == nil {
step(fmt.Sprintf(i18n.T("frage die NVD nach %s …"), strings.TrimPrefix(cpe, "cpe:2.3:")))
cv, st, err := get(ctx, cpe, step)
p = &prod{cv, st, err}
cache[cpe] = p
}
if p.err != nil {
r.err = vulnErrText(p.err)
continue
}
x := vuln.FirmwareReportFor(cpe, t.firmware, adv.Version, p.cves, kev)
hits, total, stale = append(hits, x.Hits...), total+x.Total, stale || p.stale
if rep == nil {
rep = x
}
}
if rep != nil {
r.err = ""
rep.Hits, rep.Total, rep.Stale, rep.URL = hits, total, stale, adv.URL
rep.Product = strings.Join(adv.CPE, ", ")
rep.MinFixed = ""
for _, h := range hits {
if h.FixedIn != "" && (rep.MinFixed == "" || vuln.CompareRPM(h.FixedIn, rep.MinFixed) > 0) {
rep.MinFixed = h.FixedIn
}
}
r.rep = rep
}
res[i] = r
}
return res
}
func vulnErrText(err error) string {
if err == nil {
return ""
}
if vuln.IsNotFound(err) {
return i18n.T("NVD: Produkt nicht gefunden")
}
return trunc(err.Error(), 80)
}
func (a *App) firmwareMsgs(msg tea.Msg) (tea.Cmd, bool) {
switch m := msg.(type) {
case fwStepMsg:
if m.seq == a.fwchk.seq {
a.fwchk.step = m.step
if a.modal != nil && a.modal.fw {
a.showFirmware()
}
}
return a.listen(), true
case fwDoneMsg:
f := &a.fwchk
if m.seq != f.seq {
return a.listen(), true
}
f.busy, f.res = false, m.res
for _, r := range m.res {
if r.rep != nil {
if raw, err := json.Marshal(r.rep); err == nil {
_ = a.st.SetFirmwareReport(r.t.conn.ID, raw)
}
}
}
if a.modal != nil && a.modal.fw {
a.showFirmware()
}
return a.listen(), true
}
return nil, false
}
// storedFirmware: letzte Prüfung eines Geräts.
func (a *App) storedFirmware(connID string) *vuln.FirmwareReport {
raw := a.st.FirmwareReport(connID)
if len(raw) == 0 {
return nil
}
var r vuln.FirmwareReport
if json.Unmarshal(raw, &r) != nil {
return nil
}
return &r
}
func fwCountText(c vuln.Counts) string {
if c.Total == 0 {
return i18n.T("keine bekannten Lücken")
}
var p []string
if c.KEV > 0 {
p = append(p, fmt.Sprintf(i18n.T("%d aktiv ausgenutzt"), c.KEV))
}
if c.Critical > 0 {
p = append(p, fmt.Sprintf(i18n.T("%d kritisch"), c.Critical))
}
if c.High > 0 {
p = append(p, fmt.Sprintf(i18n.T("%d hoch"), c.High))
}
if c.Medium > 0 {
p = append(p, fmt.Sprintf(i18n.T("%d mittel"), c.Medium))
}
if n := c.Low + c.Unknown; n > 0 {
p = append(p, fmt.Sprintf(i18n.T("%d gering"), n))
}
return strings.Join(p, " · ")
}
// showFirmware: Ergebnis als Textfenster (c kopiert Markdown).
func (a *App) showFirmware() {
f := &a.fwchk
var lines []string
var md strings.Builder
title := i18n.T("Firmware-Hinweise: ") + f.title
fmt.Fprintf(&md, "# %s\n\n", title)
if f.busy {
lines = append(lines, spinGlyph(time.Now())+" "+f.step, "")
}
if f.single && len(f.res) == 1 {
r := f.res[0]
lines = append(lines, a.fwDetailLines(r, &md)...)
} else if len(f.res) > 0 {
lines = append(lines, fmt.Sprintf("%-22s %-14s %-16s %4s %5s %5s %s", i18n.T("Gerät"), i18n.T("Hersteller"), "Firmware", "KEV", i18n.T("krit"), i18n.T("hoch"), i18n.T("behoben ab")))
md.WriteString(i18n.T("| Gerät | Hersteller | Firmware | KEV | kritisch | hoch | behoben ab | Hinweis |\n|---|---|---|---|---|---|---|---|\n"))
rows := append([]fwResult(nil), f.res...)
sort.SliceStable(rows, func(i, j int) bool { return fwRank(rows[i]) > fwRank(rows[j]) })
for _, r := range rows {
name := trunc(r.t.conn.Alias, 22)
vend := trunc(hostinfo.Vendor(r.t.vendor).Name(), 14)
if r.rep == nil {
lines = append(lines, fmt.Sprintf("%-22s %-14s %-16s %s", name, vend, trunc(orDefault(r.t.firmware, "?"), 16), r.err))
fmt.Fprintf(&md, "| %s | %s | %s | | | | | %s |\n", r.t.conn.Alias, vend, r.t.firmware, r.err)
continue
}
c := r.rep.Counts()
note := ""
if r.rep.Total == 0 {
note = i18n.T("NVD kennt das Produkt nicht – CPE im Befehlssatz prüfen")
} else if r.rep.Stale {
note = i18n.T("NVD nicht erreichbar, älterer Stand")
}
lines = append(lines, fmt.Sprintf("%-22s %-14s %-16s %4d %5d %5d %s %s", name, vend, trunc(r.rep.Raw, 16), c.KEV, c.Critical, c.High, orDefault(r.rep.MinFixed, "–"), note))
fmt.Fprintf(&md, "| %s | %s | %s | %d | %d | %d | %s | %s |\n", r.t.conn.Alias, vend, r.rep.Raw, c.KEV, c.Critical, c.High, r.rep.MinFixed, note)
}
lines = append(lines, "", i18n.T("Einzelheiten: Tab des Geräts öffnen, F6 › s. Firmware-Stand aus der letzten Abfrage in F6."))
}
lines = append(lines, "", i18n.T("Quelle: NVD (NIST) und CISA-Liste aktiv ausgenutzter Lücken. Die NVD ordnet Versionen nicht immer genau zu: Hersteller-Meldung prüfen."))
scroll := 0
if a.modal != nil && a.modal.kind == mText && a.modal.fw {
scroll = a.modal.scroll
}
a.modal = textModal(title, lines)
a.modal.copy, a.modal.scroll, a.modal.fw = md.String(), scroll, true
}
func fwRank(r fwResult) int {
if r.rep == nil {
return -1
}
c := r.rep.Counts()
return c.KEV*10000 + c.Critical*100 + c.High
}
func (a *App) fwDetailLines(r fwResult, md *strings.Builder) []string {
var lines []string
vend := hostinfo.Vendor(r.t.vendor).Name()
head := fmt.Sprintf("%s %s", vend, orDefault(r.t.firmware, "?"))
if r.t.model != "" {
head += " · " + r.t.model
}
lines = append(lines, head)
fmt.Fprintf(md, "%s\n\n", head)
if r.rep == nil {
if r.err != "" {
lines = append(lines, "× "+r.err)
fmt.Fprintf(md, "× %s\n", r.err)
}
if r.url != "" {
lines = append(lines, i18n.T("Sicherheitsmeldungen des Herstellers: ")+r.url)
fmt.Fprintf(md, "%s%s\n", i18n.T("Sicherheitsmeldungen des Herstellers: "), r.url)
}
return lines
}
rep := r.rep
c := rep.Counts()
sum := fwCountText(c)
if rep.MinFixed != "" {
sum += fmt.Sprintf(i18n.T(" · behoben ab %s"), rep.MinFixed)
}
lines = append(lines, sum)
fmt.Fprintf(md, "%s\n\n", sum)
if rep.Total == 0 {
lines = append(lines, i18n.T("Die NVD kennt keine CVEs zu diesem Produkt. Vermutlich stimmt die Zuordnung (advisory.cpe im Befehlssatz) nicht: das heißt nicht, dass die Firmware sicher ist."))
}
if rep.Stale {
lines = append(lines, i18n.T("NVD nicht erreichbar, älterer Stand aus dem Zwischenspeicher."))
}
lines = append(lines, "")
for _, h := range rep.Hits {
lv := vulnLevelLabel(h.Level())
flag := ""
if h.KEV {
flag = " KEV"
}
fix := ""
if h.FixedIn != "" {
fix = fmt.Sprintf(i18n.T(" · behoben ab %s"), h.FixedIn)
}
hw := ""
if h.HW {
hw = i18n.T(" · nur bestimmte Modelle")
}
lines = append(lines, fmt.Sprintf("%-5s %4.1f %-16s%s%s%s", lv, h.Score, h.ID, flag, fix, hw))
if h.Summary != "" {
lines = append(lines, " "+trunc(h.Summary, 160))
}
fmt.Fprintf(md, "- **%s** %s %.1f%s%s%s: %s\n", h.ID, lv, h.Score, flag, fix, hw, h.Summary)
}
lines = append(lines, "", fmt.Sprintf(i18n.T("Geprüft: %s (%d CVEs zum Produkt in der NVD) · %s"), rep.Product, rep.Total, rep.At.Format("02.01.2006 15:04")))
if rep.URL != "" {
lines = append(lines, i18n.T("Sicherheitsmeldungen des Herstellers: ")+rep.URL)
fmt.Fprintf(md, "\n%s%s\n", i18n.T("Sicherheitsmeldungen des Herstellers: "), rep.URL)
}
return lines
}
// viewFirmwareRow: Zeile „Sicherheit“ in F6 bei Netzwerkgeräten.
func (a *App) viewFirmwareRow(b *strings.Builder, s *session, w int) {
st := a.s
label := st.Muted.Render(fmt.Sprintf("%-9s ", i18n.T("Sicherheit")))
if a.fwchk.busy && a.fwchk.single && len(a.fwchk.res) == 0 && a.fwchk.title == s.conn.Alias {
b.WriteString(label + st.AI.Render(trunc(a.fwchk.step, w-10)) + "\n")
return
}
rep := a.storedFirmware(s.conn.ID)
if rep == nil {
b.WriteString(label + st.Muted.Render(trunc(i18n.T("Firmware nicht geprüft · s fragt die NVD"), w-10)) + "\n")
return
}
c := rep.Counts()
style := st.OK
switch {
case c.KEV > 0 || c.Critical > 0:
style = st.Danger
case c.High > 0 || c.Medium > 0:
style = st.Warn
}
txt := fwCountText(c)
if rep.Total == 0 {
style, txt = st.Muted, i18n.T("NVD kennt das Produkt nicht")
}
b.WriteString(label + style.Render(trunc(txt, w-10)) + "\n")
if rep.MinFixed != "" {
b.WriteString(strings.Repeat(" ", 10) + st.Muted.Render(trunc(fmt.Sprintf(i18n.T("behoben ab %s · s zeigt mehr"), rep.MinFixed), w-10)) + "\n")
}
}
// askNVDKey: Einstellungen › Sicherheitscheck › NVD-API-Schlüssel.
func (a *App) askNVDKey() tea.Cmd {
m := inputModal(i18n.T("Firmware-Hinweise: NVD-API-Schlüssel"),
i18n.T("Kostenlos unter nvd.nist.gov/developers/request-an-api-key. Mit Schlüssel geht die Abfrage etwa zehnmal schneller. Leer = ohne Schlüssel."),
"", func(v string) tea.Cmd {
v = strings.TrimSpace(v)
_ = a.st.UpdateSettings(func(s *domain.Settings) { s.Vuln.NVDKey = domain.Secret(v) })
if v == "" {
a.flash(i18n.T("NVD ohne Schlüssel"))
} else {
a.flashOK(i18n.T("NVD-Schlüssel gespeichert"))
}
return nil
})
m.in.EchoMode = textinput.EchoPassword
a.modal = m
return m.in.Focus()
}
func nvdKeyLabel(s domain.Settings) string {
if s.Vuln.NVDKey.IsSet() {
return i18n.T("gesetzt")
}
return i18n.T("keiner")
}
+86
View File
@@ -0,0 +1,86 @@
package ui
import (
"context"
"errors"
"strings"
"testing"
"time"
"github.com/db9979/sshtermy/internal/domain"
"github.com/db9979/sshtermy/internal/vuln"
)
func TestFirmwareFolder(t *testing.T) {
a := vulnTestApp(t)
add := func(alias, dialect, ver string) domain.Connection {
c := domain.Connection{Alias: alias, Host: alias, Username: "admin", Group: "Netz", Device: domain.DeviceNetwork}
if dialect != "" {
c.Profile = &domain.SystemProfile{Family: domain.FamilyNetwork, Dialect: dialect, Version: ver}
}
c, err := a.st.UpsertConnection(c)
if err != nil {
t.Fatal(err)
}
return c
}
fw := add("fw01", "fortios", "v7.2.5,build1517 (GA)")
add("fw02", "fortios", "v7.2.8,build1639 (GA)")
add("sw01", "unifi", "7.0.50")
add("sw02", "", "")
oldP, oldK := fwProduct, fwKEV
defer func() { fwProduct, fwKEV = oldP, oldK }()
asked := map[string]int{}
fwProduct = func(*App) func(context.Context, string, func(string)) ([]vuln.NVDCVE, bool, error) {
return func(_ context.Context, p string, _ func(string)) ([]vuln.NVDCVE, bool, error) {
asked[p]++
if p != "cpe:2.3:o:fortinet:fortios" {
return nil, false, errors.New("falsches Produkt")
}
return []vuln.NVDCVE{{ID: "CVE-2024-21762", Score: 9.8, Summary: "out-of-bounds write", Matches: []vuln.NVDMatch{{StartIncl: "7.2.0", EndExcl: "7.2.7"}}}}, false, nil
}
}
fwKEV = func(context.Context) vuln.KEV { return vuln.KEV{"CVE-2024-21762": {}} }
a.openFirmwareFolder()
if a.pick == nil {
t.Fatal("Ordnerwahl fehlt")
}
a.pickerChoose(pickItem{value: "Netz"})
deadline := time.After(5 * time.Second)
for a.fwchk.busy {
select {
case m := <-a.events:
a.Update(m)
case <-deadline:
t.Fatal("keine Antwort")
}
}
if asked["cpe:2.3:o:fortinet:fortios"] != 1 {
t.Fatalf("Produkt nicht genau einmal gefragt: %v", asked)
}
txt := strings.Join(a.modal.lines, "\n")
for _, w := range []string{"fw01", "7.2.7", "keine NVD-Zuordnung", "Hersteller unbekannt"} {
if !strings.Contains(txt, w) {
t.Fatalf("%q fehlt:\n%s", w, txt)
}
}
// fw01 oben (KEV), gespeichert für F6
if i, j := strings.Index(txt, "fw01"), strings.Index(txt, "fw02"); i > j {
t.Fatalf("Reihenfolge:\n%s", txt)
}
if r := a.storedFirmware(fw.ID); r == nil || r.Counts().KEV != 1 || r.MinFixed != "7.2.7" {
t.Fatalf("nicht gespeichert: %+v", r)
}
// Einzelansicht
a.fwchk = fwState{single: true, title: "fw01", res: []fwResult{{t: fwTarget{conn: fw, vendor: "fortios", firmware: "7.2.5"}, rep: a.storedFirmware(fw.ID)}}}
a.showFirmware()
txt = strings.Join(a.modal.lines, "\n")
if !strings.Contains(txt, "CVE-2024-21762") || !strings.Contains(txt, "KEV") || !strings.Contains(txt, "fortiguard.com") {
t.Fatalf("Einzelansicht:\n%s", txt)
}
// Sicherheits-Ergebnisse des OSV-Checks enthalten keine Firmware-Einträge
if len(a.st.VulnReports()) != 0 {
t.Fatal("Firmware-Bericht taucht im Sicherheitscheck auf")
}
}
+8 -2
View File
@@ -207,7 +207,7 @@ var helpSections = []helpSection{
{"b", "Switch-Config sichern"},
{"c", "Container (Docker, Podman, k8s)"},
{"l", "Log-Blick"},
{"s", "Sicherheitscheck (OSV)"},
{"s", "Sicherheitscheck · Switch: Firmware"},
{"↑ ↓", "Sicherung wählen"},
{"d", "Diff zur Vorversion"},
{"v", "Sicherung ansehen"},
@@ -268,6 +268,12 @@ var helpSections = []helpSection{
{"o", "alle Server im Ordner prüfen"},
{"r / c", "neu prüfen / kopieren"},
}},
{hcVuln, "■", "Patch-Runde", "Palette", false, [][2]string{
{"j j", "starten (Ordner, erster Host)"},
{"w", "nach Prüfung weiter"},
{"x", "nach diesem Host beenden"},
{"c", "Bericht kopieren"},
}},
{hcLogs, "≡", "Sitzungsprotokolle", "l", false, [][2]string{
{"/", "suchen (auch Ausgabe)"},
{"⏎ / → ←", "auf-/zuklappen"},
@@ -489,7 +495,7 @@ var helpTabs = []helpTabDef{
{"Terminal", []string{"Terminal", "Suche im Verlauf", "Tunnel", "Host-Übersicht", "Dateien", "Gefahren & Aufnahme", "Systemprofil"}},
{"KI", []string{"Ziel-Modus", "KI fragen", "KI-Begleiter", "Vorgang über mehrere Fenster", "KI-Einstellungen"}},
{"Manager", []string{"Verbindungs-Manager", "Broadcast", "Netzwerk-Scan"}},
{"Logs", []string{"Log-Blick", "Sicherheitscheck", "Sitzungsprotokolle"}},
{"Logs", []string{"Log-Blick", "Sicherheitscheck", "Patch-Runde", "Sitzungsprotokolle"}},
{"Überall", []string{"Überall", "Befehlspalette", "Aussehen & Tasten", "Maus"}},
}
+5 -3
View File
@@ -632,9 +632,10 @@ func (a *App) hostKey(s *session, k tea.KeyPressMsg) tea.Cmd {
return a.openLogScan(s)
}
case "s":
if !net {
return a.openVuln(s)
if net {
return a.openFirmware(s)
}
return a.openVuln(s)
case "b":
if net && !h.busy {
s.panelFocus = false
@@ -715,7 +716,7 @@ func (a *App) hostPanelKeys(s *session) [][2]string {
if len(s.host.backups) > 0 {
k = append(k, [2]string{"↑↓", i18n.T("Stand")}, [2]string{"v", i18n.T("ansehen")})
}
return append(k, [2]string{"l", "Logs"}, [2]string{"g", i18n.T("Grenzwerte")}, [2]string{"Esc", "Terminal"}, [2]string{a.keys.label(actHost), i18n.T("schließen")})
return append(k, [2]string{"l", "Logs"}, [2]string{"s", i18n.T("Sicherheit")}, [2]string{"g", i18n.T("Grenzwerte")}, [2]string{"Esc", "Terminal"}, [2]string{a.keys.label(actHost), i18n.T("schließen")})
}
k := [][2]string{{"r", i18n.T("aktualisieren")}}
if s.host.live.hasLive() {
@@ -874,6 +875,7 @@ func (a *App) viewHost(b *strings.Builder, s *session, w int) {
row(i18n.T("Modell"), sw.Model)
}
row("Firmware", orDefault(sw.Firmware, "?"))
a.viewFirmwareRow(b, s, w)
if sw.Uptime != "" {
row(i18n.T("Laufzeit"), sw.Uptime)
}
+1 -1
View File
@@ -241,7 +241,7 @@ func (a *App) folderScanMsg(msg tea.Msg) (tea.Cmd, bool) {
if f.allDone() {
a.flashOK(fmt.Sprintf(i18n.T("Ordner-Scan fertig: %d Hosts in %s"), len(f.hosts), durText(time.Since(f.start))))
}
if f.open && a.modal != nil && a.modal.kind == mText && a.modal.copy != "" && !a.modal.vuln {
if f.open && a.modal != nil && a.modal.kind == mText && a.modal.copy != "" && !a.modal.vuln && !a.modal.fw && !a.modal.patch {
a.showFolderScan()
}
return a.listen(), true
+7
View File
@@ -43,6 +43,8 @@ type modal struct {
kind modalKind
copy string // mText: c kopiert diesen Text
vuln bool // mText: Ergebnis des Sicherheitschecks über einen Ordner (vulnfolder.go)
fw bool // mText: Firmware-Hinweise (firmware.go)
patch bool // mText: Patch-Runde (patchround.go)
mail string // mText: m öffnet diese mailto:-Adresse im Mailprogramm
title string
body string
@@ -282,6 +284,11 @@ func (a *App) modalKey(k tea.KeyPressMsg) tea.Cmd {
case mQuick:
return a.quickModalKey(key)
case mText:
if m.patch {
if cmd, ok := a.patchKey(key); ok {
return cmd
}
}
if m.textKey(key) {
a.modal = nil
}
+15 -1
View File
@@ -418,6 +418,18 @@ func (a *App) palActsGlobal(add palAdd, inMgr bool) {
add("net", palItem{icon: ic("lock"), label: i18n.T("Sicherheitscheck: letztes Ergebnis"), hint: a.vfold.folder,
keys: "sicherheit security osv ergebnis folder", run: func() tea.Cmd { a.showVulnFolder(); return nil }})
}
add("net", palItem{icon: ic("lock"), label: i18n.T("Firmware-Hinweise: Switches und Firewalls im Ordner …"), hint: "NVD",
keys: "firmware sicherheit security cve nvd switch firewall router hersteller advisory ordner", run: func() tea.Cmd { return a.openFirmwareFolder() }})
if len(a.fwchk.res) > 0 || a.fwchk.busy {
add("net", palItem{icon: ic("lock"), label: i18n.T("Firmware-Hinweise: letztes Ergebnis"), hint: trunc(a.fwchk.title, 18),
keys: "firmware sicherheit nvd ergebnis", run: func() tea.Cmd { a.showFirmware(); return nil }})
}
add("net", palItem{icon: ic("restart"), label: i18n.T("Patch-Runde: Updates gestaffelt über einen Ordner …"), hint: i18n.T("erst ein Host"),
keys: "patch runde updates upgrade aktualisieren ordner gestaffelt kanarienvogel canary rollout apt dnf neustart reboot", run: func() tea.Cmd { return a.openPatch() }})
if len(a.patch.hosts) > 0 {
add("net", palItem{icon: ic("restart"), label: i18n.T("Patch-Runde: Stand und Bericht"), hint: trunc(orDefault(a.patch.folder, "*"), 18),
keys: "patch runde stand bericht report", run: func() tea.Cmd { a.showPatch(); return nil }})
}
add("team",
palItem{icon: ic("team"), label: i18n.T("Geteilte Sitzung ansehen …"), hint: i18n.T("Code"),
keys: "zusehen watch link code teilen share live einladung", run: func() tea.Cmd { return a.askWatch() }},
@@ -669,7 +681,7 @@ var palSubMenus = []palMenu{
{"settings/relay", "relay", "Vermittler", "Server hinter NAT/Firewall", "relay vermittler"},
{"settings/logs", "sesslog", "Protokolle & Logs", "Sitzungsprotokoll, Logwache, Syslog, Audit", "protokoll logs syslog audit"},
{"settings/net", "backup", "Netzwerkgeräte", "Befehlssätze, Regeln für Switch-Configs", "switch netzwerk befehlssatz"},
{"settings/osv", "lock", "Sicherheitscheck (OSV)", "Quelle online/offline, eigener Spiegel, Container", "sicherheit security osv cve schwachstellen"},
{"settings/osv", "lock", "Sicherheitscheck (OSV)", "Quelle online/offline, eigener Spiegel, Container, NVD-Schlüssel", "sicherheit security osv cve schwachstellen"},
{"help/debug", "sesslog", "Fehlersuche", "Debug-Protokoll, Leistungsanzeige", "debug fehler leistung"},
}
@@ -892,6 +904,8 @@ func (a *App) palMenuItems() []palItem {
keys: "sicherheit security osv spiegel mirror offline firmennetz proxy", run: func() tea.Cmd { return a.askVulnMirror() }},
sub("settings/osv", palToggle(ic("lock"), i18n.T("Laufende Container mitprüfen"), !set.Vuln.NoContainers, "sicherheit security osv docker podman container",
func() tea.Cmd { return a.toggleVulnContainers() })),
palItem{group: pgSetSetup, menu: "settings/osv", icon: ic("lock"), label: i18n.T("NVD-API-Schlüssel (Firmware-Hinweise) …"), hint: nvdKeyLabel(set),
keys: "nvd api key schlüssel firmware switch nist", run: func() tea.Cmd { return a.askNVDKey() }},
// Einstellungen › KI
palItem{group: pgSetSetup, menu: "settings/ki", icon: ic("ai"), label: i18n.T("Endpunkt & Modell …"), hint: "s", keys: "ai llm ki-einstellungen endpunkt modell model url", run: func() tea.Cmd { return a.openSettings() }},
+779
View File
@@ -0,0 +1,779 @@
package ui
import (
"context"
"encoding/json"
"errors"
"fmt"
"sort"
"strings"
"time"
tea "charm.land/bubbletea/v2"
"github.com/db9979/sshtermy/internal/audit"
"github.com/db9979/sshtermy/internal/domain"
"github.com/db9979/sshtermy/internal/i18n"
"github.com/db9979/sshtermy/internal/logscan"
"github.com/db9979/sshtermy/internal/patchrun"
"github.com/db9979/sshtermy/internal/sshx"
"github.com/db9979/sshtermy/internal/vuln"
)
// Patch-Runde (Palette „Patch-Runde“): Updates gestaffelt über einen
// Ordner. Erst ein Host (Kanarienvogel), dann nach Freigabe (w) der Rest,
// einer nach dem anderen. Vor und nach dem Update: laufende Dienste,
// lauschende Ports, fehlgeschlagene Units, neue Fehler im Log. Neustart nur,
// wenn gewählt und nötig, mit Warten auf Rückkehr. Bei Auffälligkeiten hält
// die Runde an. Starten erst nach doppelter Bestätigung (Gefahr-Stufe).
type patchConn interface {
ExecInput(ctx context.Context, cmd string, in []byte) (sshx.RunResult, error)
Close() error
}
// patchDial: ohne Rückfragen verbinden (in Tests austauschbar).
var patchDial = func(a *App) func(ctx context.Context, c domain.Connection) (patchConn, error) {
hk, st := a.hostKeys, a.st
relayDial := a.relayDialer()
return func(ctx context.Context, c domain.Connection) (patchConn, error) {
opts := sshx.Options{
HostKeys: hk,
Resolve: st.Connection,
Relay: relayDial,
Prompt: func(string, string, string) bool { return false },
AskSecret: func(label string) (string, error) {
return "", fmt.Errorf(i18n.T("braucht eine Eingabe (%s), die Patch-Runde meldet sich ohne Rückfrage an"), label)
},
}
cl, err := sshx.Dial(ctx, c, opts)
if err != nil {
return nil, err
}
return cl, nil
}
}
// Wartezeiten beim Neustart (in Tests kürzer).
var (
patchRebootWait = 20 * time.Second // erst nach dieser Zeit wieder anklopfen
patchPoll = 10 * time.Second
patchBackMax = 15 * time.Minute
patchSettle = 30 * time.Second // nach dem Update/Neustart: Dienste hochkommen lassen
)
type patchJob struct {
conn domain.Connection
scope patchrun.Scope
pkgs []string
reboot bool
noise func(string) bool
pws []string // Kandidaten fürs sudo-Passwort (gespeichert)
}
type patchHost struct {
conn domain.Connection
phase string
done bool
err string
skipped bool
before patchrun.State
after patchrun.State
diff patchrun.Diff
upgraded int
tail string
newLogs []string
rebooted bool
reboot bool // nach der Runde noch Neustart nötig
start time.Time
end time.Time
}
func (h patchHost) problems() int {
if h.err != "" {
return 1
}
return h.diff.Problems() + len(h.newLogs)
}
type patchState struct {
seq int
folder string
scope patchrun.Scope
reboot bool
hosts []patchHost
jobs []patchJob
next int // nächster Host
running bool // ein Host läuft gerade
paused bool // wartet auf w
why string
done bool
ctx context.Context
cancel context.CancelFunc
start time.Time
}
type patchHostMsg struct {
seq int
i int
h patchHost
final bool
}
// ---------------------------------------------------------------- Start
func (a *App) openPatch() tea.Cmd {
if a.patch.running {
a.showPatch()
return nil
}
count := map[string]int{}
for _, c := range a.st.Connections() {
if !vulnScanable(c) {
continue
}
count[""]++
p := c.Group
for p != "" {
count[p]++
i := strings.LastIndex(p, domain.PathSep)
if i < 0 {
break
}
p = p[:i]
}
}
if count[""] == 0 {
a.flash(i18n.T("Keine Linux-Server (SSH) für eine Patch-Runde"))
return nil
}
var paths []string
for p := range count {
if p != "" {
paths = append(paths, p)
}
}
sort.Strings(paths)
items := []pickItem{{value: "\x00all", label: i18n.T("Alle Verbindungen"), hint: fmt.Sprint(count[""])}}
for _, p := range paths {
items = append(items, pickItem{value: p, label: p, hint: fmt.Sprint(count[p]), indent: strings.Count(p, domain.PathSep)})
}
cur := ""
if a.scr == scrManager {
if r, ok := a.mgrCur(); ok {
if r.isFolder() {
cur = r.node.Path
} else {
cur = r.conn.Group
}
}
}
a.pick = newPicker(i18n.T("Patch-Runde: Ordner wählen"), i18n.T("Ordner suchen …"), items, cur, func(it pickItem) tea.Cmd {
f := it.value
if f == "\x00all" {
f = ""
}
return a.patchAskScope(f)
})
a.pick.help = i18n.T("Updates gestaffelt: erst ein Host, dann nach deiner Freigabe der Rest, einer nach dem anderen. Vorher und nachher prüft sshTermy Dienste, Ports und Logs. Braucht root oder sudo.")
return nil
}
func (a *App) patchAskScope(folder string) tea.Cmd {
conns := a.vulnFolderConns(folder)
if len(conns) == 0 {
a.flash(i18n.T("Keine Linux-Server (SSH) für eine Patch-Runde"))
return nil
}
withCheck := 0
for _, c := range conns {
if len(a.patchPkgs(c.ID)) > 0 {
withCheck++
}
}
items := []pickItem{{value: "all", label: i18n.T("Alle verfügbaren Updates"), hint: fmt.Sprint(len(conns))}}
if withCheck > 0 {
items = append(items, pickItem{value: "sec", label: i18n.T("Nur Pakete mit Lücken aus dem Sicherheitscheck"), hint: fmt.Sprint(withCheck)})
}
a.pick = newPicker(i18n.T("Patch-Runde: was einspielen?"), "", items, "", func(it pickItem) tea.Cmd {
scope := patchrun.ScopeAll
if it.value == "sec" {
scope = patchrun.ScopeSecurity
}
return a.patchAskReboot(folder, scope)
})
a.pick.help = i18n.T("„Nur Pakete mit Lücken“ nimmt je Host die Pakete aus dem letzten Sicherheitscheck, für die es ein Update gibt. Hosts ohne Sicherheitscheck werden dann übersprungen.")
return nil
}
func (a *App) patchAskReboot(folder string, scope patchrun.Scope) tea.Cmd {
items := []pickItem{
{value: "yes", label: i18n.T("Neu starten, wenn nötig (einzeln, mit Warten auf Rückkehr)")},
{value: "no", label: i18n.T("Nicht neu starten, nur melden")},
}
a.pick = newPicker(i18n.T("Patch-Runde: Neustart?"), "", items, "", func(it pickItem) tea.Cmd {
return a.patchAskCanary(folder, scope, it.value == "yes")
})
return nil
}
func (a *App) patchAskCanary(folder string, scope patchrun.Scope, reboot bool) tea.Cmd {
conns := a.vulnFolderConns(folder)
sort.SliceStable(conns, func(i, j int) bool { return patchCanaryRank(conns[i]) < patchCanaryRank(conns[j]) })
var items []pickItem
for _, c := range conns {
hint := c.Group
if domain.IsProduction(c) {
hint = strings.TrimSpace(hint + " · " + i18n.T("geschützt"))
}
items = append(items, pickItem{value: c.ID, label: c.Alias, hint: hint})
}
a.pick = newPicker(i18n.T("Patch-Runde: welcher Host zuerst?"), i18n.T("Host suchen …"), items, "", func(it pickItem) tea.Cmd {
return a.patchConfirm(folder, scope, reboot, it.value)
})
a.pick.help = i18n.T("Der erste Host (Kanarienvogel) bekommt die Updates allein. Danach hält die Runde an und du entscheidest mit w, ob der Rest folgt. Am besten ein Test- oder unwichtiger Host.")
return nil
}
// patchCanaryRank: Test-Hosts zuerst vorschlagen.
func patchCanaryRank(c domain.Connection) int {
s := strings.ToLower(c.Alias + " " + strings.Join(c.Tags, " "))
for _, w := range []string{"canary", "kanari", "test", "dev", "staging", "stage"} {
if strings.Contains(s, w) {
return 0
}
}
if !domain.IsProduction(c) {
return 1
}
return 2
}
func (a *App) patchConfirm(folder string, scope patchrun.Scope, reboot bool, canary string) tea.Cmd {
conns := a.vulnFolderConns(folder)
sort.SliceStable(conns, func(i, j int) bool {
if (conns[i].ID == canary) != (conns[j].ID == canary) {
return conns[i].ID == canary
}
return strings.ToLower(conns[i].Alias) < strings.ToLower(conns[j].Alias)
})
prot := 0
var names []string
for _, c := range conns {
if domain.IsProduction(c) {
prot++
}
names = append(names, c.Alias)
}
what := i18n.T("alle verfügbaren Updates")
if scope == patchrun.ScopeSecurity {
what = i18n.T("nur Pakete mit Lücken aus dem Sicherheitscheck")
}
rb := i18n.T("kein Neustart")
if reboot {
rb = i18n.T("Neustart, wenn nötig")
}
where := folder
if where == "" {
where = i18n.T("alle Verbindungen")
}
body := fmt.Sprintf(i18n.T("Ordner: %s\nHosts (%d): %s\nErster Host: %s\nEinspielen: %s · %s"), where, len(conns), trunc(strings.Join(names, ", "), 300), conns[0].Alias, what, rb)
if prot > 0 {
body += "\n" + fmt.Sprintf(i18n.T("▲ %d davon sind als produktiv geschützt."), prot)
}
body += "\n\n" + i18n.T("sshTermy führt die Updates mit root-Rechten aus. Nach dem ersten Host hält die Runde an.") + "\n" + i18n.T("j = starten · n = abbrechen")
m := confirmModal(i18n.T("Patch-Runde starten?"), body, func() tea.Cmd { return a.startPatch(folder, conns, scope, reboot) })
m.twice = true
a.modal = m
return nil
}
// patchPkgs: Binärpakete mit Update aus dem letzten Sicherheitscheck.
func (a *App) patchPkgs(connID string) []string {
raw := a.st.VulnReport(connID)
if len(raw) == 0 {
return nil
}
var r vuln.Report
if json.Unmarshal(raw, &r) != nil {
return nil
}
seen := map[string]bool{}
var out []string
for _, f := range r.Findings {
if f.Container != "" || f.Fixed == "" {
continue
}
for _, b := range f.Binaries {
if !seen[b] {
seen[b] = true
out = append(out, b)
}
}
}
sort.Strings(out)
return out
}
func (a *App) startPatch(folder string, conns []domain.Connection, scope patchrun.Scope, reboot bool) tea.Cmd {
p := &a.patch
if p.cancel != nil {
p.cancel()
}
ctx, cancel := context.WithTimeout(context.Background(), 12*time.Hour)
*p = patchState{seq: p.seq + 1, folder: folder, scope: scope, reboot: reboot, ctx: ctx, cancel: cancel, start: time.Now()}
for _, c := range conns {
j := patchJob{conn: c, scope: scope, reboot: reboot, noise: a.noiseFor(c)}
if scope == patchrun.ScopeSecurity {
j.pkgs = a.patchPkgs(c.ID)
}
if c.Password.IsSet() {
j.pws = append(j.pws, c.Password.Reveal())
}
if c.Keychain {
j.pws = append(j.pws, sshx.KeychainSecret(c.ID, sshx.SecretSudo), sshx.KeychainSecret(c.ID, sshx.SecretPassword))
}
p.jobs = append(p.jobs, j)
p.hosts = append(p.hosts, patchHost{conn: c, phase: i18n.T("wartet")})
}
a.audit.Add(audit.EvBroadcast, orDefault(folder, "*"), fmt.Sprintf("Patch-Runde: %d Hosts", len(conns)))
cmd := a.patchNext()
a.showPatch()
return cmd
}
// patchNext startet den nächsten Host im Hintergrund.
func (a *App) patchNext() tea.Cmd {
p := &a.patch
if p.next >= len(p.jobs) {
p.done, p.running = true, false
a.patchFinished()
return nil
}
i := p.next
p.next++
p.running, p.paused, p.why = true, false, ""
job, seq, ev, ctx := p.jobs[i], p.seq, a.events, p.ctx
run := patchHostRun(a)
go func() {
h := run(ctx, job, func(h patchHost) { ev <- patchHostMsg{seq: seq, i: i, h: h} })
ev <- patchHostMsg{seq: seq, i: i, h: h, final: true}
}()
return nil
}
func (a *App) patchMsgs(msg tea.Msg) (tea.Cmd, bool) {
m, ok := msg.(patchHostMsg)
if !ok {
return nil, false
}
p := &a.patch
if m.seq != p.seq || m.i >= len(p.hosts) {
return a.listen(), true
}
p.hosts[m.i] = m.h
var cmd tea.Cmd
if m.final {
p.running = false
h := m.h
switch {
case p.ctx.Err() != nil:
p.done = true
case m.i == 0 && len(p.jobs) > 1:
p.paused = true
if h.problems() > 0 {
p.why = i18n.T("Erster Host mit Auffälligkeiten. Bitte ansehen, bevor es weitergeht.")
a.flashErr(i18n.T("Patch-Runde: erster Host mit Auffälligkeiten"))
} else {
p.why = i18n.T("Erster Host ist durch, ohne Auffälligkeiten.")
a.flashOK(i18n.T("Patch-Runde: erster Host fertig, w setzt fort"))
}
a.schedDesktop(i18n.T("Patch-Runde"), p.why)
case h.problems() > 0 && p.next < len(p.jobs):
p.paused = true
p.why = fmt.Sprintf(i18n.T("%s mit Auffälligkeiten. Runde angehalten."), h.conn.Alias)
a.flashErr(i18n.T("Patch-Runde angehalten: ") + h.conn.Alias)
a.schedDesktop(i18n.T("Patch-Runde"), p.why)
default:
cmd = a.patchNext()
}
}
if a.modal != nil && a.modal.patch {
a.showPatch()
}
if cmd != nil {
return tea.Batch(cmd, a.listen()), true
}
return a.listen(), true
}
func (a *App) patchFinished() {
p := &a.patch
okN, probN := 0, 0
for _, h := range p.hosts {
if h.skipped {
continue
}
if h.problems() > 0 {
probN++
} else if h.done {
okN++
}
}
txt := fmt.Sprintf(i18n.T("Patch-Runde fertig: %d ohne Auffälligkeiten, %d mit"), okN, probN)
if probN > 0 {
a.flashErr(txt)
} else {
a.flashOK(txt)
}
a.schedDesktop(i18n.T("Patch-Runde"), txt)
}
// patchKey: Tasten im Fenster der Runde. true = verarbeitet.
func (a *App) patchKey(key string) (tea.Cmd, bool) {
p := &a.patch
switch key {
case "w":
if p.paused && !p.done {
cmd := a.patchNext()
a.showPatch()
return cmd, true
}
case "x":
// Nie mitten im Update abbrechen: der laufende Host wird fertig.
if !p.done {
for i := p.next; i < len(p.hosts); i++ {
p.hosts[i].skipped, p.hosts[i].phase = true, i18n.T("nicht gestartet")
}
p.next = len(p.jobs)
if !p.running {
p.paused, p.done = false, true
p.why = i18n.T("Runde beendet.")
}
a.showPatch()
return nil, true
}
}
return nil, false
}
// ---------------------------------------------------------------- ein Host
// patchHostRun: einen Host aktualisieren (in Tests austauschbar).
var patchHostRun = func(a *App) func(ctx context.Context, j patchJob, upd func(patchHost)) patchHost {
dial := patchDial(a)
ask := a.events
return func(ctx context.Context, j patchJob, upd func(patchHost)) patchHost {
return runPatchHost(ctx, j, dial, func(label string) string {
r := make(chan string, 1)
select {
case ask <- secretAskMsg{label, r}:
case <-ctx.Done():
return ""
}
select {
case pw := <-r:
if pw == "\x00cancel" {
return ""
}
return pw
case <-ctx.Done():
return ""
}
}, upd)
}
}
func runPatchHost(ctx context.Context, j patchJob, dial func(context.Context, domain.Connection) (patchConn, error),
askPw func(string) string, upd func(patchHost)) (h patchHost) {
h = patchHost{conn: j.conn, start: time.Now()}
phase := func(s string) {
h.phase = s
upd(h)
}
fail := func(err error) patchHost {
h.err, h.done, h.end = strings.TrimSpace(err.Error()), true, time.Now()
h.phase = i18n.T("Fehler")
return h
}
if j.scope == patchrun.ScopeSecurity && len(j.pkgs) == 0 {
h.skipped, h.done, h.end = true, true, time.Now()
h.phase = i18n.T("übersprungen: kein Sicherheitscheck mit Updates")
return h
}
phase(i18n.T("verbindet …"))
cctx, ccancel := context.WithTimeout(ctx, 45*time.Second)
cl, err := dial(cctx, j.conn)
ccancel()
if err != nil {
return fail(err)
}
defer func() {
if cl != nil {
cl.Close()
}
}()
run := func(cl patchConn, script string, d time.Duration) (string, int, error) {
rctx, cancel := context.WithTimeout(ctx, d)
defer cancel()
res, err := cl.ExecInput(rctx, "sh -c "+sshx.Quote(script), nil)
return string(res.Output), res.Exit, err
}
phase(i18n.T("liest Zustand …"))
out, _, err := run(cl, patchrun.StateScript, 2*time.Minute)
if err != nil && out == "" {
return fail(err)
}
h.before = patchrun.ParseState(out)
if h.before.Manager == patchrun.MgrNone {
return fail(errors.New(i18n.T("keine bekannte Paketverwaltung (apt, dnf, yum, zypper, apk)")))
}
before := map[string]bool{}
if out, _, err := run(cl, logscan.UnixScript(24), 2*time.Minute); err == nil || out != "" {
for _, f := range logscan.ParseUnix(out, 24, time.Now()).Findings {
before[f.Key] = true
}
}
// root: direkt, sonst sudo (ohne Passwort, gespeichertes, sonst fragen)
asRoot := func(cl patchConn, script string, d time.Duration) (string, int, error) {
return run(cl, script, d)
}
if !h.before.Root {
res, err := cl.ExecInput(ctx, "LC_ALL=C sudo -n true", nil)
if err != nil {
return fail(err)
}
var pw string
if res.Exit != 0 {
ok := false
tried := map[string]bool{}
try := func(p string) bool {
if p == "" || tried[p] {
return false
}
tried[p] = true
r, err := cl.ExecInput(ctx, "LC_ALL=C sudo -S -p '' true", []byte(p+"\n"))
return err == nil && r.Exit == 0
}
for _, p := range j.pws {
if try(p) {
pw, ok = p, true
break
}
}
if !ok && askPw != nil {
if p := askPw(fmt.Sprintf(i18n.T("sudo-Passwort für %s@%s (Patch-Runde)"), j.conn.Username, j.conn.Host)); try(p) {
pw, ok = p, true
}
}
if !ok {
return fail(errors.New(i18n.T("sudo braucht ein Passwort, das nicht stimmt oder fehlt")))
}
}
asRoot = func(cl patchConn, script string, d time.Duration) (string, int, error) {
rctx, cancel := context.WithTimeout(ctx, d)
defer cancel()
cmd, in := "LC_ALL=C sudo -n sh -c "+sshx.Quote(script), []byte(nil)
if pw != "" {
cmd, in = "LC_ALL=C sudo -S -p '' sh -c "+sshx.Quote(script), []byte(pw+"\n")
}
res, err := cl.ExecInput(rctx, cmd, in)
return string(res.Output), res.Exit, err
}
}
phase(i18n.T("spielt Updates ein …"))
script := patchrun.UpdateScript(h.before.Manager, j.scope, j.pkgs)
if script == "" {
return fail(errors.New(i18n.T("kein Update-Befehl für diese Paketverwaltung")))
}
out, exit, err := asRoot(cl, script, 45*time.Minute)
h.tail = patchrun.Tail(out, 15)
h.upgraded = patchrun.Upgraded(h.before.Manager, out)
if err != nil && out == "" {
return fail(err)
}
if exit != 0 {
h.err = fmt.Sprintf(i18n.T("Update-Befehl endete mit %d"), exit)
}
sleep := func(d time.Duration) bool {
select {
case <-ctx.Done():
return false
case <-time.After(d):
return true
}
}
phase(i18n.T("prüft …"))
out, _, _ = run(cl, patchrun.StateScript, 2*time.Minute)
mid := patchrun.ParseState(out)
if mid.Reboot && j.reboot && h.err == "" {
phase(i18n.T("startet neu …"))
_, _, _ = asRoot(cl, patchrun.RebootScript, 30*time.Second)
cl.Close()
cl = nil
if !sleep(patchRebootWait) {
return fail(ctx.Err())
}
phase(i18n.T("wartet auf Rückkehr …"))
deadline := time.Now().Add(patchBackMax)
for {
dctx, dcancel := context.WithTimeout(ctx, 20*time.Second)
c2, err := dial(dctx, j.conn)
dcancel()
if err == nil {
o, _, _ := run(c2, patchrun.StateScript, time.Minute)
st := patchrun.ParseState(o)
if st.Boot != "" && st.Boot != h.before.Boot {
cl = c2
break
}
c2.Close()
}
if time.Now().After(deadline) {
return fail(fmt.Errorf(i18n.T("nach %s nicht zurückgekommen"), durText(patchBackMax)))
}
if !sleep(patchPoll) {
return fail(ctx.Err())
}
}
}
phase(i18n.T("lässt Dienste hochkommen …"))
if !sleep(patchSettle) {
return fail(ctx.Err())
}
phase(i18n.T("prüft …"))
out, _, err = run(cl, patchrun.StateScript, 2*time.Minute)
if err != nil && out == "" {
return fail(err)
}
h.after = patchrun.ParseState(out)
h.diff = patchrun.Compare(h.before, h.after)
h.rebooted, h.reboot = h.diff.Rebooted, h.after.Reboot
if out, _, err := run(cl, logscan.UnixScript(1), 2*time.Minute); err == nil || out != "" {
r := logscan.ParseUnix(out, 1, time.Now())
if j.noise != nil {
logscan.ApplyNoise(r, j.noise)
}
for _, f := range r.Findings {
if f.Sev >= logscan.SevErr && !f.Noise && !before[f.Key] {
h.newLogs = append(h.newLogs, f.Title)
}
}
}
h.done, h.end = true, time.Now()
h.phase = i18n.T("fertig")
return h
}
// ---------------------------------------------------------------- Anzeige
func (a *App) showPatch() {
p := &a.patch
if len(p.hosts) == 0 {
a.flash(i18n.T("Noch keine Patch-Runde gelaufen"))
return
}
lines, md := a.patchLines()
where := p.folder
if where == "" {
where = i18n.T("alle Verbindungen")
}
scroll := 0
if a.modal != nil && a.modal.kind == mText && a.modal.patch {
scroll = a.modal.scroll
}
a.modal = textModal(i18n.T("Patch-Runde: ")+where, lines)
a.modal.copy, a.modal.scroll, a.modal.patch = md, scroll, true
}
func (a *App) patchLines() (lines []string, md string) {
p := &a.patch
var b strings.Builder
what := i18n.T("alle Updates")
if p.scope == patchrun.ScopeSecurity {
what = i18n.T("nur Pakete aus dem Sicherheitscheck")
}
rb := i18n.T("ohne Neustart")
if p.reboot {
rb = i18n.T("Neustart, wenn nötig")
}
head := fmt.Sprintf("%s · %s · %s %s", what, rb, i18n.T("seit"), p.start.Format("15:04"))
fmt.Fprintf(&b, "# %s %s\n\n%s\n\n", i18n.T("Patch-Runde"), orDefault(p.folder, i18n.T("alle Verbindungen")), head)
lines = append(lines, head)
switch {
case p.done:
lines = append(lines, i18n.T("Runde beendet."))
case p.paused:
rest := len(p.jobs) - p.next
lines = append(lines, "▶ "+p.why, fmt.Sprintf(i18n.T("w = weiter mit %d Hosts · x = Runde beenden · Esc = Fenster zu (Runde wartet)"), rest))
case p.running:
lines = append(lines, spinGlyph(time.Now())+" "+i18n.T("läuft · x = nach diesem Host beenden · Esc = Fenster zu (läuft weiter)"))
}
lines = append(lines, "", fmt.Sprintf("%-22s %-26s %7s %-9s %s", "Host", i18n.T("Stand"), i18n.T("Pakete"), i18n.T("Neustart"), i18n.T("Auffälligkeiten")))
b.WriteString(i18n.T("| Host | Stand | Pakete | Neustart | Auffälligkeiten |\n|---|---|---|---|---|\n"))
for i, h := range p.hosts {
name := h.conn.Alias
if i == 0 && len(p.hosts) > 1 {
name += " (1)"
}
pk, rbt, prob := "", "", ""
if h.done && !h.skipped {
pk = fmt.Sprint(h.upgraded)
switch {
case h.rebooted:
rbt = i18n.T("erfolgt")
case h.reboot:
rbt = i18n.T("nötig")
default:
rbt = "–"
}
if n := h.problems(); n > 0 {
prob = fmt.Sprintf("▲ %d", n)
if h.err != "" {
prob = "× " + trunc(h.err, 40)
}
} else {
prob = "✓"
}
}
lines = append(lines, fmt.Sprintf("%-22s %-26s %7s %-9s %s", trunc(name, 22), trunc(h.phase, 26), pk, rbt, prob))
fmt.Fprintf(&b, "| %s | %s | %s | %s | %s |\n", h.conn.Alias, h.phase, pk, rbt, prob)
}
// Einzelheiten zu Hosts mit Auffälligkeiten
for _, h := range p.hosts {
if h.problems() == 0 || !h.done {
continue
}
lines = append(lines, "", "▲ "+h.conn.Alias)
fmt.Fprintf(&b, "\n## %s\n\n", h.conn.Alias)
add := func(label string, xs []string) {
if len(xs) == 0 {
return
}
l := label + ": " + strings.Join(xs, ", ")
lines = append(lines, " "+trunc(l, 200))
fmt.Fprintf(&b, "- %s\n", l)
}
if h.err != "" {
add(i18n.T("Fehler"), []string{h.err})
}
add(i18n.T("Dienste gestoppt"), h.diff.StoppedServices)
add(i18n.T("Units fehlgeschlagen"), h.diff.NewFailed)
add(i18n.T("Ports nicht mehr offen"), h.diff.ClosedPorts)
add(i18n.T("Neue Fehler im Log"), h.newLogs)
if h.tail != "" && h.err != "" {
lines = append(lines, i18n.T(" Letzte Ausgabe:"))
for _, l := range strings.Split(h.tail, "\n") {
lines = append(lines, " "+trunc(l, 160))
}
fmt.Fprintf(&b, "\n```\n%s\n```\n", h.tail)
}
}
lines = append(lines, "", i18n.T("(1) = erster Host. Verglichen werden laufende Dienste, offene Ports, fehlgeschlagene Units und neue Fehler im Log (letzte Stunde gegen die 24 h davor). c kopiert den Bericht."))
return lines, b.String()
}
+209
View File
@@ -0,0 +1,209 @@
package ui
import (
"context"
"strings"
"sync"
"testing"
"time"
"github.com/db9979/sshtermy/internal/domain"
"github.com/db9979/sshtermy/internal/patchrun"
"github.com/db9979/sshtermy/internal/sshx"
"github.com/db9979/sshtermy/internal/vuln"
)
// fakeHost spielt einen Server: Zustand vor/nach dem Update, Neustart.
type fakeHost struct {
mu sync.Mutex
boot string
updated bool
rebooted bool
breaks bool // nach dem Update läuft nginx nicht mehr
root bool
sudoPw string
cmds []string
}
type fakeConn struct{ h *fakeHost }
func (f fakeConn) Close() error { return nil }
func (f fakeConn) ExecInput(_ context.Context, cmd string, in []byte) (sshx.RunResult, error) {
h := f.h
h.mu.Lock()
defer h.mu.Unlock()
h.cmds = append(h.cmds, cmd)
switch {
case strings.Contains(cmd, "sudo -n true"):
if h.sudoPw == "" {
return sshx.RunResult{}, nil
}
return sshx.RunResult{Exit: 1, Output: []byte("sudo: a password is required")}, nil
case strings.Contains(cmd, "sudo -S -p '' true"):
if string(in) == h.sudoPw+"\n" {
return sshx.RunResult{}, nil
}
return sshx.RunResult{Exit: 1}, nil
case strings.Contains(cmd, "pm=apt"): // Zustand
var b strings.Builder
if h.root {
b.WriteString("root=1\n")
}
b.WriteString("pm=apt\nboot=" + h.boot + "\nsvc=ssh.service\n")
if !(h.updated && h.breaks) {
b.WriteString("svc=nginx.service\nport=0.0.0.0:80\n")
}
b.WriteString("port=0.0.0.0:22\n")
if h.updated && !h.rebooted {
b.WriteString("reboot=1\n")
}
return sshx.RunResult{Output: []byte(b.String())}, nil
case strings.Contains(cmd, "apt-get upgrade"):
h.updated = true
return sshx.RunResult{Output: []byte("Unpacking openssl (3) over (2) ...\nUnpacking curl (8) over (7) ...\n")}, nil
case strings.Contains(cmd, "apt-get install --only-upgrade"):
h.updated = true
return sshx.RunResult{Output: []byte("Unpacking openssl (3) over (2) ...\n")}, nil
case strings.Contains(cmd, "systemctl reboot"):
h.rebooted, h.boot = true, h.boot+"-neu"
return sshx.RunResult{}, nil
}
return sshx.RunResult{}, nil // Logs: leer
}
func TestRunPatchHost(t *testing.T) {
defer func(a, b, c, d time.Duration) { patchRebootWait, patchPoll, patchBackMax, patchSettle = a, b, c, d }(patchRebootWait, patchPoll, patchBackMax, patchSettle)
patchRebootWait, patchPoll, patchBackMax, patchSettle = time.Millisecond, time.Millisecond, time.Second, time.Millisecond
h := &fakeHost{boot: "b1", sudoPw: "geheim"}
dial := func(context.Context, domain.Connection) (patchConn, error) { return fakeConn{h}, nil }
var phases []string
j := patchJob{conn: domain.Connection{Alias: "web01", Username: "u", Host: "web01"}, scope: patchrun.ScopeAll, reboot: true, pws: []string{"falsch", "geheim"}}
got := runPatchHost(context.Background(), j, dial, nil, func(x patchHost) { phases = append(phases, x.phase) })
if got.err != "" || !got.done || !got.rebooted || got.upgraded != 2 || got.problems() != 0 {
t.Fatalf("%+v", got)
}
if len(phases) < 5 {
t.Fatalf("Phasen: %v", phases)
}
upd := ""
for _, c := range h.cmds {
if strings.Contains(c, "apt-get upgrade") {
upd = c
}
}
if !strings.HasPrefix(upd, "LC_ALL=C sudo -S -p '' sh -c") {
t.Fatalf("Update ohne sudo-Passwort: %s", upd)
}
// Dienst fällt aus, kein Neustart gewünscht
h2 := &fakeHost{boot: "b1", root: true, breaks: true}
j2 := patchJob{conn: domain.Connection{Alias: "web02"}, scope: patchrun.ScopeSecurity, pkgs: []string{"openssl"}}
got = runPatchHost(context.Background(), j2, func(context.Context, domain.Connection) (patchConn, error) { return fakeConn{h2}, nil }, nil, func(patchHost) {})
if got.rebooted || !got.reboot || got.problems() != 2 || got.diff.StoppedServices[0] != "nginx.service" {
t.Fatalf("%+v", got)
}
// ohne Pakete aus dem Sicherheitscheck: übersprungen
got = runPatchHost(context.Background(), patchJob{scope: patchrun.ScopeSecurity}, nil, nil, func(patchHost) {})
if !got.skipped {
t.Fatal("nicht übersprungen")
}
// sudo-Passwort fehlt
h3 := &fakeHost{boot: "b", sudoPw: "x"}
got = runPatchHost(context.Background(), patchJob{scope: patchrun.ScopeAll}, func(context.Context, domain.Connection) (patchConn, error) { return fakeConn{h3}, nil }, func(string) string { return "" }, func(patchHost) {})
if !strings.Contains(got.err, "sudo") {
t.Fatalf("%+v", got)
}
}
func TestPatchRoundFlow(t *testing.T) {
a := vulnTestApp(t)
for _, n := range []string{"app-test", "app01", "app02"} {
if _, err := a.st.UpsertConnection(domain.Connection{Alias: n, Host: n, Username: "root", Group: "Apps"}); err != nil {
t.Fatal(err)
}
}
old := patchHostRun
defer func() { patchHostRun = old }()
patchHostRun = func(*App) func(context.Context, patchJob, func(patchHost)) patchHost {
return func(_ context.Context, j patchJob, upd func(patchHost)) patchHost {
upd(patchHost{conn: j.conn, phase: "spielt Updates ein …"})
h := patchHost{conn: j.conn, phase: "fertig", done: true, upgraded: 3}
if j.conn.Alias == "app01" {
h.diff.ClosedPorts = []string{"*:443"}
}
return h
}
}
a.scr = scrManager
a.openPatch()
if a.pick == nil {
t.Fatal("Ordnerwahl fehlt")
}
a.pick.onPick(pickItem{value: "Apps"})
if a.pick == nil || len(a.pick.items) != 1 {
t.Fatal("Umfang: ohne Sicherheitscheck nur „alle Updates“")
}
a.pick.onPick(a.pick.items[0])
a.pick.onPick(pickItem{value: "yes"})
if a.pick.items[0].label != "app-test" {
t.Fatalf("Test-Host nicht zuerst vorgeschlagen: %v", a.pick.items[0].label)
}
a.pick.onPick(a.pick.items[0])
if a.modal == nil || a.modal.kind != mConfirm || !a.modal.twice || !strings.Contains(a.modal.body, "geschützt") {
t.Fatalf("Bestätigung: %+v", a.modal)
}
a.Update(keyMsg("j"))
if a.patch.running {
t.Fatal("startet nach einmal j")
}
a.Update(keyMsg("j"))
if !a.patch.running || a.modal == nil || !a.modal.patch {
t.Fatal("Runde läuft nicht")
}
pump := func(cond func() bool) {
deadline := time.After(5 * time.Second)
for !cond() {
select {
case m := <-a.events:
a.Update(m)
case <-deadline:
t.Fatal("keine Antwort")
}
}
}
pump(func() bool { return a.patch.paused })
if a.patch.hosts[0].conn.Alias != "app-test" || !strings.Contains(strings.Join(a.modal.lines, "\n"), "w = ") {
t.Fatalf("Pause nach dem ersten Host fehlt:\n%s", strings.Join(a.modal.lines, "\n"))
}
a.Update(keyMsg("w"))
pump(func() bool { return a.patch.paused || a.patch.done })
if !a.patch.paused || a.patch.hosts[1].conn.Alias != "app01" {
t.Fatal("hält bei Auffälligkeiten nicht an")
}
txt := strings.Join(a.modal.lines, "\n")
if !strings.Contains(txt, "Ports nicht mehr offen: *:443") || !strings.Contains(a.modal.copy, "| app01 |") {
t.Fatalf("Bericht:\n%s", txt)
}
a.Update(keyMsg("x"))
if !a.patch.done || !a.patch.hosts[2].skipped {
t.Fatal("x beendet nicht")
}
}
func TestPatchPkgsFromVulnCheck(t *testing.T) {
a := vulnTestApp(t)
c, _ := a.st.UpsertConnection(domain.Connection{Alias: "db", Host: "db", Username: "root"})
r := sampleVulnReport()
r.Findings = append(r.Findings, vuln.Finding{Package: "nofix", Binaries: []string{"nofix"}}, vuln.Finding{Container: "web", Package: "x", Fixed: "2", Binaries: []string{"x"}})
a.saveVuln(c.ID, r)
got := a.patchPkgs(c.ID)
for _, p := range got {
if p == "nofix" || p == "x" {
t.Fatalf("falsche Pakete: %v", got)
}
}
if len(got) == 0 {
t.Fatal("keine Pakete")
}
}
+1 -1
View File
@@ -20,7 +20,7 @@
│ ── ALLE AKTIONEN ─────────────────────────────────────────────────────── │
│ [/] Suchen & Logs › Verlauf, alle Tabs, Log-Blick, Protokolle 3 │
│ [T] Tabs & Ansicht › neu, teilen, Zoom, Arbeitsplätze 2 │
│ [*] Mehrere Hosts & Netzwerk › Broadcast, Scan, Zeitpläne, Switches 6 │
│ [*] Mehrere Hosts & Netzwerk › Broadcast, Scan, Zeitpläne, Switches 8 │
│ [&] Team & Teilen › live teilen, Team-Ordner 4 │
│ [=] Verbindungen & Daten › neu, SSH-Key, Import/Export, Sicherung 6 │
│ │
+1 -1
View File
@@ -20,7 +20,7 @@
│ ── ALL ACTIONS ───────────────────────────────────────────────────────── │
│ [/] Search & logs › scrollback, all tabs, log glance, session logs 3 │
│ [T] Tabs & view › new, split, zoom, workspaces 2 │
│ [*] Several hosts & network › broadcast, scan, schedules, switches 6 │
│ [*] Several hosts & network › broadcast, scan, schedules, switches 8 │
│ [&] Team & sharing › live sharing, team folders 4 │
│ [=] Connections & data › new, SSH key, import/export, backup 6 │
│ │
+1 -1
View File
@@ -16,7 +16,7 @@
┃│ ⇧F1…F8 Schnellbefehl ausführen b Switch-Config sichern │┃
┃│ ⇧F10 Tab in eigenes Fenster (Sitzung bleibt c Container (Docker, Podman, k8s) │┃
┃│ offen) l Log-Blick │┃
┃│ Tab / → Ghost-Text übernehmen s Sicherheitscheck (OSV) │┃
┃│ Tab / → Ghost-Text übernehmen s Sicherheitscheck · Switch: Firmware │┃
┃│ Alt+1…4 Folgebefehl einfügen ↑ ↓ Sicherung wählen │┃
┃│ Alt+0 Fehler: Warum? & Fix d Diff zur Vorversion │┃
┃│ Alt+K KI-Begleiter: Aus/Leise/Gesprächig/Coach v Sicherung ansehen │┃
+1 -1
View File
@@ -8,7 +8,7 @@
┃│ F3 Ask AI b back up switch config │┃
┃│ F4 Tunnel c Containers (Docker, Podman, k8s) │┃
┃│ F5 Files (SFTP) l Log view │┃
┃│ F6 Host overview s Security check (OSV) │┃
┃│ F6 Host overview s security check · switch: firmware │┃
┃│ F7 / F8 switch tab ↑ ↓ choose backup │┃
┃│ F9 Quick commands (list) d diff to previous │┃
┃│ F9 → a adopt a frequent command v view backup │┃
+474
View File
@@ -0,0 +1,474 @@
package vuln
import (
"compress/gzip"
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
"os"
"path/filepath"
"regexp"
"sort"
"strings"
"time"
)
// Firmware von Switches, Firewalls und Routern kennt OSV nicht. Dafür
// fragt sshTermy die NVD (National Vulnerability Database, NIST) nach allen
// CVEs eines Produkts (CPE „cpe:2.3:o:fortinet:fortios“) und prüft die
// Versionsangaben selbst. Gesendet wird nur der Produktname, nie die
// Firmware-Version, ein Gerätename oder eine Adresse. Welche CPE zu welchem
// Befehlssatz gehört, steht in dessen YAML (advisory.cpe).
// DefaultNVD: Adresse der NVD-API (CVE 2.0).
const DefaultNVD = "https://services.nvd.nist.gov/rest/json/cves/2.0"
// NVD fragt die NVD-API. Ohne Schlüssel erlaubt sie 5 Anfragen in 30
// Sekunden, mit Schlüssel 50.
type NVD struct {
HTTP
URL string // leer = DefaultNVD (oder eigener Spiegel)
Key string // optionaler API-Schlüssel
// Wait: Pause zwischen zwei Seiten; 0 = je nach Schlüssel 6 s bzw. 0,7 s.
Wait time.Duration
}
// NVDCVE: eine CVE, auf das Produkt verkleinert.
type NVDCVE struct {
ID string `json:"id"`
Score float64 `json:"score,omitempty"`
Summary string `json:"sum,omitempty"`
KEV bool `json:"kev,omitempty"`
Matches []NVDMatch `json:"m"`
}
// NVDMatch: eine betroffene Version oder ein Bereich.
type NVDMatch struct {
Version string `json:"v,omitempty"` // genaue Version ("" = Bereich)
StartIncl string `json:"si,omitempty"`
StartExcl string `json:"se,omitempty"`
EndIncl string `json:"ei,omitempty"`
EndExcl string `json:"ee,omitempty"`
HW bool `json:"hw,omitempty"` // gilt nur für bestimmte Modelle
}
// FirmwareHit: eine CVE, die die Firmware betrifft.
type FirmwareHit struct {
ID string `json:"id"`
Score float64 `json:"score,omitempty"`
Summary string `json:"sum,omitempty"`
KEV bool `json:"kev,omitempty"`
FixedIn string `json:"fixed,omitempty"` // erste Version ohne die Lücke ("" = unbekannt)
HW bool `json:"hw,omitempty"`
}
// Level: Stufe der Lücke.
func (h FirmwareHit) Level() Level { return LevelOf(h.Score) }
// FirmwareReport: Ergebnis für ein Gerät.
type FirmwareReport struct {
Product string `json:"product"` // CPE-Präfix
Version string `json:"version"` // wie verglichen
Raw string `json:"raw"` // wie das Gerät sie nennt
Hits []FirmwareHit `json:"hits"`
Total int `json:"total"` // CVEs zum Produkt in der NVD
At time.Time `json:"at"`
Stale bool `json:"stale,omitempty"` // NVD nicht erreichbar, älterer Stand
MinFixed string `json:"min_fixed,omitempty"` // höchste „behoben ab“ aller Treffer
URL string `json:"url,omitempty"` // Seite mit Sicherheitsmeldungen des Herstellers
}
// Counts: Treffer je Stufe und aktiv ausgenutzte.
func (r *FirmwareReport) Counts() (c Counts) {
for _, h := range r.Hits {
c.Total++
c.CVEs++
switch h.Level() {
case LevelCritical:
c.Critical++
case LevelHigh:
c.High++
case LevelMedium:
c.Medium++
case LevelLow:
c.Low++
default:
c.Unknown++
}
if h.KEV {
c.KEV++
}
}
return c
}
func (n *NVD) url() string {
if n.URL != "" {
return n.URL
}
return DefaultNVD
}
func (n *NVD) cachePath(product string) string {
if n.Cache == "" {
return ""
}
return filepath.Join(n.Cache, "nvd", safeName(strings.TrimPrefix(product, "cpe:2.3:"))+".json.gz")
}
// Product: alle CVEs zu einem Produkt (aus dem Cache, wenn jünger als
// DBMaxAge). stale = NVD nicht erreichbar, Stand aus dem Cache.
func (n *NVD) Product(ctx context.Context, product string, step func(string)) (cves []NVDCVE, stale bool, err error) {
p := n.cachePath(product)
if p != "" {
if st, e := os.Stat(p); e == nil && time.Since(st.ModTime()) < DBMaxAge {
if c, e := readNVDCache(p); e == nil {
return c, false, nil
}
}
}
cves, err = n.fetchProduct(ctx, product, step)
if err != nil {
if p != "" {
if c, e := readNVDCache(p); e == nil {
return c, true, nil
}
}
return nil, false, err
}
if p != "" {
_ = writeNVDCache(p, cves)
}
return cves, false, nil
}
type nvdPage struct {
ResultsPerPage int `json:"resultsPerPage"`
StartIndex int `json:"startIndex"`
TotalResults int `json:"totalResults"`
Vulnerabilities []struct {
CVE nvdCVE `json:"cve"`
} `json:"vulnerabilities"`
}
type nvdCVE struct {
ID string `json:"id"`
VulnStatus string `json:"vulnStatus"`
CISAExploitAdd string `json:"cisaExploitAdd"`
Descriptions []struct {
Lang string `json:"lang"`
Value string `json:"value"`
} `json:"descriptions"`
Metrics map[string][]struct {
Type string `json:"type"`
CVSSData struct {
BaseScore float64 `json:"baseScore"`
} `json:"cvssData"`
} `json:"metrics"`
Configurations []struct {
Operator string `json:"operator"`
Nodes []nvdNode `json:"nodes"`
} `json:"configurations"`
}
type nvdNode struct {
Operator string `json:"operator"`
Negate bool `json:"negate"`
CPEMatch []struct {
Vulnerable bool `json:"vulnerable"`
Criteria string `json:"criteria"`
StartIncl string `json:"versionStartIncluding"`
StartExcl string `json:"versionStartExcluding"`
EndIncl string `json:"versionEndIncluding"`
EndExcl string `json:"versionEndExcluding"`
} `json:"cpeMatch"`
}
func (n *NVD) fetchProduct(ctx context.Context, product string, step func(string)) ([]NVDCVE, error) {
wait := n.Wait
if wait == 0 {
wait = 6 * time.Second
if n.Key != "" {
wait = 700 * time.Millisecond
}
}
const per = 2000
var out []NVDCVE
for start, total := 0, -1; total < 0 || start < total; {
if start > 0 {
select {
case <-ctx.Done():
return nil, ctx.Err()
case <-time.After(wait):
}
}
q := url.Values{}
q.Set("virtualMatchString", product)
q.Set("resultsPerPage", fmt.Sprint(per))
q.Set("startIndex", fmt.Sprint(start))
req, err := http.NewRequestWithContext(ctx, http.MethodGet, n.url()+"?"+q.Encode(), nil)
if err != nil {
return nil, err
}
req.Header.Set("User-Agent", "sshtermy")
if n.Key != "" {
req.Header.Set("apiKey", n.Key)
}
resp, err := n.client().Do(req)
if err != nil {
return nil, err
}
if resp.StatusCode != http.StatusOK {
resp.Body.Close()
return nil, &statusError{resp.StatusCode, n.url()}
}
var pg nvdPage
err = json.NewDecoder(io.LimitReader(resp.Body, 512<<20)).Decode(&pg)
resp.Body.Close()
if err != nil {
return nil, err
}
total = pg.TotalResults
for _, v := range pg.Vulnerabilities {
if c, ok := reduceNVD(v.CVE, product); ok {
out = append(out, c)
}
}
if len(pg.Vulnerabilities) == 0 {
break
}
start += len(pg.Vulnerabilities)
if step != nil && total > 0 {
step(fmt.Sprintf("NVD %d/%d", min(start, total), total))
}
}
return out, nil
}
// reduceNVD: nur die Angaben zum Produkt behalten.
func reduceNVD(v nvdCVE, product string) (NVDCVE, bool) {
if strings.EqualFold(v.VulnStatus, "Rejected") {
return NVDCVE{}, false
}
c := NVDCVE{ID: v.ID, KEV: v.CISAExploitAdd != ""}
for _, d := range v.Descriptions {
if d.Lang == "en" {
c.Summary = shorten(d.Value, 300)
break
}
}
for _, k := range []string{"cvssMetricV40", "cvssMetricV31", "cvssMetricV30", "cvssMetricV2"} {
ms := v.Metrics[k]
for _, m := range ms {
if m.Type == "Primary" || len(ms) == 1 {
c.Score = m.CVSSData.BaseScore
break
}
}
if c.Score == 0 && len(ms) > 0 {
c.Score = ms[0].CVSSData.BaseScore
}
if c.Score > 0 {
break
}
}
pre := strings.ToLower(product) + ":"
for _, cfg := range v.Configurations {
hw := strings.EqualFold(cfg.Operator, "AND") && len(cfg.Nodes) > 1
for _, nd := range cfg.Nodes {
if nd.Negate {
continue
}
for _, m := range nd.CPEMatch {
if !m.Vulnerable || !strings.HasPrefix(strings.ToLower(m.Criteria), pre) {
continue
}
f := splitCPE(m.Criteria)
x := NVDMatch{StartIncl: m.StartIncl, StartExcl: m.StartExcl, EndIncl: m.EndIncl, EndExcl: m.EndExcl, HW: hw}
if len(f) > 5 && f[5] != "*" && f[5] != "-" && f[5] != "" {
x.Version = f[5]
if len(f) > 6 && f[6] != "*" && f[6] != "-" && f[6] != "" {
x.Version += f[6]
}
}
c.Matches = append(c.Matches, x)
}
}
}
return c, len(c.Matches) > 0
}
// splitCPE zerlegt eine CPE 2.3 an „:“ (mit \-Maskierung).
func splitCPE(s string) []string {
var out []string
var b strings.Builder
for i := 0; i < len(s); i++ {
switch {
case s[i] == '\\' && i+1 < len(s):
i++
b.WriteByte(s[i])
case s[i] == ':':
out = append(out, b.String())
b.Reset()
default:
b.WriteByte(s[i])
}
}
return append(out, b.String())
}
func shorten(s string, n int) string {
s = strings.Join(strings.Fields(s), " ")
if len([]rune(s)) <= n {
return s
}
return string([]rune(s)[:n-1]) + "…"
}
var defaultFW = regexp.MustCompile(`(?i)\d+(?:[.\-()a-z0-9]*[0-9a-z)])?`)
// NormFirmware: Firmware-Angabe des Geräts in die Schreibweise der NVD
// bringen. pattern (aus advisory.version) mit einer Gruppe; leer = erste
// Zahlenfolge mit Punkten/Buchstaben.
func NormFirmware(raw, pattern string) string {
raw = strings.TrimSpace(raw)
if pattern != "" {
if re, err := regexp.Compile(pattern); err == nil {
if m := re.FindStringSubmatch(raw); len(m) > 1 {
return strings.ToLower(m[1])
} else if len(m) == 1 {
return strings.ToLower(m[0])
}
}
}
return strings.ToLower(defaultFW.FindString(raw))
}
// fwCmp vergleicht Firmware-Versionen (Ziffern- und Buchstabengruppen wie
// rpm, Klammern und Bindestriche trennen nur).
func fwCmp(a, b string) int {
return CompareRPM(strings.ToLower(a), strings.ToLower(b))
}
// CheckFirmware: welche CVEs die Version betreffen.
func CheckFirmware(cves []NVDCVE, version string, kev KEV) []FirmwareHit {
var hits []FirmwareHit
if version == "" {
return nil
}
for _, c := range cves {
var hit bool
var fixed string
hw := true
for _, m := range c.Matches {
ok, fx := matchFW(m, version)
if !ok {
continue
}
hit = true
hw = hw && m.HW
if fx != "" && (fixed == "" || fwCmp(fx, fixed) > 0) {
fixed = fx
}
}
if !hit {
continue
}
h := FirmwareHit{ID: c.ID, Score: c.Score, Summary: c.Summary, KEV: c.KEV, FixedIn: fixed, HW: hw}
if _, ok := kev[c.ID]; ok {
h.KEV = true
}
hits = append(hits, h)
}
sort.SliceStable(hits, func(i, j int) bool {
if hits[i].KEV != hits[j].KEV {
return hits[i].KEV
}
if hits[i].Score != hits[j].Score {
return hits[i].Score > hits[j].Score
}
return hits[i].ID > hits[j].ID
})
return hits
}
func matchFW(m NVDMatch, v string) (bool, string) {
if m.Version != "" {
return fwCmp(m.Version, v) == 0, ""
}
if m.StartIncl == "" && m.StartExcl == "" && m.EndIncl == "" && m.EndExcl == "" {
return false, "" // „alle Versionen“: zu ungenau, nicht melden
}
if m.StartIncl != "" && fwCmp(v, m.StartIncl) < 0 {
return false, ""
}
if m.StartExcl != "" && fwCmp(v, m.StartExcl) <= 0 {
return false, ""
}
if m.EndIncl != "" && fwCmp(v, m.EndIncl) > 0 {
return false, ""
}
if m.EndExcl != "" {
if fwCmp(v, m.EndExcl) >= 0 {
return false, ""
}
return true, m.EndExcl
}
return true, ""
}
// FirmwareReportFor: Bericht für ein Gerät aus den CVEs des Produkts.
func FirmwareReportFor(product, raw, pattern string, cves []NVDCVE, kev KEV) *FirmwareReport {
v := NormFirmware(raw, pattern)
r := &FirmwareReport{Product: product, Version: v, Raw: raw, Total: len(cves), At: time.Now()}
r.Hits = CheckFirmware(cves, v, kev)
for _, h := range r.Hits {
if h.FixedIn != "" && (r.MinFixed == "" || fwCmp(h.FixedIn, r.MinFixed) > 0) {
r.MinFixed = h.FixedIn
}
}
return r
}
func readNVDCache(p string) ([]NVDCVE, error) {
f, err := os.Open(p)
if err != nil {
return nil, err
}
defer f.Close()
zr, err := gzip.NewReader(f)
if err != nil {
return nil, err
}
defer zr.Close()
var c []NVDCVE
return c, json.NewDecoder(zr).Decode(&c)
}
func writeNVDCache(p string, c []NVDCVE) error {
if err := os.MkdirAll(filepath.Dir(p), 0o700); err != nil {
return err
}
tmp := p + ".tmp"
f, err := os.OpenFile(tmp, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0o600)
if err != nil {
return err
}
zw := gzip.NewWriter(f)
if err := json.NewEncoder(zw).Encode(c); err != nil {
zw.Close()
f.Close()
return err
}
if err := zw.Close(); err != nil {
f.Close()
return err
}
if err := f.Close(); err != nil {
return err
}
return os.Rename(tmp, p)
}
+109
View File
@@ -0,0 +1,109 @@
package vuln
import (
"context"
"encoding/json"
"net/http"
"net/http/httptest"
"sync/atomic"
"testing"
"time"
)
const nvdSample = `{"resultsPerPage":2,"startIndex":0,"totalResults":3,"vulnerabilities":[
{"cve":{"id":"CVE-2024-21762","vulnStatus":"Analyzed","cisaExploitAdd":"2024-02-09",
"descriptions":[{"lang":"en","value":"A out-of-bounds write in Fortinet FortiOS allows remote code execution."}],
"metrics":{"cvssMetricV31":[{"type":"Primary","cvssData":{"baseScore":9.8}}]},
"configurations":[{"nodes":[{"operator":"OR","negate":false,"cpeMatch":[
{"vulnerable":true,"criteria":"cpe:2.3:o:fortinet:fortios:*:*:*:*:*:*:*:*","versionStartIncluding":"7.2.0","versionEndExcluding":"7.2.7"},
{"vulnerable":true,"criteria":"cpe:2.3:o:fortinet:fortios:*:*:*:*:*:*:*:*","versionStartIncluding":"7.4.0","versionEndExcluding":"7.4.3"}]}]}]}},
{"cve":{"id":"CVE-2023-0001","vulnStatus":"Analyzed",
"descriptions":[{"lang":"en","value":"Only 6.x."}],
"metrics":{"cvssMetricV31":[{"type":"Primary","cvssData":{"baseScore":5.3}}]},
"configurations":[{"nodes":[{"operator":"OR","cpeMatch":[
{"vulnerable":true,"criteria":"cpe:2.3:o:fortinet:fortios:6.4.1:*:*:*:*:*:*:*"}]}]}]}}
]}`
const nvdSample2 = `{"resultsPerPage":2,"startIndex":2,"totalResults":3,"vulnerabilities":[
{"cve":{"id":"CVE-2023-0002","vulnStatus":"Analyzed",
"descriptions":[{"lang":"en","value":"Exact 7.2.5 on some models."}],
"metrics":{"cvssMetricV2":[{"cvssData":{"baseScore":7.5}}]},
"configurations":[{"operator":"AND","nodes":[
{"operator":"OR","cpeMatch":[{"vulnerable":true,"criteria":"cpe:2.3:o:fortinet:fortios:7.2.5:*:*:*:*:*:*:*"}]},
{"operator":"OR","cpeMatch":[{"vulnerable":false,"criteria":"cpe:2.3:h:fortinet:fortigate-60f:-:*:*:*:*:*:*:*"}]}]}]}}
]}`
func TestNVDFirmware(t *testing.T) {
var calls int32
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
atomic.AddInt32(&calls, 1)
if r.URL.Query().Get("virtualMatchString") != "cpe:2.3:o:fortinet:fortios" {
t.Errorf("Anfrage: %s", r.URL.RawQuery)
}
if r.Header.Get("apiKey") != "k" {
t.Error("Schlüssel fehlt")
}
if r.URL.Query().Get("startIndex") == "0" {
w.Write([]byte(nvdSample))
return
}
w.Write([]byte(nvdSample2))
}))
defer srv.Close()
n := &NVD{HTTP: HTTP{Cache: t.TempDir()}, URL: srv.URL, Key: "k", Wait: time.Millisecond}
cves, stale, err := n.Product(context.Background(), "cpe:2.3:o:fortinet:fortios", nil)
if err != nil || stale || len(cves) != 3 {
t.Fatalf("%v %v %d", err, stale, len(cves))
}
r := FirmwareReportFor("cpe:2.3:o:fortinet:fortios", "v7.2.5,build1517 (GA)", "", cves, KEV{})
if r.Version != "7.2.5" || len(r.Hits) != 2 {
t.Fatalf("%+v", r)
}
if r.Hits[0].ID != "CVE-2024-21762" || !r.Hits[0].KEV || r.Hits[0].FixedIn != "7.2.7" || r.Hits[0].HW {
t.Fatalf("%+v", r.Hits[0])
}
if !r.Hits[1].HW || r.Hits[1].Score != 7.5 {
t.Fatalf("%+v", r.Hits[1])
}
if r.MinFixed != "7.2.7" || r.Counts().KEV != 1 || r.Counts().Critical != 1 {
t.Fatalf("%+v %+v", r.MinFixed, r.Counts())
}
// zweiter Aufruf aus dem Cache
c0 := atomic.LoadInt32(&calls)
if _, _, err := n.Product(context.Background(), "cpe:2.3:o:fortinet:fortios", nil); err != nil || atomic.LoadInt32(&calls) != c0 {
t.Fatal("Cache nicht benutzt")
}
// fixe Version: nichts
if r := FirmwareReportFor("x", "7.2.7", "", cves, nil); len(r.Hits) != 0 {
t.Fatalf("%+v", r.Hits)
}
raw, _ := json.Marshal(r)
if len(raw) == 0 {
t.Fatal()
}
}
func TestNormFirmware(t *testing.T) {
for _, c := range []struct{ raw, pat, want string }{
{"WC.16.11.0012", "", "16.11.0012"},
{"15.2(7)E8", "", "15.2(7)e8"},
{"7.11.2 (stable)", "", "7.11.2"},
{"21.4R3-S5.4", `(?i)(\d+\.\d+[a-z]\d+(?:-s\d+)?)`, "21.4r3-s5"},
} {
if got := NormFirmware(c.raw, c.pat); got != c.want {
t.Errorf("%q → %q, will %q", c.raw, got, c.want)
}
}
cves := []NVDCVE{{ID: "CVE-1", Score: 8, Matches: []NVDMatch{{Version: "15.2(7)e8"}}},
{ID: "CVE-2", Score: 8, Matches: []NVDMatch{{Version: "21.4r3-s5"}}},
{ID: "CVE-3", Score: 8, Matches: []NVDMatch{{EndExcl: "15.2(7)e10"}}}}
if h := CheckFirmware(cves, "15.2(7)e8", nil); len(h) != 2 || h[0].FixedIn+h[1].FixedIn != "15.2(7)e10" {
t.Fatalf("%+v", h)
}
if h := CheckFirmware(cves, "21.4r3-s5", nil); len(h) != 1 || h[0].ID != "CVE-2" {
t.Fatalf("%+v", h)
}
if f := splitCPE(`cpe:2.3:o:cisco:ios:15.2\(7\)e8:*`); f[5] != "15.2(7)e8" {
t.Fatal(f)
}
}
+1 -1
View File
@@ -85,7 +85,7 @@
<li><kbd>⇧F10</kbd> verschiebt einen Tab in ein eigenes Terminalfenster.</li>
<li><kbd>Strg</kbd>+<kbd>F</kbd> durchsucht den Verlauf, <kbd>Strg</kbd>+<kbd>E</kbd> springt zu Fehlerzeilen. <kbd>Alt</kbd>+<kbd>S</kbd> sucht in allen offenen Tabs.</li>
<li><kbd>F9</kbd> und <kbd>⇧F1</kbd>…<kbd>⇧F8</kbd>: Schnellbefehle, passend zum Gerät vorbelegt (Linux, Windows, Aruba, Cisco, Juniper, MikroTik, FortiGate …).</li>
<li><kbd>F6</kbd> Host-Übersicht: CPU, RAM, Platte, Updates bei Servern, bei Linux Live-Graphen (<kbd>t</kbd> 5 min / 1 h, <kbd>z</kbd> groß); Firmware, Ports und VLANs bei Netzwerkgeräten; <kbd>c</kbd> Container; <kbd>s</kbd> Sicherheitscheck: installierte Pakete gegen die OSV-Datenbank (Bewertung, Reparatur vorhanden, aktiv ausgenutzt, von laufendem Dienst genutzt).</li>
<li><kbd>F6</kbd> Host-Übersicht: CPU, RAM, Platte, Updates bei Servern, bei Linux Live-Graphen (<kbd>t</kbd> 5 min / 1 h, <kbd>z</kbd> groß); Firmware, Ports und VLANs bei Netzwerkgeräten; <kbd>c</kbd> Container; <kbd>s</kbd> Sicherheitscheck: installierte Pakete gegen die OSV-Datenbank (Bewertung, Reparatur vorhanden, aktiv ausgenutzt, von laufendem Dienst genutzt); an Switches und Firewalls Firmware-Hinweise aus der NVD. Palette <em>Patch-Runde</em>: Updates gestaffelt über einen Ordner, erst ein Host, dann <kbd>w</kbd> für den Rest.</li>
<li>Reißt die Leitung ab (WLAN, VPN, Ruhezustand), verbindet sshTermy von selbst neu, startet Tunnel und hängt tmux/screen wieder an. Nach dem Aufwachen oder einem Netzwechsel werden alle Leitungen sofort geprüft.</li>
</ul>
</section>
+2
View File
@@ -153,6 +153,7 @@ sudo apt update && sudo apt install sshtermy</pre></div>
<div class="card"><h3>Log-Blick</h3><p><kbd>Alt</kbd>+<kbd>E</kbd> liest die Logs des Systems, auf dem du gerade bist (Linux, Windows, Switches, Firewalls), nur lesend, und zeigt Muster statt Zeilen: was seit dem letzten Blick neu ist, eine Zeitleiste mit Neustarts, Updates und deinen Befehlen, Rauschen pro Host oder Ordner ausblenden und ein KI-Lagebericht nur aus den verdichteten Mustern.</p></div>
<div class="card"><h3>Logwache &amp; Ordner-Scan</h3><p>Folgt im Hintergrund den Logs offener Tabs und meldet nur neue oder kritische Muster; empfängt Syslog von Switches und Firewalls. Der Ordner-Scan prüft alle Hosts eines Ordners auf einmal (auch nachts als Zeitplan) und zeigt, was mehrere gemeinsam haben. <kbd>s</kbd> im Log-Blick eines Switches richtet Syslog an sshTermy ein. Syslog von Absendern ohne gespeicherte Verbindung wird verworfen.</p></div>
<div class="card"><h3>Sicherheitscheck (OSV)</h3><p><kbd>F6</kbd> → <kbd>s</kbd> gleicht die installierten Pakete eines Linux-Servers (und seiner laufenden Container) mit der öffentlichen OSV-Datenbank ab. Zeigt nur, was zählt: Bewertung, Reparatur vorhanden, aktiv ausgenutzt (CISA KEV), von einem Dienst mit offenem Port genutzt. <kbd>u</kbd> fügt den Update-Befehl ein, <kbd>k</kbd> lässt die KI erklären. Online oder ganz offline, für einen ganzen Ordner oder wöchentlich als Zeitplan. Den Rechner verlassen nur Paketnamen und Versionen.</p></div>
<div class="card"><h3>Firmware-Hinweise &amp; Patch-Runde</h3><p><kbd>F6</kbd> → <kbd>s</kbd> am Switch oder an der Firewall prüft die Firmware gegen die NVD (FortiOS, Cisco, Junos, RouterOS, Aruba, PAN-OS …): aktiv ausgenutzt, behoben ab welcher Version. Die Patch-Runde spielt Updates gestaffelt über einen Ordner ein: erst ein Host, nach <kbd>w</kbd> der Rest, mit Vergleich von Diensten, Ports und Logs vorher/nachher und Neustarts einzeln.</p></div>
<div class="card"><h3>Sync</h3><p>Ende-zu-Ende-verschlüsselt über OneDrive, Dropbox, iCloud, Syncthing oder WebDAV (Synology, Nextcloud). Tasten, Shell und Schnittstelle gehen auch pro Rechner, Zeitpläne laufen nur auf ihrem Rechner, Favoriten zählen über alle.</p></div>
<div class="card"><h3>Systemprofil</h3><p>Kennt Linux-Distributionen, macOS, Windows und Netzwerk-Dialekte (Aruba, Cisco, Juniper, MikroTik, FortiGate, UniFi …), damit die KI passende Befehle vorschlägt.</p></div>
<div class="card"><h3>Befehlssätze</h3><p>48 Befehlssätze eingebaut (Cisco, Arista, Aruba, Comware, Huawei, Dell, Extreme, Ruckus, Palo Alto, Sophos, FortiGate, pfSense, Proxmox …). Eigene als YAML ergänzen, am Gerät testen oder von der KI entwerfen lassen, per Sync auf allen Rechnern; eigene und Team-Sätze können die eingebauten Sicherheitsregeln nie abschwächen.</p></div>
@@ -234,6 +235,7 @@ sudo apt update && sudo apt install sshtermy</pre></div>
<tr><td><kbd>F6</kbd> → <kbd>c</kbd></td><td>Container: Docker, Podman, Kubernetes (Shell, Logs, KI)</td></tr>
<tr><td><kbd>Alt</kbd>+<kbd>E</kbd> oder <kbd>F6</kbd> → <kbd>l</kbd></td><td>Log-Blick: <kbd>n</kbd> Was ist neu?, <kbd>t</kbd> Zeitleiste, <kbd>x</kbd>/<kbd>X</kbd> Rauschen ausblenden, <kbd>k</kbd> KI erklärt, <kbd>b</kbd> KI-Lagebericht, <kbd>1</kbd>…<kbd>4</kbd> Prüfbefehl, <kbd>w</kbd> Meldungen der Logwache, <kbd>s</kbd> Syslog einrichten (Switch)</td></tr>
<tr><td><kbd>F6</kbd> → <kbd>s</kbd></td><td>Sicherheitscheck (OSV): <kbd>⏎</kbd> Details, <kbd>u</kbd> Update-Befehl einfügen, <kbd>k</kbd> KI erklärt, <kbd>f</kbd> nur reparierbare, <kbd>x</kbd>/<kbd>X</kbd> für Host/Ordner hinnehmen, <kbd>o</kbd> ganzer Ordner, <kbd>c</kbd> kopieren</td></tr>
<tr><td>Palette: <em>Patch-Runde</em></td><td>Updates gestaffelt: <kbd>j</kbd> <kbd>j</kbd> starten, <kbd>w</kbd> nach dem ersten Host weiter, <kbd>x</kbd> nach dem laufenden Host beenden, <kbd>c</kbd> Bericht kopieren. Am Switch zeigt <kbd>F6</kbd> → <kbd>s</kbd> Firmware-Hinweise.</td></tr>
<tr><td><kbd>F6</kbd> → <kbd>t</kbd> / <kbd>z</kbd></td><td>Live-Graphen: Zeitraum 5 min / 1 h, groß</td></tr>
<tr><td><kbd>F5</kbd> → <kbd>e</kbd></td><td>Server-Datei im eigenen Editor (Speichern lädt hoch)</td></tr>
<tr><td><kbd>F5</kbd> → <kbd>⏎</kbd> / Doppelklick</td><td>Datei ansehen (<kbd>/</kbd> suchen, <kbd>f</kbd> mitlesen, <kbd>w</kbd> umbrechen), <kbd>o</kbd> Standardprogramm</td></tr>
Binary file not shown.
Binary file not shown.
+2
View File
@@ -153,6 +153,7 @@ sudo apt update && sudo apt install sshtermy</pre></div>
<div class="card"><h3>Log view</h3><p><kbd>Alt</kbd>+<kbd>E</kbd> reads the logs of the system you are on (Linux, Windows, switches, firewalls), read-only, and shows patterns instead of lines: what is new since your last look, a timeline with reboots, updates and your own commands, hide noise per host or folder, and an AI status report from the condensed patterns only.</p></div>
<div class="card"><h3>Log watch &amp; folder scan</h3><p>Follows the logs of open tabs in the background and reports only new or critical patterns; receives syslog from switches and firewalls. The folder scan checks every host of a folder at once (also nightly as a schedule) and shows what several hosts share. <kbd>s</kbd> in a switch's log view sets up syslog to sshTermy. Syslog from senders without a saved connection is dropped.</p></div>
<div class="card"><h3>Security check (OSV)</h3><p><kbd>F6</kbd> → <kbd>s</kbd> compares the installed packages of a Linux server (and its running containers) with the public OSV database. Shows only what matters: score, fix available, actively exploited (CISA KEV), used by a service with an open port. <kbd>u</kbd> inserts the update command, <kbd>k</kbd> lets the AI explain. Online or fully offline, for a whole folder or weekly as a schedule. Only package names and versions leave your computer.</p></div>
<div class="card"><h3>Firmware advisories &amp; patch round</h3><p><kbd>F6</kbd> → <kbd>s</kbd> on a switch or firewall checks the firmware against the NVD (FortiOS, Cisco, Junos, RouterOS, Aruba, PAN-OS …): actively exploited, fixed in which version. The patch round installs updates across a folder in stages: first one host, then after <kbd>w</kbd> the rest, comparing services, ports and logs before and after, rebooting one at a time.</p></div>
<div class="card"><h3>Sync</h3><p>End-to-end encrypted via OneDrive, Dropbox, iCloud, Syncthing or WebDAV (Synology, Nextcloud). Keys, shell and serial port can be set per computer, schedules run only on their computer, favorites count across all.</p></div>
<div class="card"><h3>System profile</h3><p>Knows Linux distributions, macOS, Windows and network OS dialects (Aruba, Cisco, Juniper, MikroTik, FortiGate, UniFi …), so the AI suggests matching commands.</p></div>
<div class="card"><h3>Command sets</h3><p>48 command sets built in (Cisco, Arista, Aruba, Comware, Huawei, Dell, Extreme, Ruckus, Palo Alto, Sophos, FortiGate, pfSense, Proxmox …). Add your own as YAML, test it on the device or let the AI draft it, synced to your other computers; own and team sets can never weaken the built-in safety rules.</p></div>
@@ -233,6 +234,7 @@ sudo apt update && sudo apt install sshtermy</pre></div>
<tr><td><kbd>F6</kbd> → <kbd>c</kbd></td><td>Containers: Docker, Podman, Kubernetes (shell, logs, AI)</td></tr>
<tr><td><kbd>Alt</kbd>+<kbd>E</kbd> or <kbd>F6</kbd> → <kbd>l</kbd></td><td>Log view: <kbd>n</kbd> what's new, <kbd>t</kbd> timeline, <kbd>x</kbd>/<kbd>X</kbd> hide noise, <kbd>k</kbd> AI explains, <kbd>b</kbd> AI status report, <kbd>1</kbd>…<kbd>4</kbd> check command, <kbd>w</kbd> log watch alerts, <kbd>s</kbd> syslog setup (switch)</td></tr>
<tr><td><kbd>F6</kbd> → <kbd>s</kbd></td><td>Security check (OSV): <kbd>⏎</kbd> details, <kbd>u</kbd> insert update command, <kbd>k</kbd> AI explains, <kbd>f</kbd> only fixable, <kbd>x</kbd>/<kbd>X</kbd> accept for host/folder, <kbd>o</kbd> whole folder, <kbd>c</kbd> copy</td></tr>
<tr><td>Palette: <em>Patch round</em></td><td>Staged updates: <kbd>j</kbd> <kbd>j</kbd> start, <kbd>w</kbd> continue after the first host, <kbd>x</kbd> stop after the current host, <kbd>c</kbd> copy report. On a switch <kbd>F6</kbd> → <kbd>s</kbd> shows firmware advisories.</td></tr>
<tr><td><kbd>F6</kbd> → <kbd>t</kbd> / <kbd>z</kbd></td><td>Live graphs: range 5 min / 1 h, large view</td></tr>
<tr><td><kbd>F5</kbd> → <kbd>e</kbd></td><td>Server file in your own editor (saving uploads it)</td></tr>
<tr><td><kbd>F5</kbd> → <kbd>⏎</kbd> / double-click</td><td>View file (<kbd>/</kbd> search, <kbd>f</kbd> follow, <kbd>w</kbd> wrap), <kbd>o</kbd> default app</td></tr>
+1 -1
View File
@@ -85,7 +85,7 @@
<li><kbd>⇧F10</kbd> moves a tab into its own terminal window.</li>
<li><kbd>Ctrl</kbd>+<kbd>F</kbd> searches the scrollback, <kbd>Ctrl</kbd>+<kbd>E</kbd> jumps to error lines. <kbd>Alt</kbd>+<kbd>S</kbd> searches all open tabs.</li>
<li><kbd>F9</kbd> and <kbd>⇧F1</kbd>…<kbd>⇧F8</kbd>: quick commands, preset for the device (Linux, Windows, Aruba, Cisco, Juniper, MikroTik, FortiGate …).</li>
<li><kbd>F6</kbd> host overview: CPU, RAM, disk, updates on servers, live graphs on Linux (<kbd>t</kbd> 5 min / 1 h, <kbd>z</kbd> large); firmware, ports and VLANs on network devices; <kbd>c</kbd> containers; <kbd>s</kbd> security check: installed packages against the OSV database (score, fix available, actively exploited, used by a running service).</li>
<li><kbd>F6</kbd> host overview: CPU, RAM, disk, updates on servers, live graphs on Linux (<kbd>t</kbd> 5 min / 1 h, <kbd>z</kbd> large); firmware, ports and VLANs on network devices; <kbd>c</kbd> containers; <kbd>s</kbd> security check: installed packages against the OSV database (score, fix available, actively exploited, used by a running service); on switches and firewalls firmware advisories from the NVD. Palette <em>Patch round</em>: staged updates across a folder, first host, then <kbd>w</kbd> for the rest.</li>
<li>If the line drops (Wi-Fi, VPN, standby), sshTermy reconnects by itself, restarts tunnels and re-attaches tmux/screen. After waking up or a network change all connections are checked right away.</li>
</ul>
</section>
+2 -2
View File
@@ -167,7 +167,7 @@ export const de = {
['↑ / ↓ · d · v', 'Stand wählen · Diff · ansehen'],
['c · g · t · z', 'Container · Grenzen · Zeitraum · groß'],
['Alt+E / l', 'Log-Blick: n neu · t Zeit · b KI · w Wache · s Syslog'],
['s', 'Sicherheitscheck: u Update · k KI · x hinnehmen'],
['s', 'Sicherheit: u Update · k KI · Switch: Firmware'],
]},
{ t: 'Suche im Verlauf', ic: '/', key: 'Strg+F', rows: [
['⏎ / ⇧⏎', 'älterer / neuerer Treffer'],
@@ -356,7 +356,7 @@ export const en = {
['↑ / ↓ · d · v', 'pick state · diff · view'],
['c · g · t · z', 'containers · limits · range · large'],
['Alt+E / l', "log view: n new · t time · b AI · w watch · s syslog"],
['s', 'security check: u update · k AI · x accept'],
['s', 'security: u update · k AI · switch: firmware'],
]},
{ t: 'Scrollback search', ic: '/', key: 'Ctrl+F', rows: [
['⏎ / ⇧⏎', 'older / newer match'],
+1 -1
View File
@@ -1 +1 @@
01834b86a6b8c183d535030d5722d10c02f327596cfb2f7c5fd7dc4e3fcfdb75
25d1de21630be943f2798a733e6df3adc49264efae83ab2d7205bb9d80bb2d03