Coverage for /pythoncovmergedfiles/medio/medio/src/selkies/tests/fuzz/fuzz_stun.py: 32%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

25 statements  

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/env python3 

13# This Source Code Form is subject to the terms of the Mozilla Public 

14# License, v. 2.0. If a copy of the MPL was not distributed with this 

15# file, You can obtain one at https://mozilla.org/MPL/2.0/. 

16"""Fuzzes STUN parsing, which the ICE agent and the UDP mux run on every 

17datagram a peer sends, before any authentication.""" 

18import sys 

19 

20import atheris 

21 

22with atheris.instrument_imports(): 

23 from selkies.ice import stun 

24 

25 

26def TestOneInput(data): 

27 # The first byte chooses whether MESSAGE-INTEGRITY is checked, as it is on 

28 # a pair whose password is known. 

29 key = b"fuzz-password" if data[:1] == b"\x01" else None 

30 try: 

31 stun.parse_message(data[1:], integrity_key=key) 

32 except ValueError: 

33 pass 

34 

35 

36def main(): 

37 atheris.Setup(sys.argv, TestOneInput) 

38 atheris.Fuzz() 

39 

40 

41if __name__ == "__main__": 

42 main()