Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Backport CVE-2022-31173 fix from GHSA-4rx6-g5vg-5f3j
Co-authored-by: ilslv <ilya.solovyiov@gmail.com>
- Loading branch information
Showing
10 changed files
with
297 additions
and
102 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| //! Checks that long looping chain of fragments doesn't cause a stack overflow. | ||
| //! | ||
| //! ```graphql | ||
| //! # Fragment loop example | ||
| //! query { | ||
| //! ...a | ||
| //! } | ||
| //! | ||
| //! fragment a on Query { | ||
| //! ...b | ||
| //! } | ||
| //! | ||
| //! fragment b on Query { | ||
| //! ...a | ||
| //! } | ||
| //! ``` | ||
|
|
||
| use std::iter; | ||
|
|
||
| use itertools::Itertools as _; | ||
| use juniper::{graphql_object, EmptyMutation, EmptySubscription, Variables}; | ||
|
|
||
| struct Query; | ||
|
|
||
| #[graphql_object] | ||
| impl Query { | ||
| fn dummy() -> bool { | ||
| false | ||
| } | ||
| } | ||
|
|
||
| type Schema = juniper::RootNode<'static, Query, EmptyMutation, EmptySubscription>; | ||
|
|
||
| #[tokio::test] | ||
| async fn test() { | ||
| const PERM: &str = "abcefghijk"; | ||
| const CIRCLE_SIZE: usize = 7500; | ||
|
|
||
| let query = iter::once(format!("query {{ ...{PERM} }} ")) | ||
| .chain( | ||
| PERM.chars() | ||
| .permutations(PERM.len()) | ||
| .map(|vec| vec.into_iter().collect::<String>()) | ||
| .take(CIRCLE_SIZE) | ||
| .collect::<Vec<_>>() | ||
| .into_iter() | ||
| .circular_tuple_windows::<(_, _)>() | ||
| .map(|(cur, next)| format!("fragment {cur} on Query {{ ...{next} }} ")), | ||
| ) | ||
| .collect::<String>(); | ||
|
|
||
| let schema = Schema::new(Query, EmptyMutation::new(), EmptySubscription::new()); | ||
| let _ = juniper::execute(&query, None, &schema, &Variables::new(), &()) | ||
| .await | ||
| .unwrap_err(); | ||
| } |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.