From 118790018679ac0ba7d3c550cc5c7e0e55980776 Mon Sep 17 00:00:00 2001 From: kisfenyo Date: Thu, 19 Nov 2026 08:41:29 +0100 Subject: [PATCH] =?UTF-8?q?hub=20(unreleased):=20the=20operator's=20bind?= =?UTF-8?q?=20form=20has=20a=20field=20for=20extra=20installer=20flags=20?= =?UTF-8?q?=E2=80=94=20only=20plain=20--flag=20words=20pass=20(R-1398,=20r?= =?UTF-8?q?elease=204=20Part=200)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The bind handler always read extra_args and the pairing answer always carried it; the Hosts page had no input, so --accept-small-disk could not reach a public-image install. One text input, a validator in the store (CleanApplianceExtraArgs), a 400 for a refused value. Tests TestR1398_* (4), 5 mutations red. Register: R-1035's 4-week read moved to 2026-11-26 (the operator's Search Console read; reason in the row). Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS --- documentation/backlog/OPEN-ITEMS.md | 4 +- hub/CHANGELOG.md | 9 +++ hub/internal/api/appliance_test.go | 4 +- hub/internal/api/r1398_extra_args_test.go | 33 ++++++++ hub/internal/store/appliance.go | 30 +++++++ hub/internal/web/appliances.go | 6 +- hub/internal/web/appliances_test.go | 4 +- .../web/r1398_bind_extra_args_test.go | 80 +++++++++++++++++++ hub/internal/web/templates/hosts.html | 1 + 9 files changed, 164 insertions(+), 7 deletions(-) create mode 100644 hub/internal/api/r1398_extra_args_test.go create mode 100644 hub/internal/web/r1398_bind_extra_args_test.go diff --git a/documentation/backlog/OPEN-ITEMS.md b/documentation/backlog/OPEN-ITEMS.md index 6fc3c62d..8d95ef3f 100644 --- a/documentation/backlog/OPEN-ITEMS.md +++ b/documentation/backlog/OPEN-ITEMS.md @@ -379,7 +379,7 @@ stopping line that lies. | **R-930** | Business & legal | P3 | **The site's primary call-to-action fails WCAG AA: white on `--blue` #0083D8 measures 4.01:1 at 16px/600, against a 4.5:1 floor.** MEASURED 2026-10-10 in the browser, on the LIVE home page and on the redesign preview: identical, so this is **pre-existing and site-wide**, not a regression of the redesign. It is the „Jelentkezem tesztelőnek" button and every `.cta-button` on every page. `.cta-button-secondary` is fine (7.17:1). Three fixes, all needing the operator because each touches brand: (a) darken `--blue` until the ratio clears 4.5 (changes a token used across hub, controller and website); (b) make the label 700 weight at 18.66px+, which moves it into WCAG's „large text" band where 3:1 applies and 4.01 passes, at the cost of a bigger button everywhere; (c) accept it and record the decision. **Not changed unilaterally**: `felhom-web-design` §6 puts a new accent colour behind the operator's word. | **WAITING-ON-OPERATOR** — filed 2026-10-10 by the home-page redesign session; evidence `audits/redesign-2026-10-10/AUDIT.md` | operator's choice between (a), (b), (c) | pick one of the three | operator | | **R-989** | Business & legal | P4 | **Operator: read `documentation/audits/selfhst-survey-2026-10-12/FELHOM.md` §6 and rule on each recommendation.** READ-ONLY research 2026-10-12: the selfh.st self-hosting survey 2023–2025 (1,869 / 3,655 / 4,081 respondents, hobby users) against our catalog, features, pitch and hardware. Ten ranked recommendations, none acted on; the top three: a supported-hardware page (none exists — finding, §4), off-site backup as a *why* reason in the pitch (only 25.2 % of the crowd backs up off-site), Syncthing as the largest catalog gap (25.9 %). Tables: `TABLE.md`; method and limits: `METHOD.md`. | **WAITING-ON-OPERATOR** — filed 2026-10-12 | the operator's reading | Operator: rule on each of the ten (yes / no / later). If nothing is done: nothing changes; the research ages (the 2026 survey replaces it) | operator | | **R-990** | Business & legal | P4 | **Operator: read `documentation/audits/forum-research-2026-10-12/FELHOM.md` §5 and rule on each recommendation.** READ-ONLY research 2026-10-12: three years (#7943–#11092, 2,908 posts, 195 people, 82 beginner threads) of the public PROHARDVER! topic „Home server / házi szerver építése”, tagged and counted by person (`FINDINGS.md`, method and spot-check in `METHOD.md`; no username or post text in git). Ten ranked recommendations, none acted on; the top three: a „which machine works” page (8 of 33 beginners who name their hardware own only a Synology, a router disk or a Raspberry Pi — the installer cannot run there; the same gap is R-989's first recommendation from a different source, and the shipped-page half is R-991), „you do not choose an operating system — we do” (the biggest beginner question, 20 of 82 threads), and „bring your old office PC” as the cheap entry. Catalog gap (≥ 3 people): a DLNA server (7), an ad/DNS blocker (5), a camera recorder (5). | **WAITING-ON-OPERATOR** — filed 2026-10-12 | the operator's reading | Operator: rule on each of the ten (yes / no / later). If nothing is done: nothing changes; the research ages | operator | -| **R-1035** | Business & legal | P4 | **Did the „felhő tárhely” page earn anything? Two dated checks.** **Baseline (reported by the operator from Search Console, 2026-10-14, last 3 months):** 1 click, 48 impressions, CTR 2.1 %, average position **73.6**; „felhő tárhely” 19 impressions, „felhőtárhely” 5, „felhő alapú tárhely” 3. CC measured separately that the phrase „felhő tárhely” appeared **0 times** on the home, FAQ and backup pages — Google was showing the home page for those queries by accident. `/sajat-felho-tarhely` + `/en/own-cloud-storage` published **2026-10-14**; full baseline, price sources and the power provenance in `audits/seo-2026-10-14/BASELINE.md`. **What to measure, both times:** impressions and average position for „felhő tárhely” and „saját felhő tárhely”, plus the new page's own impressions, clicks and position. **A null result at +4 weeks means nothing on its own** — a new page on a site at position 73.6 takes weeks to months to move, and „felhő tárhely” alone is held by Microsoft, Google and the big list sites; the page aims at the two longer phrases. That is why there are two checks and not one, and why neither should be read as a verdict on the copy. **There is no Search Console connector in this project, so CC cannot read these numbers** — the operator reads them, CC records and compares. **Blocked until the operator asks for indexing** (Search Console → URL-ellenőrzés → the URL → „Indexelés kérése”): until that happens, or Google finds the page itself, both checks read zero for a reason that is not the page. **This is a slow channel and does not replace talking to people.** **2026-11-11:** the 4-week check came due today in a run with no operator present; only the operator can read Search Console, so the date moved to 2026-11-18 (the gate's rule allows a move with a reason). The 8-week check keeps its date. | **WATCHING** | operator: request indexing, then supply the Search Console read | 2026-11-11: first read (+4 weeks); 2026-12-09: second (+8 weeks), compared with the first | operator + CC | +| **R-1035** | Business & legal | P4 | **Did the „felhő tárhely” page earn anything? Two dated checks.** **Baseline (reported by the operator from Search Console, 2026-10-14, last 3 months):** 1 click, 48 impressions, CTR 2.1 %, average position **73.6**; „felhő tárhely” 19 impressions, „felhőtárhely” 5, „felhő alapú tárhely” 3. CC measured separately that the phrase „felhő tárhely” appeared **0 times** on the home, FAQ and backup pages — Google was showing the home page for those queries by accident. `/sajat-felho-tarhely` + `/en/own-cloud-storage` published **2026-10-14**; full baseline, price sources and the power provenance in `audits/seo-2026-10-14/BASELINE.md`. **What to measure, both times:** impressions and average position for „felhő tárhely” and „saját felhő tárhely”, plus the new page's own impressions, clicks and position. **A null result at +4 weeks means nothing on its own** — a new page on a site at position 73.6 takes weeks to months to move, and „felhő tárhely” alone is held by Microsoft, Google and the big list sites; the page aims at the two longer phrases. That is why there are two checks and not one, and why neither should be read as a verdict on the copy. **There is no Search Console connector in this project, so CC cannot read these numbers** — the operator reads them, CC records and compares. **Blocked until the operator asks for indexing** (Search Console → URL-ellenőrzés → the URL → „Indexelés kérése”): until that happens, or Google finds the page itself, both checks read zero for a reason that is not the page. **This is a slow channel and does not replace talking to people.** **2026-11-11:** the 4-week check came due today in a run with no operator present; only the operator can read Search Console, so the date moved to 2026-11-18 (the gate's rule allows a move with a reason). The 8-week check keeps its date. | **WATCHING** — 2026-11-19: the 4-week read moved to 2026-11-26 (it is the operator's read from Search Console; the release run of this day cannot take it, and asks in its note). | operator: request indexing, then supply the Search Console read | 2026-11-11: first read (+4 weeks); 2026-12-09: second (+8 weeks), compared with the first | operator + CC | ## Process & tooling — 36 rows (P3 9, P4 27) @@ -426,7 +426,7 @@ stopping line that lies. | item | due (UTC) | what to measure | |---|---|---| | R-1293 | 2027-03-29 | the spring clock change: the hub's 02:00 snapshot and the 02:30 push on 2027-03-28 (02:00–03:00 does not exist) — which file each push took; detail in the R-1293 row | -| R-1035 | 2026-11-18 | „felhő tárhely” + „saját felhő tárhely” impressions and average position, and the new page's own impressions/clicks/position, 4 weeks after publishing; operator supplies the read; detail in the R-1035 row | +| R-1035 | 2026-11-26 | „felhő tárhely” + „saját felhő tárhely” impressions and average position, and the new page's own impressions/clicks/position, 4 weeks after publishing; operator supplies the read; detail in the R-1035 row | | R-528 | 2026-11-28 | no further failed oom_check after the one on 2026-11-11 (demo-felhom), no unexplained app_oom; detail in the R-528 row | | R-1035 | 2026-12-09 | the same three numbers 8 weeks after publishing, compared with the 4-week read; a null at 4 weeks is not a verdict, both reads are needed; detail in the R-1035 row | diff --git a/hub/CHANGELOG.md b/hub/CHANGELOG.md index b8a8281c..cd02842f 100644 --- a/hub/CHANGELOG.md +++ b/hub/CHANGELOG.md @@ -1,5 +1,14 @@ ## Unreleased (after v0.182.0) +- **R-1398 (2026-11-19, release 4 Part 0): the operator's bind form has a field for extra installer flags.** The bind + handler always read `extra_args` and the pairing answer always carried it to the first-boot unit, which appends it to + the installer's command line — but the Hosts page offered no input, so `--accept-small-disk` could not reach an install + from the public image. Now the form has one text input (`name="extra_args"`, the example `--accept-small-disk`), and + only plain `--flag` words pass (`store.CleanApplianceExtraArgs`: `^--[a-z][a-z0-9-]{0,40}$`, at most 8 words, joined + by one space; no value, no quote, no shell character — the unit splits the text on spaces). A refused value is a 400 + and changes nothing; the store refuses it too, for any caller. The household's own bind still sends none. **A value + flag such as `--cores 4` is now refused** (the page never offered one). Tests `TestR1398_*` (4); 5 mutations red + (no field; the word check off; the word limit off; the store's check off; the answer drops the value). - **Review of the notice lock, finding 6 (2026-11-15 night): the test-only helpers in production files cannot be used by the product.** `store.SetEndNoticeForTest` (it writes „told” with any date), `store.BackdateNotificationLogForTest` and `notify.Dispatcher.SetSendFnForTest` must stay in production files — diff --git a/hub/internal/api/appliance_test.go b/hub/internal/api/appliance_test.go index 0e7a97a7..ac553474 100644 --- a/hub/internal/api/appliance_test.go +++ b/hub/internal/api/appliance_test.go @@ -95,7 +95,7 @@ func TestAppliancePoll_OneShotAnd410(t *testing.T) { // Operator binds it. list, _ := st.ListUnclaimedAppliances() - if err := st.BindAppliance(list[0].ID, "acme", "appliance", "--cores 4"); err != nil { + if err := st.BindAppliance(list[0].ID, "acme", "appliance", "--accept-small-disk"); err != nil { t.Fatal(err) } @@ -107,7 +107,7 @@ func TestAppliancePoll_OneShotAnd410(t *testing.T) { var creds map[string]string json.Unmarshal(rr.Body.Bytes(), &creds) if creds["customer_id"] != "acme" || creds["retrieval_passphrase"] != "the-passphrase" || - creds["mode"] != "appliance" || creds["extra_args"] != "--cores 4" { + creds["mode"] != "appliance" || creds["extra_args"] != "--accept-small-disk" { t.Fatalf("delivery payload wrong: %+v", creds) } diff --git a/hub/internal/api/r1398_extra_args_test.go b/hub/internal/api/r1398_extra_args_test.go new file mode 100644 index 00000000..d9f89522 --- /dev/null +++ b/hub/internal/api/r1398_extra_args_test.go @@ -0,0 +1,33 @@ +package api + +import ( + "encoding/json" + "testing" + + "gitea.dooplex.hu/admin/felhom-hub/internal/store" +) + +// R-1398: the flag the operator puts in the bind form reaches the box in the pairing answer, word for word — +// the first-boot unit appends exactly this text to the installer's command line (felhom-bootstrap.sh, read -ra). +func TestR1398_ExtraArgsReachThePairingAnswer(t *testing.T) { + h, st, _ := newTestHandler(t) + if err := st.SaveCustomerConfig(&store.CustomerConfig{CustomerID: "acme", APIKey: "k", RetrievalPassword: "pw"}); err != nil { + t.Fatal(err) + } + token := registerAppliance(t, h, "uuid-X", []string{"bc:24:11:98:10:0e"}) + list, _ := st.ListUnclaimedAppliances() + if err := st.BindAppliance(list[0].ID, "acme", "appliance", " --accept-small-disk "); err != nil { + t.Fatal(err) + } + rr := poll(t, h, token) + if rr.Code != 200 { + t.Fatalf("bound poll = %d", rr.Code) + } + var creds map[string]string + if err := json.Unmarshal(rr.Body.Bytes(), &creds); err != nil { + t.Fatal(err) + } + if creds["extra_args"] != "--accept-small-disk" { + t.Fatalf("extra_args in the pairing answer = %q, want --accept-small-disk", creds["extra_args"]) + } +} diff --git a/hub/internal/store/appliance.go b/hub/internal/store/appliance.go index d39e11c8..9c640f91 100644 --- a/hub/internal/store/appliance.go +++ b/hub/internal/store/appliance.go @@ -3,6 +3,8 @@ package store import ( "database/sql" "fmt" + "regexp" + "strings" "time" ) @@ -216,6 +218,10 @@ func (s *Store) ListUnclaimedAppliances() ([]ApplianceRegistration, error) { // or an already-bound-not-delivered state (operator re-bind / changed mind). Refuses once delivered or // discarded. func (s *Store) BindAppliance(id int64, customerID, mode, extraArgs string) error { + extraArgs, err := CleanApplianceExtraArgs(extraArgs) + if err != nil { + return err + } res, err := s.db.Exec(`UPDATE appliance_registrations SET status = 'bound', customer_id = ?, install_mode = ?, extra_args = ?, bound_at = datetime('now') WHERE id = ? AND status IN ('registered','bound')`, customerID, mode, extraArgs, id) @@ -259,3 +265,27 @@ func (s *Store) DiscardAppliance(id int64) error { } return nil } + +// applianceFlagWord is one plain installer flag: two dashes, a lower-case letter, then letters, digits and dashes. +var applianceFlagWord = regexp.MustCompile(`^--[a-z][a-z0-9-]{0,40}$`) + +// maxApplianceExtraArgs bounds the number of words; the installer has fewer than 40 flags in all. +const maxApplianceExtraArgs = 8 + +// CleanApplianceExtraArgs checks the operator's extra installer arguments for a bind (R-1398, release 4) and +// returns them joined by one space. Only plain `--flag` words pass — no value, no quote, no shell character — +// because the first-boot unit splits the text on spaces and hands each word to the installer as it is +// (`scripts/iso/felhom-bootstrap.sh`, `read -ra`). An empty text is allowed (no extra arguments). +// Pinned by TestR1398_BindRefusesExtraArgsThatAreNotPlainFlags and TestR1398_ExtraArgsReachThePairingAnswer. +func CleanApplianceExtraArgs(s string) (string, error) { + words := strings.Fields(s) + if len(words) > maxApplianceExtraArgs { + return "", fmt.Errorf("extra installer arguments: at most %d words", maxApplianceExtraArgs) + } + for _, w := range words { + if !applianceFlagWord.MatchString(w) { + return "", fmt.Errorf("extra installer arguments: %q is not a plain --flag word", w) + } + } + return strings.Join(words, " "), nil +} diff --git a/hub/internal/web/appliances.go b/hub/internal/web/appliances.go index ba595216..3b4b324f 100644 --- a/hub/internal/web/appliances.go +++ b/hub/internal/web/appliances.go @@ -137,11 +137,15 @@ func (s *Server) handleApplianceBind(w http.ResponseWriter, r *http.Request, id if mode == "" { mode = "appliance" } - extraArgs := strings.TrimSpace(r.FormValue("extra_args")) + extraArgs, xerr := store.CleanApplianceExtraArgs(r.FormValue("extra_args")) if customerID == "" { http.Error(w, "customer_id is required", http.StatusBadRequest) return } + if xerr != nil { + http.Error(w, "Bind refused: "+xerr.Error(), http.StatusBadRequest) + return + } cc, err := s.store.GetCustomerConfig(customerID) if err != nil { s.logger.Printf("[ERROR] appliance bind %d: customer lookup: %v", id, err) diff --git a/hub/internal/web/appliances_test.go b/hub/internal/web/appliances_test.go index 3936fd42..a07701c3 100644 --- a/hub/internal/web/appliances_test.go +++ b/hub/internal/web/appliances_test.go @@ -70,7 +70,7 @@ func TestAppliances_BindStagesDelivery(t *testing.T) { } id := seedAppliance(t, st, "uuid-bind", "bc:24:11:98:10:0e") - form := url.Values{"customer_id": {"acme"}, "mode": {"appliance"}, "extra_args": {"--cores 4"}} + form := url.Values{"customer_id": {"acme"}, "mode": {"appliance"}, "extra_args": {" --accept-small-disk "}} req := httptest.NewRequest("POST", "/appliances/x/bind", strings.NewReader(form.Encode())) req.Header.Set("Content-Type", "application/x-www-form-urlencoded") rr := httptest.NewRecorder() @@ -80,7 +80,7 @@ func TestAppliances_BindStagesDelivery(t *testing.T) { } // The appliance is now bound with the staged delivery. a, _ := st.GetAppliance(id) - if a.Status != store.ApplianceBound || a.CustomerID != "acme" || a.InstallMode != "appliance" || a.ExtraArgs != "--cores 4" { + if a.Status != store.ApplianceBound || a.CustomerID != "acme" || a.InstallMode != "appliance" || a.ExtraArgs != "--accept-small-disk" { t.Fatalf("bind did not stage the delivery: %+v", a) } // Audit event recorded (a customer scopes it now). diff --git a/hub/internal/web/r1398_bind_extra_args_test.go b/hub/internal/web/r1398_bind_extra_args_test.go new file mode 100644 index 00000000..1867f0f5 --- /dev/null +++ b/hub/internal/web/r1398_bind_extra_args_test.go @@ -0,0 +1,80 @@ +package web + +import ( + "net/http" + "net/http/httptest" + "net/url" + "strings" + "testing" + + "gitea.dooplex.hu/admin/felhom-hub/internal/store" +) + +// R-1398 (release 4, 2026-11-19): the operator's bind form offers the extra installer flags the handler has always +// read, so `--accept-small-disk` can reach an install from the public image. Only plain --flag words pass. + +func TestR1398_TheBindFormHasTheExtraArgsField(t *testing.T) { + s, st := newTestServer(t) + if err := st.SaveCustomerConfig(&store.CustomerConfig{CustomerID: "acme", CustomerName: "Acme", APIKey: "k", RetrievalPassword: "pw"}); err != nil { + t.Fatal(err) + } + seedAppliance(t, st, "uuid-field", "bc:24:11:98:10:0e") + html := renderHosts(t, s) + form := html[strings.Index(html, `/bind"`):] + form = form[:strings.Index(form, "")] + if !strings.Contains(form, `name="extra_args"`) { + t.Fatalf("the bind form has no extra_args input:\n%s", form) + } + if !strings.Contains(form, "--accept-small-disk") { + t.Error("the field does not name the one flag it exists for") + } +} + +func TestR1398_BindRefusesExtraArgsThatAreNotPlainFlags(t *testing.T) { + for _, bad := range []string{ + "--cores 4", // a value + "--accept-small-disk;reboot", // a shell character + "-f", // one dash + "--Accept", // upper case + "--a=b", // an equals sign + "'--force'", // a quote + "--a --b --c --d --e --f --g --h --i", // too many words + } { + t.Run(bad, func(t *testing.T) { + s, st := newTestServer(t) + if err := st.SaveCustomerConfig(&store.CustomerConfig{CustomerID: "acme", APIKey: "k", RetrievalPassword: "pw"}); err != nil { + t.Fatal(err) + } + id := seedAppliance(t, st, "uuid-bad", "bc:24:11:98:10:0e") + form := url.Values{"customer_id": {"acme"}, "extra_args": {bad}} + req := httptest.NewRequest("POST", "/appliances/x/bind", strings.NewReader(form.Encode())) + req.Header.Set("Content-Type", "application/x-www-form-urlencoded") + rr := httptest.NewRecorder() + s.handleApplianceBind(rr, req, id) + if rr.Code != http.StatusBadRequest { + t.Fatalf("bind with %q = %d, want 400", bad, rr.Code) + } + if a, _ := st.GetAppliance(id); a.Status != store.ApplianceRegistered || a.ExtraArgs != "" { + t.Fatalf("a refused bind changed the appliance: %+v", a) + } + // The store refuses it too, for any other caller. + if err := st.BindAppliance(id, "acme", "appliance", bad); err == nil { + t.Fatalf("the store took %q", bad) + } + }) + } +} + +func TestR1398_BindTakesPlainFlagsAndEmpty(t *testing.T) { + for in, want := range map[string]string{ + "": "", + " ": "", + "--accept-small-disk": "--accept-small-disk", + " --accept-small-disk\t--no-oob ": "--accept-small-disk --no-oob", + } { + got, err := store.CleanApplianceExtraArgs(in) + if err != nil || got != want { + t.Errorf("CleanApplianceExtraArgs(%q) = %q, %v; want %q", in, got, err, want) + } + } +} diff --git a/hub/internal/web/templates/hosts.html b/hub/internal/web/templates/hosts.html index e77dc93e..d3d09ff7 100644 --- a/hub/internal/web/templates/hosts.html +++ b/hub/internal/web/templates/hosts.html @@ -95,6 +95,7 @@ {{range $.CustomerPicker}}{{end}} +