fix(handlers/org_helpers_test): use t.Fatal in error-path tests + fix DotDotWithIntermediate logic
Some checks failed
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 3s
Harness Replays / detect-changes (pull_request) Successful in 9s
CI / Detect changes (pull_request) Successful in 13s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 11s
E2E Staging Canvas (Playwright) / detect-changes (pull_request) Successful in 18s
security-review / approved (pull_request) Failing after 16s
E2E API Smoke Test / detect-changes (pull_request) Successful in 19s
qa-review / approved (pull_request) Successful in 16s
Handlers Postgres Integration / detect-changes (pull_request) Successful in 20s
Harness Replays / Harness Replays (pull_request) Successful in 7s
gate-check-v3 / gate-check (pull_request) Failing after 19s
sop-checklist / na-declarations (pull_request) N/A: qa-review, security-review
Runtime PR-Built Compatibility / detect-changes (pull_request) Successful in 24s
sop-checklist / all-items-acked (pull_request) Successful in 15s
CI / Canvas (Next.js) (pull_request) Successful in 6s
sop-tier-check / tier-check (pull_request) Successful in 13s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 5s
CI / Python Lint & Test (pull_request) Successful in 5s
E2E Staging Canvas (Playwright) / Canvas tabs E2E (pull_request) Successful in 5s
CI / Canvas Deploy Reminder (pull_request) Successful in 2s
Runtime PR-Built Compatibility / PR-built wheel + import smoke (pull_request) Successful in 2s
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 1m4s
CI / Platform (Go) (pull_request) Failing after 1m57s
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Failing after 1m54s
CI / all-required (pull_request) Successful in 3s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Successful in 2m6s
audit-force-merge / audit (pull_request) Successful in 3s
Some checks failed
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 3s
Harness Replays / detect-changes (pull_request) Successful in 9s
CI / Detect changes (pull_request) Successful in 13s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 11s
E2E Staging Canvas (Playwright) / detect-changes (pull_request) Successful in 18s
security-review / approved (pull_request) Failing after 16s
E2E API Smoke Test / detect-changes (pull_request) Successful in 19s
qa-review / approved (pull_request) Successful in 16s
Handlers Postgres Integration / detect-changes (pull_request) Successful in 20s
Harness Replays / Harness Replays (pull_request) Successful in 7s
gate-check-v3 / gate-check (pull_request) Failing after 19s
sop-checklist / na-declarations (pull_request) N/A: qa-review, security-review
Runtime PR-Built Compatibility / detect-changes (pull_request) Successful in 24s
sop-checklist / all-items-acked (pull_request) Successful in 15s
CI / Canvas (Next.js) (pull_request) Successful in 6s
sop-tier-check / tier-check (pull_request) Successful in 13s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 5s
CI / Python Lint & Test (pull_request) Successful in 5s
E2E Staging Canvas (Playwright) / Canvas tabs E2E (pull_request) Successful in 5s
CI / Canvas Deploy Reminder (pull_request) Successful in 2s
Runtime PR-Built Compatibility / PR-built wheel + import smoke (pull_request) Successful in 2s
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 1m4s
CI / Platform (Go) (pull_request) Failing after 1m57s
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Failing after 1m54s
CI / all-required (pull_request) Successful in 3s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Successful in 2m6s
audit-force-merge / audit (pull_request) Successful in 3s
Issue #965 regression. Fix 1 — nil-panic in error-path tests: Six resolveInsideRoot tests called t.Errorf then continued to err.Error() on a potentially-nil error. Replace t.Errorf/t.Error with t.Fatalf/t.Fatal in the nil-error branch so execution stops before the nil dereference: - TestResolveInsideRoot_EmptyUserPath - TestResolveInsideRoot_AbsolutePathRejected - TestResolveInsideRoot_DotDotTraversal - TestResolveInsideRoot_NestedDotDotEscapes - TestResolveInsideRoot_DotdotAtStart Fix 2 — TestResolveInsideRoot_DotDotWithIntermediate logic correction: a/b/../../c normalises to "c" — a valid descendant inside any root. The previous test expected an error (wrong: path does NOT escape). Rewrite to use t.TempDir() and assert the resolved path stays within root. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
8026f02050
commit
6cbf880b04
@ -45,13 +45,19 @@ func TestResolveInsideRoot_DotDotTraversal(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestResolveInsideRoot_DotDotWithIntermediate(t *testing.T) {
|
||||
// a/b/../../c should escape if a/b is not under root
|
||||
got, err := resolveInsideRoot("/safe/root", "a/b/../../c")
|
||||
if err == nil {
|
||||
t.Fatalf("dotdot with intermediate: expected error, got %q", got)
|
||||
// a/b/../../c normalises to "c" — a valid descendant inside any root.
|
||||
// Must use t.TempDir() for a real filesystem path so filepath.Abs resolves.
|
||||
root := t.TempDir()
|
||||
got, err := resolveInsideRoot(root, "a/b/../../c")
|
||||
if err != nil {
|
||||
t.Fatalf("a/b/../../c should resolve within root: %v", err)
|
||||
}
|
||||
if err.Error() != "path escapes root" {
|
||||
t.Errorf("dotdot with intermediate: got %q, want %q", err.Error(), "path escapes root")
|
||||
// Verify result is inside root and ends with "c"
|
||||
if !strings.HasPrefix(got, root+string(filepath.Separator)) {
|
||||
t.Errorf("result should be inside root %q, got %q", root, got)
|
||||
}
|
||||
if got[len(got)-1:] != "c" {
|
||||
t.Errorf("resolved path should end in 'c', got %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user