Skip to content

Commit 5773286

Browse files
titanouschris-ramon
authored andcommitted
Check for invalid NonNull in isValidLiteralValue
Nil panic found with go-fuzz. Signed-off-by: Jonathan Rudenberg <[email protected]>
1 parent d114382 commit 5773286

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

rules.go

+3
Original file line numberDiff line numberDiff line change
@@ -1717,6 +1717,9 @@ func VariablesInAllowedPositionRule(context *ValidationContext) *ValidationRuleI
17171717
func isValidLiteralValue(ttype Input, valueAST ast.Value) (bool, []string) {
17181718
// A value must be provided if the type is non-null.
17191719
if ttype, ok := ttype.(*NonNull); ok {
1720+
if e := ttype.Error(); e != nil {
1721+
return false, []string{e.Error()}
1722+
}
17201723
if valueAST == nil {
17211724
if ttype.OfType.Name() != "" {
17221725
return false, []string{fmt.Sprintf(`Expected "%v!", found null.`, ttype.OfType.Name())}

rules_default_values_of_correct_type_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,7 @@ func TestValidate_VariableDefaultValuesOfCorrectType_ListVariablesWithInvalidIte
101101
2, 40),
102102
})
103103
}
104+
105+
func TestValidate_VariableDefaultValuesOfCorrectType_InvalidNonNull(t *testing.T) {
106+
testutil.ExpectPassesRule(t, graphql.DefaultValuesOfCorrectTypeRule, `query($g:e!){a}`)
107+
}

0 commit comments

Comments
 (0)