Skip to content
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

Don't log sensitive user info in GLIDE code #1443

Merged
merged 3 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 3 additions & 5 deletions glide-core/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,9 @@ fn parse_timeout_to_f64(cmd: &Cmd, timeout_idx: usize) -> RedisResult<f64> {
ErrorKind::ResponseError,
err_msg,
format!(
"Expected to find timeout value at index {:?} for command {:?}. Recieved command = {:?}",
"Expected to find timeout value at index {:?} for command {:?}.",
timeout_idx,
std::str::from_utf8(&cmd.command().unwrap_or_default()),
cmd
),
))
};
Expand Down Expand Up @@ -166,7 +165,7 @@ fn get_timeout_from_cmd_arg(
Err(RedisError::from((
ErrorKind::ResponseError,
"Timeout cannot be negative",
format!("Recieved timeout={:?}", timeout_secs),
format!("Received timeout = {:?}", timeout_secs),
)))
} else if timeout_secs == 0.0 {
// `0` means we should set no timeout
Expand All @@ -177,7 +176,7 @@ fn get_timeout_from_cmd_arg(
Err(RedisError::from((
ErrorKind::ResponseError,
"Timeout is out of range, max timeout is 2^32 - 1 (u32::MAX)",
format!("Recieved timeout={:?}", timeout_secs),
format!("Received timeout = {:?}", timeout_secs),
)))
} else {
// Extend the request timeout to ensure we don't timeout before receiving a response from the server.
Expand Down Expand Up @@ -262,7 +261,6 @@ impl Client {
return Err((
ErrorKind::ResponseError,
"Received non-array response for transaction",
format!("Response: `{value:?}`"),
)
.into());
}
Expand Down
24 changes: 4 additions & 20 deletions glide-core/src/client/value_conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,12 @@ pub(crate) fn convert_to_expected_type(
_ => Err((
ErrorKind::TypeError,
"Response couldn't be converted to map",
format!("(response was {:?})", value),
)
.into()),
},
ExpectedReturnType::MapOfStringToDouble => match value {
Value::Nil => Ok(value),
Value::Map(map) => {
let map_clone = map.clone();
let result = map
.into_iter()
.map(|(key, inner_value)| {
Expand All @@ -66,7 +64,6 @@ pub(crate) fn convert_to_expected_type(
_ => Err((
ErrorKind::TypeError,
"Response couldn't be converted to map of {string: double}",
format!("(response was {:?})", map_clone),
)
.into()),
}
Expand All @@ -83,7 +80,6 @@ pub(crate) fn convert_to_expected_type(
_ => Err((
ErrorKind::TypeError,
"Response couldn't be converted to map of {string: double}",
format!("(response was {:?})", value),
)
.into()),
},
Expand All @@ -94,7 +90,6 @@ pub(crate) fn convert_to_expected_type(
_ => Err((
ErrorKind::TypeError,
"Response couldn't be converted to set",
format!("(response was {:?})", value),
)
.into()),
},
Expand Down Expand Up @@ -123,7 +118,6 @@ pub(crate) fn convert_to_expected_type(
_ => Err((
ErrorKind::TypeError,
"Response couldn't be converted to Array (ZRankResponseType)",
format!("(response was {:?})", value),
)
.into()),
},
Expand All @@ -138,12 +132,10 @@ pub(crate) fn convert_to_expected_type(
Value::Nil => Ok(Value::Nil),
_ => match from_owned_redis_value::<bool>(item.clone()) {
Ok(boolean_value) => Ok(Value::Boolean(boolean_value)),
_ => Err((
ErrorKind::TypeError,
"Could not convert value to boolean",
format!("(value was {:?})", item),
)
.into()),
_ => {
Err((ErrorKind::TypeError, "Could not convert value to boolean")
Copy link
Contributor

Choose a reason for hiding this comment

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

add type

Copy link
Contributor

Choose a reason for hiding this comment

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

also, why is this (and below) a boolean and not JSON toggle?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

JSON.TOGGLE returns 0/1 being converted to bool or nil.
Not a mistake I suppose.

.into())
}
},
})
.collect();
Expand All @@ -156,14 +148,12 @@ pub(crate) fn convert_to_expected_type(
_ => Err((
ErrorKind::TypeError,
"Response couldn't be converted to boolean",
format!("(response was {:?})", bytes),
)
.into()),
},
_ => Err((
ErrorKind::TypeError,
"Response couldn't be converted to Json Toggle return type",
format!("(response was {:?})", value),
)
.into()),
},
Expand All @@ -172,7 +162,6 @@ pub(crate) fn convert_to_expected_type(
_ => Err((
ErrorKind::TypeError,
"Response couldn't be converted to an array of boolean",
format!("(response was {:?})", value),
)
.into()),
},
Expand All @@ -181,7 +170,6 @@ pub(crate) fn convert_to_expected_type(
_ => Err((
ErrorKind::TypeError,
"Response couldn't be converted to an array of doubles",
format!("(response was {:?})", value),
)
.into()),
},
Expand Down Expand Up @@ -213,7 +201,6 @@ pub(crate) fn convert_to_expected_type(
_ => Err((
ErrorKind::TypeError,
"Response couldn't be converted to ZMPOP return type",
format!("(response was {:?})", value),
)
.into()),
},
Expand Down Expand Up @@ -247,7 +234,6 @@ pub(crate) fn convert_to_expected_type(
_ => Err((
ErrorKind::TypeError,
"Response couldn't be converted to an array of array of double or null. Inner value of Array must be Array or Null",
format!("(Inner value was {:?})", item),
)
.into()),
})
Expand All @@ -258,7 +244,6 @@ pub(crate) fn convert_to_expected_type(
_ => Err((
ErrorKind::TypeError,
"Response couldn't be converted to an array of array of double or null",
format!("(response was {:?})", value),
)
.into()),
},
Expand Down Expand Up @@ -342,7 +327,6 @@ pub(crate) fn convert_to_expected_type(
_ => Err((
ErrorKind::TypeError,
"Response couldn't be converted to an array containing a key, member, and score",
format!("(response was {:?})", value),
)
.into()),
},
Expand Down
Loading