Coverage for graphqler / fuzzer / engine / detectors / field_suggestion / field_suggestion_detector.py: 100%

21 statements  

« prev     ^ index     » next       coverage.py v7.13.4, created at 2026-03-20 10:09 -0400

1from typing import Type 

2 

3import requests 

4 

5from .field_suggestion_materializer import FieldSuggestionMaterializer 

6from ..detector import Detector 

7 

8 

9class FieldSuggestionsDetector(Detector): 

10 """Field Suggestions Detector 

11 """ 

12 @property 

13 def DETECTION_NAME(self) -> str: 

14 return "Field Suggestions Enabled" 

15 

16 @property 

17 def detect_only_once_for_api(self) -> bool: 

18 return True 

19 

20 @property 

21 def detect_only_once_for_node(self) -> bool: 

22 return True 

23 

24 @property 

25 def materializer(self) -> Type[FieldSuggestionMaterializer]: 

26 return FieldSuggestionMaterializer 

27 

28 def _is_vulnerable(self, graphql_response: dict, request_response: requests.Response) -> bool: 

29 return ("did you mean" in str(graphql_response['errors'][0]['message']).lower() 

30 or "did you mean" in request_response.text.lower()) 

31 

32 def _is_potentially_vulnerable(self, graphql_response: dict, request_response: requests.Response) -> bool: 

33 return self._is_vulnerable(graphql_response, request_response)