The Open Framework for Building Agents
fix(eve): reject dot-prefixed Git ref components (#4786)
Ben Pankow7921fb0438ac
diff --git a/.changeset/git-ref-leading-dot.md b/.changeset/git-ref-leading-dot.mdnew file mode 100644index 000000000..a8078571f--- /dev/null+++ b/.changeset/git-ref-leading-dot.md@@ -0,0 +1,5 @@+---+"eve": patch+---++Self-modification now rejects target branch names Git rejects: path components starting with `.` (such as `.hidden` or `feature/.hidden`) and names containing the DEL character.diff --git a/packages/eve/src/shared/git.test.ts b/packages/eve/src/shared/git.test.tsindex ad3b4a404..e25a198fb 100644--- a/packages/eve/src/shared/git.test.ts+++ b/packages/eve/src/shared/git.test.ts@@ -16,6 +16,9 @@ describe("Git helpers", () => {it("rejects unsafe Git refs", () => {expect(isValidGitRef("feature/self-modification")).toBe(true);expect(isValidGitRef("main.lock")).toBe(false);+ expect(isValidGitRef(".hidden")).toBe(false);+ expect(isValidGitRef("feature/.hidden")).toBe(false);+ expect(isValidGitRef("feature\x7fbranch")).toBe(false);expect(isValidGitRef("main; curl example.com")).toBe(false);});diff --git a/packages/eve/src/shared/git.ts b/packages/eve/src/shared/git.tsindex 5c87d16aa..6aaa4c003 100644--- a/packages/eve/src/shared/git.ts+++ b/packages/eve/src/shared/git.ts@@ -18,8 +18,10 @@ export function isValidGitRef(value: string): boolean {value.includes("//") ||value.includes("@{") ||value.includes("\\") ||- value.split("/").some((part) => part.length === 0 || part.endsWith(".lock")) ||- /[\x00-\x20~^:?*[]/u.test(value)+ value+ .split("/")+ .some((part) => part.length === 0 || part.startsWith(".") || part.endsWith(".lock")) ||+ /[\x00-\x20\x7f~^:?*[]/u.test(value));}