(item importQueueItem, nestedFilePath string)
| 421 | } |
| 422 | |
| 423 | func resolveRemoteNestedPath(item importQueueItem, nestedFilePath string) (string, *remoteImportOrigin, error) { |
| 424 | cleanPath := path.Clean(strings.TrimPrefix(nestedFilePath, "./")) |
| 425 | if cleanPath == ".." || strings.HasPrefix(cleanPath, "../") || path.IsAbs(cleanPath) { |
| 426 | return "", nil, fmt.Errorf("nested import '%s' from remote file '%s' escapes base directory", nestedFilePath, item.importPath) |
| 427 | } |
| 428 | basePath := item.remoteOrigin.BasePath |
| 429 | if basePath == "" { |
| 430 | basePath = constants.GetWorkflowDir() |
| 431 | } |
| 432 | basePath = path.Clean(basePath) |
| 433 | resolvedPath := fmt.Sprintf("%s/%s/%s/%s@%s", |
| 434 | item.remoteOrigin.Owner, item.remoteOrigin.Repo, basePath, cleanPath, item.remoteOrigin.Ref) |
| 435 | nestedRemoteOrigin := parseRemoteOrigin(resolvedPath) |
| 436 | importLog.Printf("Resolving nested import as remote workflowspec: %s -> %s (basePath=%s)", nestedFilePath, resolvedPath, basePath) |
| 437 | return resolvedPath, nestedRemoteOrigin, nil |
| 438 | } |
| 439 | |
| 440 | func determineNestedBaseDir(item importQueueItem, resolvedPath, baseDir string) string { |
| 441 | isLocalRelative := !strings.Contains(resolvedPath, "/") || strings.HasPrefix(resolvedPath, "./") |
no test coverage detected