MCPcopy Create free account
hub / github.com/github/gh-aw / resolveAndValidateRemoteSymlinkBase

Function resolveAndValidateRemoteSymlinkBase

pkg/parser/remote_fetch.go:854–866  ·  view source on GitHub ↗
(parentDir, target, dirPath string)

Source from the content-addressed store, hash-verified

852}
853
854func resolveAndValidateRemoteSymlinkBase(parentDir, target, dirPath string) (string, error) {
855 remoteLog.Printf("Resolving symlink: component=%s target=%s parentDir=%s", dirPath, target, parentDir)
856 resolvedBase := pathpkg.Clean(target)
857 if parentDir != "" {
858 resolvedBase = pathpkg.Clean(pathpkg.Join(parentDir, target))
859 }
860 remoteLog.Printf("Resolved base after path.Clean: %s", resolvedBase)
861 if resolvedBase == "" || resolvedBase == "." || pathpkg.IsAbs(resolvedBase) || strings.HasPrefix(resolvedBase, "..") {
862 remoteLog.Printf("Rejecting resolved base %q (escapes repository root)", resolvedBase)
863 return "", fmt.Errorf("symlink target %q at %s resolves outside repository root: %s", target, dirPath, resolvedBase)
864 }
865 return resolvedBase, nil
866}
867
868// DownloadFileFromGitHub downloads a file from a GitHub repository using the GitHub API.
869// This is the exported wrapper for downloadFileFromGitHub.

Callers 1

Calls 2

PrintfMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected