Forbid changing aggregation job parameters#758
Merged
Conversation
cjpatton
reviewed
Jan 9, 2025
Contributor
cjpatton
left a comment
There was a problem hiding this comment.
Looks pretty good, just one blocking comment: Is it feasible to hash the AggregationJobInitReq before decoding?
crates/daphne-service-utils/src/durable_requests/bindings/aggregation_job_store.rs
Outdated
Show resolved
Hide resolved
crates/daphne-service-utils/src/durable_requests/bindings/aggregation_job_store.rs
Show resolved
Hide resolved
cjpatton
reviewed
Jan 9, 2025
crates/daphne-service-utils/src/durable_requests/bindings/aggregation_job_store.rs
Outdated
Show resolved
Hide resolved
cd3effe to
895900a
Compare
895900a to
0447fd6
Compare
cjpatton
approved these changes
Jan 9, 2025
Contributor
cjpatton
left a comment
There was a problem hiding this comment.
Other than the decode-then-hash issue, I think this is good to go. I have one more suggestion there.
crates/daphne-service-utils/src/durable_requests/bindings/aggregation_job_store.rs
Outdated
Show resolved
Hide resolved
cjpatton
reviewed
Jan 9, 2025
Comment on lines
+63
to
+72
| impl DecodeFromDapHttpBody for HashedAggregationJobReq { | ||
| fn decode_from_http_body(bytes: Bytes, meta: &DapRequestMeta) -> Result<Self, DapAbort> { | ||
| let mut cursor = Cursor::new(bytes.as_ref()); | ||
| // Check that media type matches. | ||
| meta.get_checked_media_type(DapMediaType::AggregationJobInitReq)?; | ||
| // Decode the body | ||
| HashedAggregationJobReq::decode_with_param(&meta.version, &mut cursor) | ||
| .map_err(|e| DapAbort::from_codec_error(e, meta.task_id)) | ||
| } | ||
| } |
Contributor
There was a problem hiding this comment.
Hashing with HashedAggregationJobReq::decode_with_param() is a little awkward because you have to keep track of the start and end of the message in the cursor. Also, and this is very nit picky: HashedAggregationJobReq is not a DAP protocol message, so arguably doesn't belong in the messages module.
I think I would have done this differently:
impl DecodeFromDapHttpBody for HashedAggregationJobReq {
fn decode_from_http_body(bytes: Bytes, meta: &DapRequestMeta) -> Result<Self, DapAbort> {
// Check that media type matches.
meta.get_checked_media_type(DapMediaType::AggregationJobInitReq)?;
// Decode the body
let agg_job_req = AggregationJobReq::get_decoded_with_param(&meta.version, bytes.as_ref())
.map_err(|e| DapAbort::from_codec_error(e, meta.task_id))?;
Ok(Self{
agg_job_req:
hash: sha256(bytes.as_ref()),
})
}
}Note that this also enforces that there is nothing left to read in bytes.
d65f840 to
6e576ff
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is important for implementing the async draft later