Coverage for /pythoncovmergedfiles/medio/medio/src/fuzz_helper.py: 63%

41 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-06-07 07:16 +0000

1###### Coverage stub 

2import atexit 

3import coverage 

4cov = coverage.coverage(data_file='.coverage', cover_pylib=True) 

5cov.start() 

6# Register an exist handler that will print coverage 

7def exit_handler(): 

8 cov.stop() 

9 cov.save() 

10atexit.register(exit_handler) 

11####### End of coverage stub 

12#!/usr/bin/python3 

13# Copyright 2022 Google LLC 

14# 

15# Licensed under the Apache License, Version 2.0 (the "License"); 

16# you may not use this file except in compliance with the License. 

17# You may obtain a copy of the License at 

18# 

19# http://www.apache.org/licenses/LICENSE-2.0 

20# 

21# Unless required by applicable law or agreed to in writing, software 

22# distributed under the License is distributed on an "AS IS" BASIS, 

23# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 

24# See the License for the specific language governing permissions and 

25# limitations under the License. 

26 

27import atheris 

28import sys 

29with atheris.instrument_imports(): 

30 from redis.commands.helpers import * 

31 

32def TestInput(data): 

33 fdp = atheris.FuzzedDataProvider(data) 

34 

35 temp_list = [ 

36 fdp.ConsumeString(10), 

37 fdp.ConsumeUnicode(10), 

38 fdp.ConsumeBytes(10) 

39 ] 

40 

41 temp_dict_list = [ 

42 [fdp.ConsumeString(10),fdp.ConsumeUnicode(10)], 

43 [fdp.ConsumeString(10),fdp.ConsumeBytes(10)], 

44 [ 

45 fdp.ConsumeString(10), 

46 [ 

47 fdp.ConsumeString(10), 

48 fdp.ConsumeUnicode(10), 

49 fdp.ConsumeString(10), 

50 fdp.ConsumeBytes(10), 

51 fdp.ConsumeString(10), 

52 [ 

53 fdp.ConsumeString(10),fdp.ConsumeInt(8), 

54 fdp.ConsumeString(10),fdp.ConsumeFloat() 

55 ], 

56 [fdp.ConsumeString(10),fdp.ConsumeBool()] 

57 ] 

58 ] 

59 ] 

60 

61 temp_list = list_or_args(fdp.ConsumeString(10),temp_list) 

62 temp_list = list_or_args(fdp.ConsumeUnicode(10),temp_list) 

63 temp_list = list_or_args(fdp.ConsumeBytes(10),temp_list) 

64 temp_list = list_or_args([fdp.ConsumeString(10)],temp_list) 

65 temp_list = list_or_args([fdp.ConsumeUnicode(10)],temp_list) 

66 temp_list = list_or_args([fdp.ConsumeBytes(10)],temp_list) 

67 

68 delist(temp_list) 

69 parse_to_list(temp_list) 

70 

71 temp_dict = parse_to_dict(temp_dict_list) 

72 decode_dict_keys(temp_dict) 

73 

74 nativestr(fdp.ConsumeString(10)) 

75 nativestr(fdp.ConsumeUnicode(10)) 

76 nativestr(fdp.ConsumeBytes(10)) 

77 random_string(fdp.ConsumeInt(8)) 

78 quote_string(fdp.ConsumeString(20)) 

79 stringify_param_value(fdp.ConsumeString(10)) 

80 stringify_param_value(fdp.ConsumeUnicode(10)) 

81 stringify_param_value(fdp.ConsumeBytes(10)) 

82 stringify_param_value(temp_list) 

83 stringify_param_value(temp_dict) 

84 

85def main(): 

86 atheris.Setup(sys.argv, TestInput, enable_python_coverage=True) 

87 atheris.Fuzz() 

88 

89if __name__ == "__main__": 

90 main()