Repository navigation
fix(server): ban each put of an object outside AttachmentStorage.AddAsync - #541
Conversation
…sync The sweep of the bucket keeps an object only for Attachments:AddTimeout and a margin, and only AttachmentStorage.AddAsync ends its put and the save of its row within that time. A put on another path could lose its object to the sweep while its row still names it (#536). ObjectWriter now holds the put that ObjectStorage had. BannedSymbols.txt bans ObjectWriter and the Amazon.S3 namespace in the Server (RS0030), and each error names AttachmentStorage.AddAsync. AddAsync suppresses the ban for the put, and the three storage files suppress it for the S3 client. BannedApiSuppressionTests pins the four files.
A suppression on the whole class let a put added to ObjectStorage compile, and each Server file could call it. Each S3 member now suppresses RS0030 on its own, so a new member that calls S3 fails the build. The update note in docs/template-updates.md gives the steps for an app whose build fails at a put outside AttachmentStorage.AddAsync.
…mbers of ObjectStorage
|
Proof that the ban fails on puts outside the owner. Each scratch change was built, then removed. Scratch Scratch TLC ( |
|
review-gate: passed 53cf2ca Two rounds of pdstack:thermo-nuclear-review-subagent (opus). Round 1 found two medium findings: (M1) a class-level RS0030 suppression on ObjectStorage let a put added back to it compile, and (M2) there was no template update note. Both are fixed in 53cf2ca. Round 2 found no high or medium finding. Its two low wording findings are fixed in fde02c9. One low finding stays open: RS0030 does not see dynamic or reflection calls. Normal code does not use them, and no analyzer of this repo checks them. |
|
PASS+NOTES at head e360648 (base main 3b7a3c7). Independent verification in a detached worktree. I did not change the branch. The build rule, as a developer meets it. I added a scratch file under (5 Build and tests at e360648 (local, because CI has no minutes):
The upload path in the running app. I used
Notes (no blocker):
|
Why
Agents keep writing an object to storage around
AttachmentStorage, so an object outlives its row or loses its row to the sweep (#413, #422, #519). The sweep keeps an object forAttachments:AddTimeoutplus a margin, and onlyAttachmentStorage.AddAsyncsaves the row within that time. Before this change, nothing stopped a put on another path.Closes #536
What changed
ObjectWriternow has the put.ObjectStorage.PutAsyncis gone.BannedSymbols.txtbansObjectWriterand theAmazon.S3namespace in the Server (RS0030). Each error namesAttachmentStorage.AddAsync.AttachmentStorage.AddAsync, each S3 member ofObjectStorage,ObjectWriter, andObjectStorageRegistration.AddObjectStorage.BannedApiSuppressionTestspins their files.docs/backend.md,attachments.md, and a new update note intemplate-updates.mdnow state the rule. The text "Put other files under another prefix" is gone, because the build now refuses that put.Tradeoffs
internalopens the put to the whole Server assembly. A separate project would also have to holdAttachmentStorage, which needsAppDbContext.AttachmentStoragecan call cannot be written. The outer class cannot call the private constructor of a nested type, and each factory that it can call is open to the whole assembly.ObjectWritertype and not on theM:ID of the method, because anM:ID stops matching, with no warning, when the signature changes. The wholeAmazon.S3namespace is banned, soTransferUtility,CopyObjectAsync, multipart uploads, and a presigned PUT also fail.dynamicor reflection. It also does not flag a parameter or a DI type argument, but a put has to call a member, and each such call fails.Blast Radius
The behavior does not change: the put is the same S3 call with the same token. An app built from the template fails to build at each put of its own outside
AddAsync. The update note gives the steps.Verification
Scratch handler, now removed: a bulk import that puts under
tenants/and saves its rows later.s3.PutObjectAsync,new TransferUtility(s3), a second put method inAttachmentStorage, and aPutAsyncput back onObjectStoragealso fail with RS0030. Thedotnet build FullstackTemplate.slnxrun passes with 0 warnings. Unit tests: 2449/2449 pass. Integration: 590/590 pass. Functional: 507/507 pass. All 8 configs of theobject-storage-lifecycleTLC check are at baseline. CI did not run because the Actions minutes are used up. The full proof output is in a PR comment.