From 0ac4d80a520328fabaf478a6f6c48e70bd79e91b Mon Sep 17 00:00:00 2001 From: LGuichet Date: Fri, 30 Oct 2026 18:50:49 +0100 Subject: [PATCH 1/5] =?UTF-8?q?=F0=9F=94=A7=20chore(deps):=20bump=20Go=20t?= =?UTF-8?q?oolchain=201.26.9=20->=201.26.10=20for=20GO-2026-6809?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit govulncheck in CI fails on GO-2026-6809 (crypto/x509), reached through the atomic writer's temp-file naming (fsutil.createTemp -> rand.Read). The fix ships in go1.26.10; bump every workflow pin and go.mod together, as the 1.26.9 bump did. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/ci.yml | 8 ++++---- .github/workflows/codeql.yml | 2 +- .github/workflows/govulncheck.yml | 2 +- .github/workflows/release.yml | 2 +- CHANGELOG.md | 2 ++ go.mod | 2 +- 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 067a660..f75e4c3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,7 +45,7 @@ jobs: steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 - with: { go-version: '1.26.9' } + with: { go-version: '1.26.10' } - name: gofmt run: test -z "$(gofmt -l .)" || (gofmt -l . && exit 1) - name: vet @@ -65,7 +65,7 @@ jobs: steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 - with: { go-version: '1.26.9' } + with: { go-version: '1.26.10' } - name: golangci-lint uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0 with: @@ -84,7 +84,7 @@ jobs: steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 - with: { go-version: '1.26.9' } + with: { go-version: '1.26.10' } - name: fuzz untrusted-input parsers (negative control — normal input passes) run: | set -euo pipefail @@ -259,7 +259,7 @@ jobs: echo "negative control rejected as required — the schema gate catches malformed manifests" - name: set up Go uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 - with: { go-version: '1.26.9' } + with: { go-version: '1.26.10' } - name: leak gate + offline validator on the packaged artifact # The Go suite validates the manifest offline AND runs the leak gate over # the packaged skill payload (declared skills resolve to shareable, no diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 2ec80b3..38807f6 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -22,7 +22,7 @@ jobs: steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 - with: { go-version: '1.26.9' } + with: { go-version: '1.26.10' } - name: Initialize CodeQL uses: github/codeql-action/init@1c5b675653bb5c22dbe9b12b556ec555138e09fd # v4.38.1 with: diff --git a/.github/workflows/govulncheck.yml b/.github/workflows/govulncheck.yml index bc44303..5c47024 100644 --- a/.github/workflows/govulncheck.yml +++ b/.github/workflows/govulncheck.yml @@ -16,7 +16,7 @@ jobs: steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 - with: { go-version: '1.26.9' } + with: { go-version: '1.26.10' } - name: govulncheck run: | go install golang.org/x/vuln/cmd/govulncheck@latest diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 07138dd..cd4c409 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,7 +18,7 @@ jobs: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: { fetch-depth: 0 } - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 - with: { go-version: '1.26.9' } + with: { go-version: '1.26.10' } # Refuse to publish a tag whose version has no real changelog entry. This # runs BEFORE goreleaser, so an empty release fails the build rather than # publishing and being reported after the fact. The gate asserts a dated, diff --git a/CHANGELOG.md b/CHANGELOG.md index ac28f83..d3aa339 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,6 +51,8 @@ tagged release, goreleaser generates the release notes from the commit log - The Go toolchain was bumped from 1.26.6 to 1.26.9 to pick up patched standard-library fixes for seven disclosed vulnerabilities (GO-2026-6603, -6607, -6608, -6611, -6612, -6613, -6617), clearing `govulncheck` in CI. +- The Go toolchain was bumped from 1.26.9 to 1.26.10 for the `crypto/x509` + fix (GO-2026-6809), reached through the atomic writer's temp-file naming. ## [0.4.0] - 2026-08-19 diff --git a/go.mod b/go.mod index d52125b..2f38766 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/cwest/okfctl -go 1.26.9 +go 1.26.10 require ( github.com/spf13/cobra v1.10.2 From 37f74c6de3ccdd6a056e0f933daf0353f8a8fe9b Mon Sep 17 00:00:00 2001 From: LGuichet Date: Fri, 30 Oct 2026 18:50:50 +0100 Subject: [PATCH 2/5] =?UTF-8?q?=F0=9F=9A=A8=20fix(lint):=20clear=20golangc?= =?UTF-8?q?i-lint=20errorlint=20and=20staticcheck=20findings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - confine.go: wrap the underlying cause with %w beside ErrEscapesRoot, so errors.Is still matches ErrEscapesRoot and now also sees the cause. - confine.go: trim leading separators with TrimLeftFunc; on Unix the cutset `string(filepath.Separator)+"/"` repeated '/' (SA1024). - tagfold.go: apply De Morgan to the double-s guard (QF1001); same logic. Co-Authored-By: Claude Opus 5.5 --- internal/fsutil/confine.go | 6 +++--- internal/okf/tagfold.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/fsutil/confine.go b/internal/fsutil/confine.go index 535e83f..8d0b3a1 100644 --- a/internal/fsutil/confine.go +++ b/internal/fsutil/confine.go @@ -69,7 +69,7 @@ func ResolveInRoot(root, rel string) (string, error) { if filepath.VolumeName(native) != "" { return "", fmt.Errorf("%w: %s", ErrEscapesRoot, rel) } - native = strings.TrimLeft(native, string(filepath.Separator)+"/") + native = strings.TrimLeftFunc(native, func(r rune) bool { return r == '/' || r == filepath.Separator }) clean := filepath.Clean(native) if clean == "." || native == "" { return "", fmt.Errorf("%w: %q names the bundle root", ErrInvalidPath, rel) @@ -103,7 +103,7 @@ func ResolveInRoot(root, rel string) (string, error) { } realExisting, err := filepath.EvalSymlinks(existing) if err != nil { - return "", fmt.Errorf("%w: %s (%v)", ErrEscapesRoot, rel, err) + return "", fmt.Errorf("%w: %s (%w)", ErrEscapesRoot, rel, err) } if !within(realRoot, realExisting) { return "", fmt.Errorf("%w: %s resolves through a symlink to %s", ErrEscapesRoot, rel, realExisting) @@ -122,7 +122,7 @@ func ResolveInRoot(root, rel string) (string, error) { cur = filepath.Join(cur, part) fi, err := os.Lstat(cur) if err != nil { - return "", fmt.Errorf("%w: %s (%v)", ErrEscapesRoot, rel, err) + return "", fmt.Errorf("%w: %s (%w)", ErrEscapesRoot, rel, err) } if fi.Mode()&(os.ModeSymlink|os.ModeIrregular) == 0 { continue diff --git a/internal/okf/tagfold.go b/internal/okf/tagfold.go index 12aa59c..b88be48 100644 --- a/internal/okf/tagfold.go +++ b/internal/okf/tagfold.go @@ -79,7 +79,7 @@ func tagPluralCandidates(w string) []string { case strings.HasSuffix(w, "es"): j := n - 3 // the letter before "es" var out []string - if j > 0 && !(w[j] == 's' && w[j-1] == 's') { + if j > 0 && (w[j] != 's' || w[j-1] != 's') { out = append(out, w[:n-1]) } return append(out, w[:n-2]) From 3d81980b07ccc7707e23b41d828c8943dd393f5a Mon Sep 17 00:00:00 2001 From: LGuichet Date: Fri, 30 Oct 2026 18:50:51 +0100 Subject: [PATCH 3/5] =?UTF-8?q?=F0=9F=90=9B=20fix(touch):=20keep=20an=20em?= =?UTF-8?q?pty=20null=20frontmatter=20key=20null=20on=20refresh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit An explicit empty key (`? `) is a null key, which a map decode drops. The `modified` refresh round-trips the block through yaml.v3, whose encoder writes that empty plain scalar back as a quoted empty string, so the touched node gained a "" key it never had. FuzzTouchModifiedRoundTrip caught it in CI (`touch added keys: [] -> [ modified]`). Rewrite such keys as `~` before encoding, at every depth. A key that already is a quoted empty string is real data and keeps its quotes (negative control). The failing input joins the fuzz seeds. Co-Authored-By: Claude Opus 5.5 --- internal/okf/frontmatter_edit.go | 21 ++++++++++++++ internal/okf/frontmatter_edit_test.go | 40 +++++++++++++++++++++++++++ internal/okf/writepath_fuzz_test.go | 1 + 3 files changed, 62 insertions(+) diff --git a/internal/okf/frontmatter_edit.go b/internal/okf/frontmatter_edit.go index 878e60f..8846ab1 100644 --- a/internal/okf/frontmatter_edit.go +++ b/internal/okf/frontmatter_edit.go @@ -69,6 +69,7 @@ func TouchModifiedFile(abs string, at time.Time) error { return fmt.Errorf("frontmatter of %s is not a mapping", abs) } setScalar(root, "modified", stamp) + keepEmptyNullKeysNull(root) var fmBuf bytes.Buffer enc := yaml.NewEncoder(&fmBuf) @@ -104,6 +105,26 @@ func frontmatterMapping(doc *yaml.Node) *yaml.Node { return doc } +// keepEmptyNullKeysNull rewrites every mapping key that is an empty plain null +// (an explicit `? ` key) as `~`, recursively. yaml.v3 encodes that empty plain +// scalar as an empty quoted STRING, so a refresh would otherwise invent a key +// the node never had. `~` is the same null, spelled so it survives the encoder. +// A key that is already a quoted empty string is real data and is left alone. +func keepEmptyNullKeysNull(n *yaml.Node) { + for _, c := range n.Content { + keepEmptyNullKeysNull(c) + } + if n.Kind != yaml.MappingNode { + return + } + for i := 0; i+1 < len(n.Content); i += 2 { + k := n.Content[i] + if k.Kind == yaml.ScalarNode && k.Value == "" && k.Style == 0 && k.ShortTag() == "!!null" { + k.Value = "~" + } + } +} + // setScalar updates the scalar value of key in a mapping node in place, // preserving key order; if the key is absent it is appended, keeping the // original keys ahead of it. diff --git a/internal/okf/frontmatter_edit_test.go b/internal/okf/frontmatter_edit_test.go index 64e091f..3da152f 100644 --- a/internal/okf/frontmatter_edit_test.go +++ b/internal/okf/frontmatter_edit_test.go @@ -99,6 +99,46 @@ func TestTouchModifiedFileAddsMissingModified(t *testing.T) { } } +// A null key written as an empty explicit key (`? `) must stay null across a +// refresh. yaml.v3 re-encodes that empty plain scalar as an empty quoted STRING +// key, which a parser then reads as a key the node never had (the +// FuzzTouchModifiedRoundTrip failure `touch added keys: [] -> [ modified]`, +// where the blank is the empty key). The negative +// control: a key that really is the empty string keeps its quotes. +func TestTouchModifiedFileKeepsEmptyNullKeyNull(t *testing.T) { + at := time.Date(2026, 7, 26, 0, 0, 0, 0, time.UTC) + cases := []struct { + name, src string + wantKeys int // keys a parser sees after the touch + }{ + {"null key stays null", "---\n? \n---\n", 1}, + {"nested null key stays null", "---\na:\n ? \n---\n", 2}, + {"empty string key stays a key", "---\n'': x\n---\n", 2}, + } + for _, c := range cases { + t.Run(c.name, func(t *testing.T) { + abs := filepath.Join(t.TempDir(), "n.md") + if err := os.WriteFile(abs, []byte(c.src), 0o644); err != nil { + t.Fatal(err) + } + if err := TouchModifiedFile(abs, at); err != nil { + t.Fatalf("TouchModifiedFile: %v", err) + } + got := readAll(t, abs) + fm, _, err := ParseFrontmatter([]byte(got)) + if err != nil { + t.Fatalf("touched frontmatter does not parse: %v\n%q", err, got) + } + if len(fm) != c.wantKeys { + t.Fatalf("got %d keys %q, want %d:\n%q", len(fm), sortedKeys(fm), c.wantKeys, got) + } + if c.name == "nested null key stays null" && strings.Contains(got, "''") { + t.Fatalf("nested null key re-encoded as an empty string:\n%q", got) + } + }) + } +} + // The separator blank line between the frontmatter fence and the body must // survive a refresh byte-for-byte. The corpus writes `---\n\n# Heading`; a // refresh that collapses that to `---\n# Heading` is a prose change the drift diff --git a/internal/okf/writepath_fuzz_test.go b/internal/okf/writepath_fuzz_test.go index 803e1be..ae2e4d2 100644 --- a/internal/okf/writepath_fuzz_test.go +++ b/internal/okf/writepath_fuzz_test.go @@ -113,6 +113,7 @@ func FuzzTouchModifiedRoundTrip(f *testing.F) { "---\r\ntype: Reference\r\n---\r\n\r\nCRLF body\r\n", "---\ntitle: |\n line\n ---\n injected: true\n---\n", "---\n- a list\n---\n", + "---\n? \n---\n", // an empty null key: re-encoded as '' it became a new key "", } for _, s := range seeds { From e6c74cc3e54c9a429d158df00f5ee43360e7d217 Mon Sep 17 00:00:00 2001 From: LGuichet Date: Fri, 30 Oct 2026 18:52:16 +0100 Subject: [PATCH 4/5] =?UTF-8?q?=F0=9F=93=9D=20docs(index):=20document=20di?= =?UTF-8?q?r/index.md=20subdirectory=20links=20and=20the=20touch=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The index guide and the changelog describe the link form index build writes since the merge of #11, how an older index migrates, and the empty-null-key fix in this PR. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 11 +++++++++++ docs/guides/index-and-freshness.md | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d3aa339..ef5f099 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,8 +26,19 @@ tagged release, goreleaser generates the release notes from the commit log reference that cannot be loaded is a hard error naming the path (plain `validate` without `--templates` never consults the key). (#182) +### Changed + +- `index build` now links a subdirectory entry to the child's index file + (`* [Wine](wine/index.md)`) instead of the bare directory (`wine/`), so a + reader that can only open files can follow it. An index written by an older + build reads as stale under `index check` once; the next `index build` + rewrites its links and keeps hand-written subdirectory descriptions. + ### Fixed +- `node touch` and every other `modified` refresh no longer turn an empty null + frontmatter key (`? `) into an empty-string key the node never had. + - `validate` now enforces OKF v0.2 §9 on every reserved `log.md` at any depth: each `## ` date heading must be a valid ISO-8601 `YYYY-MM-DD` (rejecting impossible dates like `2025-13-45` and non-dates like `last Tuesday`), diff --git a/docs/guides/index-and-freshness.md b/docs/guides/index-and-freshness.md index 96762ca..9121d96 100644 --- a/docs/guides/index-and-freshness.md +++ b/docs/guides/index-and-freshness.md @@ -8,6 +8,14 @@ concepts or subdirectories, enumerating only that directory's own contents with index carries frontmatter (the §12 `okf_version` marker); every nested index carries none. +A subdirectory entry links to the child's own index file, as in +`* [Wine](wine/index.md) - description`, not to the bare directory, so a reader that can only open files +(an agent's read tool, a plain Markdown viewer) can follow it. §8 leaves the +relative URL open; its `subdir/` example is one spelling, not a rule. An index +written by an older build with `wine/` links reads as stale under `index check` +until the next `index build`, which rewrites the links and keeps every +hand-written subdirectory description. + - `okfctl index build [dir]` regenerates the reserved `index.md` files from the current bundle. Orphaned indexes left in a now-empty directory are pruned. - `okfctl index check [dir]` verifies every directory's `index.md` is current; From 24dcd3748fe7c0bf888db49061b72f46905ab70f Mon Sep 17 00:00:00 2001 From: LGuichet Date: Fri, 30 Oct 2026 19:05:03 +0100 Subject: [PATCH 5/5] =?UTF-8?q?=F0=9F=90=9B=20fix(touch):=20refuse=20a=20f?= =?UTF-8?q?rontmatter=20block=20the=20parser=20rejects?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Decoding into a yaml.Node skips map-level checks such as a duplicate key, so the modified refresh rewrote an invalid block (`ype: 0` then `ype:`) instead of refusing it and leaving the file byte-identical. FuzzTouchModifiedRoundTrip caught it in CI on #12. Run the frontmatter parser first and return its error; the input joins the fuzz seeds. Co-Authored-By: Claude Opus 5.5 --- internal/okf/frontmatter_edit.go | 7 +++++++ internal/okf/writepath_fuzz_test.go | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/okf/frontmatter_edit.go b/internal/okf/frontmatter_edit.go index 8846ab1..ae4a4aa 100644 --- a/internal/okf/frontmatter_edit.go +++ b/internal/okf/frontmatter_edit.go @@ -60,6 +60,13 @@ func TouchModifiedFile(abs string, at time.Time) error { return fsutil.WriteFileAtomic(abs, out.Bytes(), 0o644) //nolint:gosec // G306: shareable bundle content file } + // Refuse a block the frontmatter parser rejects. Decoding into a yaml.Node + // skips the map-level checks (a duplicate key, for one), so without this the + // refresh would rewrite an invalid block instead of leaving it byte-identical. + if _, _, err := ParseFrontmatter(raw); err != nil { + return fmt.Errorf("parse frontmatter of %s: %w", abs, err) + } + var doc yaml.Node if err := yaml.Unmarshal(yamlBlock, &doc); err != nil { return fmt.Errorf("parse frontmatter of %s: %w", abs, err) diff --git a/internal/okf/writepath_fuzz_test.go b/internal/okf/writepath_fuzz_test.go index ae2e4d2..c434fd4 100644 --- a/internal/okf/writepath_fuzz_test.go +++ b/internal/okf/writepath_fuzz_test.go @@ -113,7 +113,8 @@ func FuzzTouchModifiedRoundTrip(f *testing.F) { "---\r\ntype: Reference\r\n---\r\n\r\nCRLF body\r\n", "---\ntitle: |\n line\n ---\n injected: true\n---\n", "---\n- a list\n---\n", - "---\n? \n---\n", // an empty null key: re-encoded as '' it became a new key + "---\n? \n---\n", // an empty null key: re-encoded as '' it became a new key + "---\nype: 0\nype:\n---\n", // a duplicate key: the parser rejects it, so touch must too "", } for _, s := range seeds {