hub (unreleased): review fix 3 — a name that reaches a household's mail is a plain app slug; a link-shaped name gets no notice and is never agreed

Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
admin committed 2026-11-15 17:03:19 +01:00
1 parent 7b46dbcc3e
commit 73a534e753
7 files changed
+131 -3

No files matched your search

@@ -0,0 +1,60 @@
package api
import (
"os"
"path/filepath"
"strings"
"testing"
"gitea.dooplex.hu/admin/felhom-hub/internal/store"
)
// THE INDEPENDENT REVIEW OF THE NOTICE LOCK (2026-11-15 night). One test per finding, each seen red before its fix:
// documentation/audits/build-release-4b-2026-11-15/A/redproof-review-<n>.txt.
// Finding 3. A box could put a link-shaped word into the household's subject — `www.evil-bank.example.com`, five a
// day: the app-record's name rule allows dots and capitals, and a notice row was made for a name the hub never saw
// installed. A name that reaches a household's mail must be a plain app slug (store.ValidNoticeApp): lower-case
// letters, digits, `-`, `_`; no dot. Anything else: no row, no mail, never agreed.
func TestReview3_ALinkShapedNameNeverReachesTheHousehold(t *testing.T) {
r := newNoticeRig(t, household)
for _, name := range []string{"www.evil-bank.example.com", "evil.example", "Felhom-Support", "a.b", "x..y"} {
r.report(pressed(name, "2026-11-15T10:00:00Z"))
if got := r.to(household); len(got) != 0 {
t.Fatalf("%q reached the household: subject %q", name, got[0].subject)
}
if _, ok := r.notice(name); ok {
t.Fatalf("%q has a notice row", name)
}
}
// positive control: a plain slug is told
r.report(pressed("paperless-ngx", "2026-11-15T10:00:00Z"))
if got := r.to(household); len(got) != 1 || !strings.Contains(got[0].subject, "paperless-ngx: ") {
t.Fatalf("a plain app name must be told: %+v", got)
}
}
// The slug rule fits every app the catalog has (read from the sibling repository when it is there).
func TestReview3_EveryCatalogAppNameIsANoticeName(t *testing.T) {
dir := filepath.Join("..", "..", "..", "..", "app-catalog-felhom.eu", "templates")
entries, err := os.ReadDir(dir)
if err != nil {
t.Skipf("the catalog repository is not beside this one (%v)", err)
}
n := 0
for _, e := range entries {
if !e.IsDir() {
continue
}
if _, err := os.Stat(filepath.Join(dir, e.Name(), ".felhom.yml")); err != nil {
continue
}
n++
if !store.ValidNoticeApp(e.Name()) {
t.Errorf("the catalog app %q is not a notice name — its household could never be told, and its copies never deleted", e.Name())
}
}
if n < 50 {
t.Fatalf("only %d catalog apps read — the test stopped reading the catalog", n)
}
}