fix(package): private exchange body, printable refusals, a checked upload directory #294
Loading…
Reference in a new issue
No description provided.
Delete branch "loop/288-request-helper-hardening"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #288
Task. Issue #288 (loop item, acceptance criteria in its refine comment): the request helper stops leaving the CI job's token in a world-readable file, stops printing a registry's raw bytes to the terminal, and refuses an upload directory that is not a real directory of the user's own.
What changed (
compiler/src/package/upload.trb, one commit)exchangedToken(split out oftokenFor): the trusted-publishing body goes throughwritePrivate(made anew,0600while empty) and is emptied after the send, refused, failed or trusted. The sending is a function parameter, so the test sees the file while it is sent.printable: C0, DEL and C1 are left out, a line break becomes one space.answerOfapplies it tomessageanderror,refusalOfto a non-JSON body,tokenForto the identity answer.uploadDirectory:<work>/uploadis made where missing; a symbolic link or a non-directory in its place is refused with the path and the reason, before any write and before thechmod.requestanduploadRelease(before the archive is written) go through it. The doc comment ofrequeststates the contract.Split, decided by the loop. The "owned by another user" half of criterion 3 needs an owner query that
std/fslacks: a new native, whose use in the compiler can only be pushed after a seed refresh (two-commit rule). It moves to #293 together with the body writes and the rawprintOwnerfallback incli/registry.trb, which this PR leaves alone while #279 edits that file. Until then thechmodto0700after the new checks fails for every non-root user on a directory they do not own, so nothing is written there.Test. New group "The request helper" in
compiler/tests/packages.test.trb: control sequences (\u001b[2J,\u001b]0;x\u0007, C1, DEL, CR/LF) in a raw body, in the JSONerrorand inmessage; the directory made0700and taken again; a file and a symlink in its place refused byuploadDirectoryand byrequestwith nothing written into the link's target and its mode unchanged; the exchange body private while sent (also where an older body was0644) and empty and private after a trusted, a refused and an unreachable exchange. Locally:torb test compiler/tests/packages.test.trb --filter "The request helper"4 passed;torb format --checkon both files clean. Gates: forge CI of this PR.Review of #294 at
935fcef, CI green (gates, bootstrap, tier A, the rest of the matrix skipped as configured).error/message, the directory made0700and taken again, file and symlink in place refused byuploadDirectoryand byrequestwith nothing written into the link target, and the exchange body private while sent, empty and private after trusted / refused / unreachable.exchangedTokenempties the body whateversendreturned;printablehandles C0, DEL, C1 and collapses line breaks as stated;uploadDirectoryuseslinkMetadata, so a dangling link is refused too, and checks beforechmod.std/fs, two-commit rule), and #293 carries the acceptance criteria.0600, no secrets in the diff, doc comments ofrequestand the module state the contract.Non-blocking: until #293 lands, the
chmodfailure is the only guard against a directory owned by another user; that is documented in the PR body.