Repository navigation
fix(publish): upload the personal-drive body from an opened descriptor - #24733
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS The design holds up: uploading the in-memory Notes
[DESIGN-REVIEWED] fde5fac Description read[DESCRIPTION-READ] fb33469dcb9c494a935fa59be8640537e094f11e9b4938416fd42a62f57b72a2 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. The Windows branch ships a temp copy plus a checksum pin, but the description says Windows "keeps the by-name body". Notes
What this change shipsInventory (4 items) — 2 justifiedIntent: make the personal drive upload exactly the bytes it read and digested, not a file name the CLI could find swapped by the time it opens it — FIX (#13370).
[FIRST-PRINCIPLES-REVIEWED] fde5fac Description read[DESCRIPTION-READ] b165295fefaa763d3f473a7bc08d0ec8c9f8b719fe8f3462c0d8c1e4157d08ed That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
46f9424 to
f7ce12a
Compare
|
Thanks — the blocking finding was right, and it is fixed in The window was moved, not closed (First Principles, Opus 5.5, GPT 6.1). The previous head re-opened the artifact by name inside Fix: FIFO / non-regular open (GPT 6.1). Also resolved by the same change: Duplicate constants (First Principles, item 4). Removed. Tests updated: |
f7ce12a to
ed8a71e
Compare
|
Fixed in macOS crash (First Principles, Opus 5.5, GPT 6.1). Right — Windows arm description (First Principles, item 3). The docstring now matches the diff: on Windows (no The earlier core finding (upload pinned to the already-read payload rather than a re-read name) stays fixed. Tests unchanged and still prove it; 154 related tests + lint/type green. |
ed8a71e to
7298f00
Compare
|
Fixed in Windows body substitution (GPT 6.1). Correct — the Windows arm writes the payload to a named temp ( New test |
7298f00 to
088ca43
Compare
The personal cloud drive's _put passed the staged artifact to the AWS CLI as --body <path>, so the CLI re-opened that name after this process had read and digested the bytes. A same-user process could re-point the name between the read and the CLI's open, uploading bytes the product never produced -- off-host, under the user's own key, with no recall. Route the body through the merged engine seam instead: open the file once here (O_NOFOLLOW, proven a regular file), hand the descriptor to run_aws as stdin_fd, and spell --body as /dev/stdin so the CLI resolves no path at all. Windows (no /dev/stdin) keeps the by-name body, matching the aws-control upload seam's own split. Fixes #13370
088ca43 to
fde5fac
Compare
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: fix (6 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: uploads the personal-drive body from the bytes already read and digested instead of re-opening the file by name; adds tests.
Problem / Motivation
Goal: The personal cloud drive uploads the exact bytes it staged and checked, never a file name the AWS CLI re-opens afterwards.
PersonalDriveProvider._putpassed the staged artifact tos3api put-objectas--body <path>. Its callers (publish,push_version) read the payload and take its content digest from the bytes on disk, but then hand the CLI a name — so the CLI re-opens that name after this process measured it. Between those two moments a process running as the same user can re-point the name, and the bytes that leave are not the bytes that were staged.Why it matters
The upload is off-host and unattended, with no recall. A substituted body means an object in the user's own bucket, under the user's own key, carrying content the product never produced. Nothing downstream can tell: the digest the provider stored as object metadata was taken from the staged bytes, not from what the CLI re-opened.
Not a goal
cloud/source.py. That site is already safe onorigin/main: it stages the tarball in a launcher-owned private directory and pins the upload with--checksum-sha256(digest taken at write time) +--expected-bucket-owner, which closes the same window downstream of the CLI's open (landed in fix(cloud): stage the launch source tarball in a launcher-owned directory #13640). Converting it to the descriptor seam would be a redundant refactor of already-safe code.engine. It reuses thestdin_fdparameter already ondeploy.engine.run_aws/_checked.What changed (motivation -> approach -> change)
_puthands--body <path>, so the CLI re-resolves the name after the payload was read and digested._putnow opens the path once (O_NOFOLLOW, proven a regular file withS_ISREG), hands that descriptor toengine._checked(..., stdin_fd=fd), and spells--bodyas/dev/stdin, so the CLI resolves no path at all. The descriptor is closed in afinally. Windows has no/dev/stdin, so there_putkeeps the by-name body — the same platform split the aws-control upload seam already draws, and for the same reason.The seam this reuses was built and merged for the backup archive in #13272 (
storage.put_filebody_fd,run_awsstdin_fd,--body /dev/stdin); this change routes one more product site through it.Why this change
#13370 asked to fix the remaining by-name
s3api put-objectsites. Read against currentorigin/main, two of the three originally-named sites are already handled:put_fileandcloud/source.pyboth gained protection (the archive descriptor seam, and #13640's private-staging + checksum pin respectively).personal_drive._putis the one product site still passing a re-resolvable name with no pin, so it is the whole of what this PR changes. The fix is opt-in-free and changes no default, UI, or output for any user — the uploaded bytes and stored metadata are identical; only how the CLI is told where to read the body changes.Backwards compatibility
Compatible:
_put's signature and the object it writes (key, content-type, cache-control, sha256 metadata) are unchanged; only the body-delivery mechanism changes. Removes nothing: no path, record, key, validator, or public function is removed or tightened.Tests
test/test_publish_personal_drive_body_fd.py(POSIX-gated):test_publish_hands_the_body_over_as_a_descriptor_not_a_name— the recordedput-objectuses--body /dev/stdinover a real descriptor.test_a_swapped_name_cannot_change_the_uploaded_bytes— the stub plays the CLI, re-points the artifact name to different bytes at open time, and reads what actually reaches it through the handed-over descriptor; the original bytes are what leave.Both fail on
origin/main(which passes--body <path>with no descriptor) and pass on this branch. The shared test helper and four local_checkedstubs are widened to accept thestdin_fdkeyword the merged seam now passes.Proof: PROVEN (both new assertions fail with the production hunk reverted) (head 46f9424)
Manual verification
N/A — unit coverage drives the real
_putpath with the engine seam stubbed; no AWS is reached.Screenshots / video
N/A — no user-visible frontend surface is touched.
Related Issues
Fixes #13370
Sibling sweep
Swept:
git grep -nE '"--body"' -- src/kiro_crew(every products3api put-objectbody site)src/kiro_crew/apps/builtins/aws_control/backend/storage.py(put_file) -- not affected -- archive callers already hand over a descriptor viabody_fd; bare-name bodies there are the label sidecar / library push, out of this issue's scope.src/kiro_crew/cloud/source.py(upload_source) -- not affected -- already pinned by--checksum-sha256+ private staging on main (fix(cloud): stage the launch source tarball in a launcher-owned directory #13640).website/electron/scripts/sign-windows.js-- not affected -- release-signing host, guarded by a sha256 compare either side; out of product scope.Pattern harvest
Not generalizable: the remaining product body sites were enumerated in the sibling sweep and are each already handled or out of scope; this is the last unconverted one, not a recurring class.
Checklist