Conversation
Why not use something like Cargo publish protocol?
What about license? Should require it to be an SPDX expression. (EDIT: Agree! RESOLVED) |
Alaternatively, why not be even simpler: pass the PURL in some header (e.g. EDIT by Erik: Discussed a bit further in #249 (comment) and #249 (comment), we now have |
Signed-off-by: Erik Sundell <erik.sundell+2025@sensmetry.com>
Signed-off-by: Erik Sundell <erik.sundell+2025@sensmetry.com>
Signed-off-by: Erik Sundell <erik.sundell+2025@sensmetry.com>
Signed-off-by: Erik Sundell <erik.sundell+2025@sensmetry.com>
|
Looked through everything. One question/suggestion still not addressed:
|
Signed-off-by: Erik Sundell <erik.sundell+2025@sensmetry.com>
They must match with the content. The idea of having the purl field was to do an authorization check before reading the .kpar archive, as it may be a bit more expensive operation, thinking about DoS protection etc. With a purl field its clear we mean the normalized parts, do you want name and publisher to be normalized or not? We could also just remove the purl field and go with it, because we won't process the request until the .kpar is received anyhow etc, so I think my DoS thinking wasn't very relevant. Decision options:
I think I lean towards 1 if something, but more than anything I lean towards momentum so I'm fine with quickly adjusting to any decision EDIT: I've pushed a commit implementing option 1, can switch to another decision still just wanted to avoid being idle. |
Signed-off-by: Erik Sundell <erik.sundell+2025@sensmetry.com>
|
I've checked that this functionality works e2e against developed index server, so I consider it ready, but I can also adjust to a decision in the comment above. |
Is it feasible to process the request before fully receiving it (not now, just asking about whether this would be doable in the future if the need arises)? Even if not, it would still be nice to be able to quickly reject invalid requests (e.g. trying to publish to the wrong publisher/name, or especially publishing to a not-yet-existing/typoed package, which will happen for legitimate users) without unzipping the kpar. This doesn't prevent DoS by malicious users (they can simply include different names in the json than in the package, so we still must check the package), but most invalid requests come from legitimate users. Therefore I lean towards option 3 + version (to quickly detect duplicate publishes to the same version). |
For this to be effective, we also have to require that metadata "field" comes before the file in the request. |
|
@andrius-puksta-sensmetry comment above:
AI responses to misc questions:
It is possible to have the server parse a stream-read a POST request and abort mid-read etc, but this is really sidestepping the conveniences of most webserver software we build upon. If we look for this level of robustness, I think we should go for the even more solid strategy is to not have the index server receive the file at all. You can implement a multi-step flow where you first have the server generate a pre-signed URL for the client where the client can upload directly to object storage, and then the client does it, and communicates back to the server referencing the initial upload request, whereby the server processes it etc. However, we are now in the weeds of optimization beyond even what crates.io, npm, pypi, etc do, and it raises the bar in general on implementing an index. |
|
Yeah, it was just a question about feasibility. I would still prefer option 3 + version to be implemented to catch user errors without having to unzip |
Signed-off-by: Erik Sundell <erik.sundell@sensmetry.com>
Signed-off-by: Erik Sundell <erik.sundell@sensmetry.com>
Summary
This PR introduces a new
sysand publishcommand to upload.kparartifacts to a sysand package index.What’s Included
sysand publish --index <URL> [PATH]where--indexis required[PATH]explicitly, or defaults to the output a build command would default to<index>/api/v1/upload. It has two form fields.metadata(application/json) with:normalized_publishernormalized_nameversionlicensekpar_sha256_digestkparwith the .kpar data blob (application/zip)publisher/namemust be normalizable based on strict rulesversionmust be valid SemVer 2.0licensemust be valid SPDX expressionnameare preserved)http/https/api/v1/upload401/403/404/409)Docs
docs/src/commands/publish.mdsysand publishentry to docs summary navigationTests
Dependency/Config Updates
multipartfeatures forreqwest/reqwest-middlewarewhere needed for upload support