Repository navigation
Merged
Conversation
This was referenced Oct 15, 2026
…that leave the output directory; deprecate result_s3_bucket (#989) spawn pipeline collect read result_s3_bucket whenever a definition set it. Nothing writes there, and the stage instance profile is granted only s3_bucket/<s3_prefix>/*, so on every example that set it collect printed "No results found". It also made one ListObjectsV2 call (first 1000 keys), downloaded the COMPLETE/FAILED markers as results, and wrote each object to <output-dir>/<key> unchecked, so a key containing ".." wrote outside the directory. collect is now pipeline.CollectRunOutputs: it lists the run's stages/ tree with the paginator, keeps only data_output keys (ParseStageOutputKey, the inverse of the stage_keys output helpers), maps them to <output-dir>/<stage>/<path>, refuses the whole collection if any key's stage id or path is not local, and writes through an os.Root. --run collects an earlier run of the pipeline id. result_s3_bucket/result_s3_prefix are deprecated rather than published to: validate, launch and collect warn, and the examples no longer set them.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #989
Stacked on #988 (fix/956 → #980 → #972 → #957 → #942 → #931). Review and merge after it.
What was wrong
spawn pipeline collect:result_s3_bucketwhenever a definition set it. Nothing writes there, and the stage instance profile (StageDataPolicy) grants onlys3_bucket/<s3_prefix>/*. So onml-training.json,fanout-fanin.jsonandvideo-streaming.jsonit printed "No results found".ListObjectsV2call, collected the first 1000 keys, and reported success.COMPLETE/FAILEDmarkers as results.<output-dir>/<full key>without checking it. On the old code, the test below wrote a key.../output/../../../../../../../../../escaped.txtto a file outside the output directory (<parent>/a/b/escaped.txt). Anyone able to write tos3_bucketcould plant such a key, a stage command among them.What changed
collectis nowpipeline.CollectRunOutputs(inpkg/pipeline, because the cmd/ SDK-import gate wants AWS work there). It listsStagesPrefix(<run prefix>)withs3.NewListObjectsV2Paginator. It keeps onlydata_outputkeys, using the newParseStageOutputKey, which invertsStageOutputPrefix/StageInstanceOutputPrefixinstage_keys.go. Files go to<output-dir>/<stage>/<file>, or<output-dir>/<stage>/<index>/<file>forinstance_count > 1.--run <run-id>flag collects an earlier run of the samepipeline_id, and only accepts the run-id shape (^[0-9a-z][0-9a-z-]*$), because the value goes into an S3 prefix. When a run has no outputs, it lists the run ids that do.output/must befilepath.IsLocal. The#944dest_pathrule is the same:s/output/../t/xstays inside the directory, but it would write into staget's files, so it is refused too. Any bad key refuses the whole collection before anything is written. Two keys that clean to one path are also an error. Files are written through anos.Root, so a symlink already in the output directory cannot lead out either.Decision: deprecate
result_s3_bucket, don't publish to itdata_output? A copy also doubles storage, and a partial copy is a new failure mode.collectcan read directly. Anyone who wants results in a particular bucket can make it thes3_bucket.So the fields are still parsed, which means existing definitions load. They carry
// Deprecated:.Pipeline.Deprecations()makesvalidate,launchandcollectwarn. The three examples no longer set them, andexamples/pipelines/README.mddocuments collect and the deprecation. Stage commands still getSPAWN_RESULT_S3_*; I didn't remove those from the orchestrator user data, to avoid touching the Lambda.Tests (Substrate S3)
In
pkg/pipeline/collect_test.go,collect_keys_test.go:result_s3_bucket--run, rejection of a bad--run, and--stage../×9,sub/../×10,../train/0/best.h5, a..stage id. Each asserts a refusal and that nothing at all is written under the test's parent dirParseStageOutputKeyround-trips the helpers and rejects every marker kind and the config keyEach was run against a revert that compiles (CLAUDE.md rule 1):
<parent>/a/b/escaped.txt), DotDotStageID, StageFlag, RunFlag, RejectsRunID--run/ skip its validationresult_s3_bucketin ml-training.jsonmake check: everything passes exceptTestGenerateWrapper_ChownFixesCrossUIDStickyUnlink_Docker. That test needs a Docker daemon, which wasn't running locally, and its package is untouched.check-nestedpasses. Semgrep (p/golang, p/gosec, p/security-audit, p/secrets, run locally without metrics, so not--config=auto): 0 findings, nonosemgrep.Breaking for scripts
The local layout changed from
./results/<s3_prefix>/runs/<id>/stages/<stage>/output/<file>to./results/<stage>/<file>. This is noted in the CHANGELOG.No AWS resources were used. No Lambda redeploy is needed: this is CLI only.