MCPcopy Index your code
hub / github.com/google/go-github / TestNewRequest_pathTraversal

Function TestNewRequest_pathTraversal

github/github_test.go:1715–1736  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1713}
1714
1715func TestNewRequest_pathTraversal(t *testing.T) {
1716 t.Parallel()
1717 c := mustNewClient(t)
1718
1719 tests := []struct {
1720 urlStr string
1721 wantError bool
1722 }{
1723 {"repos/o/r/readme", false},
1724 {"repos/o/r/contents/file..txt", false},
1725 {"repos/x/../../../admin/users", true},
1726 {"repos/../admin", true},
1727 }
1728 for _, tt := range tests {
1729 _, err := c.NewRequest(t.Context(), "GET", tt.urlStr, nil)
1730 if tt.wantError && !errors.Is(err, ErrPathForbidden) {
1731 t.Errorf("NewRequest(%q): want ErrPathForbidden, got %v", tt.urlStr, err)
1732 } else if !tt.wantError && err != nil {
1733 t.Errorf("NewRequest(%q): unexpected error: %v", tt.urlStr, err)
1734 }
1735 }
1736}
1737
1738func TestNewFormRequest_pathTraversal(t *testing.T) {
1739 t.Parallel()

Callers

nothing calls this directly

Calls 3

mustNewClientFunction · 0.85
NewRequestMethod · 0.80
IsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…