Skip to content

Commit eda78c9

Browse files
arbitrary: Limit the length of JSON strings.
The JSON strategy was generating strings that might grown unbounded. Limit the length of the strings to 100 characters. Change-Id: I582dd47db0aeba3ce5ccc9196fb52c5f67f82842 Reviewed-on: https://gerrit.readyset.name/c/readyset/+/9744 Tested-by: Buildkite CI Reviewed-by: Michael Zink <michael.z@readyset.io>
1 parent 5014c8c commit eda78c9

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

readyset-util/src/arbitrary.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ pub fn arbitrary_json_without_f64() -> impl Strategy<Value = serde_json::Value>
237237
Just(serde_json::Value::Null),
238238
any::<bool>().prop_map(serde_json::Value::from),
239239
any::<i64>().prop_map(serde_json::Value::from),
240-
"[^\u{0}]*".prop_map(serde_json::Value::from),
240+
"[^\u{0}]{0,100}".prop_map(serde_json::Value::from),
241241
];
242242
leaf.prop_recursive(
243243
3, // 8 levels deep
@@ -247,7 +247,7 @@ pub fn arbitrary_json_without_f64() -> impl Strategy<Value = serde_json::Value>
247247
prop_oneof![
248248
// Take the inner strategy and make the two recursive cases.
249249
prop::collection::vec(inner.clone(), 0..10).prop_map(serde_json::Value::from),
250-
prop::collection::hash_map("[^\u{0}]*", inner, 0..10).prop_map(|h| {
250+
prop::collection::hash_map("[^\u{0}]{0,100}", inner, 0..10).prop_map(|h| {
251251
serde_json::Value::from(serde_json::Map::from_iter(
252252
h.iter().map(|(s, v)| (s.clone(), v.clone())),
253253
))
@@ -264,7 +264,7 @@ pub fn arbitrary_json() -> impl Strategy<Value = serde_json::Value> {
264264
any::<bool>().prop_map(serde_json::Value::from),
265265
any::<i64>().prop_map(serde_json::Value::from),
266266
any::<f64>().prop_map(serde_json::Value::from),
267-
"[^\u{0}]*".prop_map(serde_json::Value::from),
267+
"[^\u{0}]{0,100}".prop_map(serde_json::Value::from),
268268
];
269269
leaf.prop_recursive(
270270
3, // 8 levels deep
@@ -274,7 +274,7 @@ pub fn arbitrary_json() -> impl Strategy<Value = serde_json::Value> {
274274
prop_oneof![
275275
// Take the inner strategy and make the two recursive cases.
276276
prop::collection::vec(inner.clone(), 0..10).prop_map(serde_json::Value::from),
277-
prop::collection::hash_map("[^\u{0}]*", inner, 0..10).prop_map(|h| {
277+
prop::collection::hash_map("[^\u{0}]{0,100}", inner, 0..10).prop_map(|h| {
278278
serde_json::Value::from(serde_json::Map::from_iter(
279279
h.iter().map(|(s, v)| (s.clone(), v.clone())),
280280
))

0 commit comments

Comments
 (0)