-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add custom threshold support for Nebula #115
Conversation
26ae9ca
to
d4b46eb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. So the idea here is to group submissions by their threshold value (stated or implicit) and decode and aggregate them separately, so the db will have separate entries for each threshold class and we can join them in the analysis dashboard queries?
let record: FutureRecord<str, [u8]> = FutureRecord::to(&self.topic).payload(record); | ||
let mut record: FutureRecord<str, [u8]> = FutureRecord::to(&self.topic).payload(record); | ||
if let Some(threshold) = request_threshold { | ||
let threshold = (threshold as u32).to_le_bytes(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know anything about kafka, but it looks like this field really is just 'bytes' and it's custom serialization up to the application even for a base type like this. Is that right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct, rust-rdkafka requires a &[u8]
for header values, so we're responsible for serialization.
if !state.request_threshold_range.contains(&threshold) { | ||
return Err(WebError::BadThreshold); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, the server only accepts threshold values within whatever range we set (between 20 and 50 by default) so there's a bound to how many queues it will build. Excellent.
yes. pending messages (messages stored in PG from previous aggregation attempts) and new messages (messages that were just received via Kafka during the current iteration) will be grouped by tag, and then by threshold. New pending messages will be stored by tag and threshold. However, recovered messages (which include the key, metric name and metric value) will continue to be grouped by tag. If there are multiple threshold values for a given tag (i.e. if we switched the Nebula k-threshold at some point), we're covered. It turns out that the key for a given tag remains the same, regardless of the multiple threshold values in the wild. |
let msgs = if recovery_threshold == Some(threshold) && key_recovery_msgs.is_some() { | ||
// messages for this threshold were already drained in the key | ||
// recovery step, so use this existing vec | ||
key_recovery_msgs.take().unwrap() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reported by reviewdog 🐶
[semgrep] expect
or unwrap
called in function returning a Result
Source: https://semgrep.dev/r/trailofbits.rs.panic-in-function-returning-result.panic-in-function-returning-result
Cc @thypon @bcaller
@@ -112,22 +198,15 @@ | |||
id: 0, | |||
msg_tag: msg_tag.clone(), | |||
epoch_tag: *epoch as i16, | |||
metric_name: measurement.0, | |||
metric_value: measurement.1, | |||
metric_name: metric_name.unwrap(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reported by reviewdog 🐶
[semgrep] expect
or unwrap
called in function returning a Result
Source: https://semgrep.dev/r/trailofbits.rs.panic-in-function-returning-result.panic-in-function-returning-result
Cc @thypon @bcaller
metric_name: measurement.0, | ||
metric_value: measurement.1, | ||
metric_name: metric_name.unwrap(), | ||
metric_value: metric_value.unwrap(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reported by reviewdog 🐶
[semgrep] expect
or unwrap
called in function returning a Result
Source: https://semgrep.dev/r/trailofbits.rs.panic-in-function-returning-result.panic-in-function-returning-result
Cc @thypon @bcaller
let key = if let Some(rec_msg) = existing_rec_msg { | ||
rec_msg.key.clone() | ||
} else { | ||
let threshold = recovery_threshold.unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reported by reviewdog 🐶
[semgrep] expect
or unwrap
called in function returning a Result
Source: https://semgrep.dev/r/trailofbits.rs.panic-in-function-returning-result.panic-in-function-returning-result
Cc @thypon @bcaller
AppSTARError::Recovery(ConstellationError::ShareRecovery) => { | ||
// Store new messages until we receive more shares in the future. | ||
for msg in msgs.drain(..new_msg_count) { | ||
chunk.new_msgs.get_mut(&threshold).unwrap().push(msg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reported by reviewdog 🐶
[semgrep] expect
or unwrap
called in function returning a Result
Source: https://semgrep.dev/r/trailofbits.rs.panic-in-function-returning-result.panic-in-function-returning-result
Cc @thypon @bcaller
i see this adds new dependencies; is there something in the pre-merge pipeline which runs |
Is the modified code part of a command or a server? @DJAndries |
modifications are mostly for the server + server-side aggregator. some changes were made to the test client as well |
I filed #133 to address this. An unmaintained warning about the rusoto crates is the only thing reported after running |
6878772
to
e81c32d
Compare
…surements from csv using test client in one command
0ff661f
to
4653dd8
Compare
[puLL-Merge] - brave/constellation-processors@115 DescriptionThis PR makes changes to support custom k-threshold values in requests to the encrypted message submission endpoint. The k-threshold value is passed in a request header, and if present, overrides the default threshold. Pending messages are now stored in the database with the threshold value. Message grouping and key recovery is done separately for each threshold group. ChangesChanges
Security Hotspots
|
No description provided.