Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions lib/query-plan-executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -874,12 +874,6 @@ impl QueryPlanExecutionContext<'_> {
entity: &Value,
buffer: &mut String,
) {
if requires_selections.is_empty() {
// No selections, so serialize the entity directly into the buffer.
write!(buffer, "{}", serde_json::to_string(entity).unwrap()).unwrap();
return;
}

match entity {
Value::Null => buffer.push_str("null"),
Value::Bool(b) => write!(buffer, "{}", b).unwrap(),
Expand All @@ -898,6 +892,11 @@ impl QueryPlanExecutionContext<'_> {
buffer.push(']');
}
Value::Object(entity_obj) => {
if requires_selections.is_empty() {
// It is probably a scalar with an object value, so we write it directly
write!(buffer, "{}", serde_json::to_string(entity_obj).unwrap()).unwrap();
return;
Comment on lines +895 to +898
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

If requires_selections is empty, the code serializes the entire entity_obj using serde_json::to_string. This might not be the desired behavior if only specific fields are intended to be serialized. Consider whether this serialization should be conditional based on the type of object or the context in which it's being used. This could lead to unexpected data exposure if the object contains sensitive information that should not be serialized in certain cases.

Suggested change
if requires_selections.is_empty() {
// It is probably a scalar with an object value, so we write it directly
write!(buffer, "{}", serde_json::to_string(entity_obj).unwrap()).unwrap();
return;
if requires_selections.is_empty() {
// It is probably a scalar with an object value, so we write it directly
// TODO: Verify if this serialization is safe and doesn't expose sensitive data.
write!(buffer, "{}", serde_json::to_string(entity_obj).unwrap()).unwrap();
return;
}

}
buffer.push('{');
let mut first = true;
self.project_requires_map_mut(requires_selections, entity_obj, buffer, &mut first);
Expand Down
Loading