Skip to content

Commit b8bb2be

Browse files
committed
v0.19.0: 69.4% code coverage (+3.9%), session null-byte validation
Coverage gains across all packages: - cmd/odek: 44.1% → 49.9% (wsapprover, readFile O_NOFOLLOW, writeFile path confinement, searchFiles, isBinary, patch error paths, jsonResult, shorten, expandHome, buildSandboxArgs, loadMCPTools) - internal/danger: 77.3% → 82.8% (NewTTYApprover, SetTrustedClasses, PromptCommand/PromptOperation error paths, classifier helpers) - internal/resource: 74.1% → 91.1% (describeFile, formatDuration, SessionResolver.Search/Load, ParseRefs edge cases) - internal/session: 74.1% → 79.3% (ValidateSessionID edge cases, NewStore invalid dir, null byte validation, generateID, Latest) - internal/memory: 80.4% → 82.5% (sanitizeLine, BuildSystemPrompt injection scan, EpisodeStore.Write error paths, ReplaceFact) - internal/skills: 83.0% → 84.5% (fetchLocal path traversal/file-not-found, LoadFromDir with empty dir, RecordUsage concurrency) Security fix: ValidateSessionID now rejects null bytes (\\x00)
1 parent 2ec3db0 commit b8bb2be

17 files changed

Lines changed: 2900 additions & 3 deletions

cmd/odek/browser_tool_test.go

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,71 @@ func TestBrowser_ExtractsInteractiveElements(t *testing.T) {
333333
}
334334
}
335335

336+
// ── URL Resolution Tests ───────────────────────────────────────────────
337+
338+
func TestResolveURL_RelativeURL(t *testing.T) {
339+
// Relative URL should resolve against base
340+
result := resolveURL("/page2", "https://example.com")
341+
if result != "https://example.com/page2" {
342+
t.Errorf("resolveURL('/page2', 'https://example.com') = %q, want 'https://example.com/page2'", result)
343+
}
344+
}
345+
346+
func TestResolveURL_RelativePath(t *testing.T) {
347+
// Relative path without leading slash
348+
result := resolveURL("page2", "https://example.com/base/")
349+
if result != "https://example.com/base/page2" {
350+
t.Errorf("resolveURL('page2', 'https://example.com/base/') = %q, want 'https://example.com/base/page2'", result)
351+
}
352+
}
353+
354+
func TestResolveURL_AbsoluteURL(t *testing.T) {
355+
// Absolute URL should be returned as-is
356+
result := resolveURL("https://other.com/page", "https://example.com")
357+
if result != "https://other.com/page" {
358+
t.Errorf("resolveURL('https://other.com/page', ...) = %q, want 'https://other.com/page'", result)
359+
}
360+
}
361+
362+
func TestResolveURL_AlreadyAbsolute(t *testing.T) {
363+
result := resolveURL("http://example.com/page", "https://base.com")
364+
if result != "http://example.com/page" {
365+
t.Errorf("resolveURL('http://example.com/page', ...) = %q, want 'http://example.com/page'", result)
366+
}
367+
}
368+
369+
func TestResolveURL_EmptyBase(t *testing.T) {
370+
// When base is empty, the href should be returned as-is
371+
result := resolveURL("/some-path", "")
372+
if result != "/some-path" {
373+
t.Errorf("resolveURL('/some-path', '') = %q, want '/some-path'", result)
374+
}
375+
}
376+
377+
func TestResolveURL_InvalidBase(t *testing.T) {
378+
// When base is invalid, fall back to href
379+
result := resolveURL("/path", "://invalid-url")
380+
if result != "/path" {
381+
t.Errorf("resolveURL('/path', '://invalid-url') = %q, want '/path'", result)
382+
}
383+
}
384+
385+
func TestResolveURL_FragmentURL(t *testing.T) {
386+
// Fragment-only URL should resolve to the base page
387+
result := resolveURL("#section", "https://example.com/page")
388+
if !strings.Contains(result, "#section") {
389+
t.Errorf("resolveURL('#section', ...) = %q, want to include '#section'", result)
390+
}
391+
}
392+
393+
func TestResolveURL_SameDirRelative(t *testing.T) {
394+
result := resolveURL("other.html", "https://example.com/dir/page.html")
395+
want := "https://example.com/dir/other.html"
396+
if result != want {
397+
t.Errorf("resolveURL('other.html', 'https://example.com/dir/page.html') = %q, want %q", result, want)
398+
}
399+
}
400+
336401
// ── Browser Bad Action Parameters ─────────────────────────────────────
337402

338403
func TestBrowser_Navigate_BadJSON(t *testing.T) {

0 commit comments

Comments
 (0)