Permit safe cross-run output declarations
This commit is contained in:
@@ -155,7 +155,7 @@ func Resolve(
|
||||
result.SkippedMissing = append(result.SkippedMissing, requirement.Name)
|
||||
continue
|
||||
}
|
||||
selectedRel, err := publishedOutputRelativePath(previousSessionPrefix, current.RunID, selectedArtifact.DestinationKey)
|
||||
selectedRel, err := publishedOutputRelativePath(previousSessionPrefix, selectedArtifact.DestinationKey)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("resolve declared previous-session artifact %q: %w", requirement.Name, err)
|
||||
}
|
||||
@@ -209,11 +209,14 @@ func committedPublishedArtifactBySource(commit *artifacts.RemoteCommitManifest,
|
||||
return artifacts.RemoteArtifact{}, false
|
||||
}
|
||||
|
||||
func publishedOutputRelativePath(sessionPrefix, runID, destinationKey string) (string, error) {
|
||||
prefix := artifacts.S3RunRelativeDestinationKey(artifacts.S3RunPrefix(sessionPrefix, runID), "published") + "/"
|
||||
rel, ok := strings.CutPrefix(strings.TrimSpace(destinationKey), prefix)
|
||||
func publishedOutputRelativePath(sessionPrefix, destinationKey string) (string, error) {
|
||||
identity, err := artifacts.ParseImmutableRunObjectKey(sessionPrefix, destinationKey)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
rel, ok := strings.CutPrefix(identity.RelativePath, "published/")
|
||||
if !ok || strings.TrimSpace(rel) == "" {
|
||||
return "", fmt.Errorf("destination %q is outside selected run published-output prefix %q", destinationKey, prefix)
|
||||
return "", fmt.Errorf("destination %q is outside its immutable run published-output prefix", destinationKey)
|
||||
}
|
||||
normalized, err := pathsafe.NormalizeRelativeDestination(rel)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user