Validate published output declarations
This commit is contained in:
@@ -353,14 +353,15 @@ func TestRestorePlanTraversalUnsafeKeyFails(t *testing.T) {
|
||||
func seedCurrentRestoreObject(t *testing.T, store *storage.FakeBackend, current *RemoteCurrentState, key string, data []byte) {
|
||||
t.Helper()
|
||||
artifactType := artifacts.RemoteArtifactTypePublishedOutput
|
||||
source := "narratio.restore." + strings.ReplaceAll(strings.TrimPrefix(key, current.SessionPrefix), "/", ".")
|
||||
sourceKey := strings.NewReplacer("/", "_", ".", "_", "-", "_").Replace(strings.TrimPrefix(key, current.SessionPrefix))
|
||||
source := artifacts.ConfiguredArtifactSourceID(sourceKey)
|
||||
destination := key
|
||||
if key == current.CurrentManifestKey {
|
||||
artifactType = artifacts.RemoteArtifactTypeSessionManifest
|
||||
source = "session.manifest"
|
||||
current.ManifestData = append([]byte(nil), data...)
|
||||
} else if strings.HasPrefix(key, current.SessionPrefix) {
|
||||
destination = artifacts.S3RunPrefix(current.SessionPrefix, current.RunID) + strings.TrimPrefix(key, current.SessionPrefix)
|
||||
destination = artifacts.S3RunPrefix(current.SessionPrefix, current.RunID) + "published/" + strings.TrimPrefix(key, current.SessionPrefix)
|
||||
}
|
||||
seedRestoreObject(store, destination, data)
|
||||
current.Commit.Artifacts = append(current.Commit.Artifacts, remoteRestoreArtifact(store, artifactType, source, destination))
|
||||
@@ -397,11 +398,11 @@ func seedRestoreObject(store *storage.FakeBackend, key string, data []byte) {
|
||||
destination := key
|
||||
if strings.HasPrefix(key, sessionPrefix) && !strings.HasPrefix(key, runPrefix) {
|
||||
relative := strings.TrimPrefix(key, sessionPrefix)
|
||||
destination = runPrefix + relative
|
||||
destination = runPrefix + "published/" + relative
|
||||
store.SeedObject(storage.FakeObject{Key: destination, Data: data})
|
||||
}
|
||||
typeID := artifacts.RemoteArtifactTypePublishedOutput
|
||||
source := "narratio.test"
|
||||
source := artifacts.ConfiguredArtifactSourceID("test")
|
||||
if destination == artifacts.S3RunSessionManifestKey(sessionPrefix, pointer.RunID) {
|
||||
typeID, source = artifacts.RemoteArtifactTypeSessionManifest, "session.manifest"
|
||||
} else if relative := strings.TrimPrefix(destination, runPrefix); strings.HasPrefix(relative, "artifacts/") || strings.HasPrefix(relative, "published/artifacts/") {
|
||||
|
||||
Reference in New Issue
Block a user