mirror of
https://github.com/db9979/sshtermy.git
synced 2026-12-05 12:24:08 +01:00
* Sicherheitscheck (OSV): Pakete gegen bekannte Lücken prüfen F6 → s liest die installierten Pakete (deb/rpm/apk, optional laufende Container) nur lesend und gleicht sie mit der OSV-Datenbank ab: online über die API oder offline mit lokaler Datenbank je Distribution. Befunde mit Bewertung, Reparatur, CISA KEV und laufendem Dienst; Update-Befehl einfügen, KI-Erklärung, Hinnehmen je Host/Ordner, Ordner-Scan und Zeitplan. Doku, Webseite und Kurzreferenz mitgezogen. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018i4GUj1JqSmBpmAhAgpD8W * Sicherheitscheck: Datenrennen im Test, ungenutzte Felder, gofmt Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018i4GUj1JqSmBpmAhAgpD8W * 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 --------- Co-authored-by: Claude <noreply@anthropic.com>
73 lines
1.9 KiB
Go
73 lines
1.9 KiB
Go
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))
|
|
}
|
|
}
|