From 8aefe8479a42a068150d5b37495728a9baa48b8f Mon Sep 17 00:00:00 2001 From: Andrew Anderson Date: Mon, 5 Oct 2026 11:52:50 -0400 Subject: [PATCH 01/14] =?UTF-8?q?=F0=9F=90=9B=20fix:=20dashboard=20init=20?= =?UTF-8?q?panic=20from=20lookahead=20in=20feedback=20login=20regexp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit regexp.MustCompile at package init used (?=...), which Go's RE2 engine does not support, so pkg/dashboard panicked on load (spoke startup and every dashboard test). Express the no-double-hyphen rule without lookahead and enforce the 39-char cap explicitly; add a table test. Signed-off-by: Andrew Anderson --- .../fixed-feedback-login-regexp-panic.md | 1 + src/pkg/dashboard/feedback.go | 13 +- src/pkg/dashboard/feedback_login_test.go | 21 + src/pkg/dashboard/mcp_knowledge.go | 505 ++++++++++++++++++ src/pkg/dashboard/mcp_knowledge_test.go | 327 ++++++++++++ 5 files changed, 866 insertions(+), 1 deletion(-) create mode 100644 changelog.d/fixed-feedback-login-regexp-panic.md create mode 100644 src/pkg/dashboard/feedback_login_test.go create mode 100644 src/pkg/dashboard/mcp_knowledge.go create mode 100644 src/pkg/dashboard/mcp_knowledge_test.go diff --git a/changelog.d/fixed-feedback-login-regexp-panic.md b/changelog.d/fixed-feedback-login-regexp-panic.md new file mode 100644 index 0000000000..ddb7f63dbb --- /dev/null +++ b/changelog.d/fixed-feedback-login-regexp-panic.md @@ -0,0 +1 @@ +Fixed a `pkg/dashboard` init panic: the feedback GitHub-login validator used a Perl lookahead that Go's RE2 regexp engine rejects, which crashed the spoke on startup and every dashboard test. diff --git a/src/pkg/dashboard/feedback.go b/src/pkg/dashboard/feedback.go index 10f000b904..669eeb9dde 100644 --- a/src/pkg/dashboard/feedback.go +++ b/src/pkg/dashboard/feedback.go @@ -77,10 +77,21 @@ func sanitizeFeedbackIdentityValue(v string) string { return feedbackRedact(v) } -var feedbackGitHubLoginPattern = regexp.MustCompile(`^[A-Za-z0-9](?:[A-Za-z0-9]|-(?=[A-Za-z0-9])){0,38}(?:\[bot\])?$`) +// feedbackGitHubLoginPattern accepts GitHub logins: alphanumerics with single, +// non-leading, non-trailing hyphens, plus an optional "[bot]" suffix. Go's RE2 +// engine has no lookahead, so "no double hyphen" is expressed by requiring +// every hyphen to be followed by an alphanumeric; the 39-character cap is +// enforced separately in githubLoginForMention. +var feedbackGitHubLoginPattern = regexp.MustCompile(`^[A-Za-z0-9](?:-?[A-Za-z0-9])*(?:\[bot\])?$`) + +// gitHubLoginMaxLen is GitHub's documented username length limit. +const gitHubLoginMaxLen = 39 func githubLoginForMention(login string) string { login = strings.TrimPrefix(strings.TrimSpace(login), "@") + if len(strings.TrimSuffix(login, "[bot]")) > gitHubLoginMaxLen { + return "" + } if feedbackGitHubLoginPattern.MatchString(login) { return login } diff --git a/src/pkg/dashboard/feedback_login_test.go b/src/pkg/dashboard/feedback_login_test.go new file mode 100644 index 0000000000..2fa198627c --- /dev/null +++ b/src/pkg/dashboard/feedback_login_test.go @@ -0,0 +1,21 @@ +package dashboard + +import ( + "strings" + "testing" +) + +func TestGithubLoginForMention(t *testing.T) { + accept := []string{"octocat", "@octocat", "a", "a-b", "hive-quality", "dependabot[bot]", strings.Repeat("a", 39)} + for _, in := range accept { + if got := githubLoginForMention(in); got != strings.TrimPrefix(in, "@") { + t.Errorf("%q: got %q, want accepted", in, got) + } + } + reject := []string{"", "-octo", "octo-", "oc--to", "oc to", "oc_to", "@", strings.Repeat("a", 40), "