Repository navigation
Make FetchSBOM and FetchVEX stream single files in chunks - #33
henrymitchellhibbert-lab wants to merge 1 commit into
Conversation
4089c1b to
f299563
Compare
f299563 to
fd8d3ae
Compare
|
I think we should set both limits on the chunk size and also a recommended chunk size:
|
| // A VexArtifact represents a VEX document. | ||
| message VexArtifact { | ||
| // Metadata describing a streamed VEX document. | ||
| message VexArtifactMetadata { |
There was a problem hiding this comment.
What do you think about adding a new field here called size_bytes.
This would let the server tell the client immediately how many bytes to expect in the chunks. If something goes wrong and there's an unexpectedly large (or small) payload, this would catch that . It may also help performance because the client can pre-allocate the memory needed for the document.
| // A VexArtifact represents a VEX document. | ||
| message VexArtifact { | ||
| // Metadata describing a streamed VEX document. | ||
| message VexArtifactMetadata { |
There was a problem hiding this comment.
Altough the payload itself is going to be signed (JWS/JSF), parsing that requires putting it through the entire JSON parser. We could get a very cheap verification immediately after the chunks are downloaded by including a sha256 digest (or similar) in this metadata. The client then just does a very quick hash and only proceeds to the JSON parsing if that succeeds.
FetchSBOM and FetchVEX were intended to stream large artifacts in chunks, but were not configured correctly to achieve that. Instead they streamed multiple files at a time, but each file was transmitted whole.
This change rewrites these RPCs to each stream one artifact at a time, but the individual artifacts are broken into chunks of bytes.
In response to a request, the server sends the metadata of the file (its identifier and the format of the document) and then streams the file contents in chunks of bytes until the whole file is transmitted.
The server could then look something like this: