MCPcopy Index your code
hub / github.com/go-git/go-git / TreeEntryFile

Method TreeEntryFile

plumbing/object/tree.go:127–138  ·  view source on GitHub ↗

TreeEntryFile returns the *File for a given *TreeEntry. The entry's name is validated against pathutil.ValidTreePath for the same reason FindEntry validates: TreeEntryFile is a boundary where attacker-controlled tree data leaves the trusted store as a *File whose Name a caller can hand to filesyste

(e *TreeEntry)

Source from the content-addressed store, hash-verified

125// where attacker-controlled tree data leaves the trusted store as a
126// *File whose Name a caller can hand to filesystem ops.
127func (t *Tree) TreeEntryFile(e *TreeEntry) (*File, error) {
128 if err := pathutil.ValidTreePath(e.Name); err != nil {
129 return nil, err
130 }
131
132 blob, err := GetBlob(t.s, e.Hash)
133 if err != nil {
134 return nil, err
135 }
136
137 return NewFile(e.Name, e.Mode, blob), nil
138}
139
140// FindEntry search a TreeEntry in this tree or any subtree.
141//

Callers 1

FilesMethod · 0.80

Calls 3

ValidTreePathFunction · 0.92
GetBlobFunction · 0.85
NewFileFunction · 0.85

Tested by

no test coverage detected