Coverage for /pythoncovmergedfiles/medio/medio/src/selkies/tests/fuzz/fuzz_rtp.py: 30%
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
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
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 RTP and RTCP parsing, which the DTLS transport runs on every
17decrypted media packet a peer sends."""
18import struct
19import sys
21import atheris
23with atheris.instrument_imports():
24 from selkies.webrtc.rtp import HeaderExtensionsMap, RtcpPacket, RtpPacket
25 from selkies.webrtc.rtcrtpparameters import RTCRtpHeaderExtensionParameters, RTCRtpParameters
27EXTENSIONS = HeaderExtensionsMap()
28EXTENSIONS.configure(
29 RTCRtpParameters(
30 headerExtensions=[
31 RTCRtpHeaderExtensionParameters(id=1, uri="urn:ietf:params:rtp-hdrext:sdes:mid"),
32 RTCRtpHeaderExtensionParameters(id=2, uri="http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time"),
33 RTCRtpHeaderExtensionParameters(id=3, uri="urn:ietf:params:rtp-hdrext:toffset"),
34 RTCRtpHeaderExtensionParameters(
35 id=4, uri="http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01"
36 ),
37 ]
38 )
39)
42def TestOneInput(data):
43 try:
44 if data[:1] == b"\x01":
45 RtcpPacket.parse(data[1:])
46 else:
47 RtpPacket.parse(data[1:], EXTENSIONS)
48 except (ValueError, struct.error):
49 pass
52def main():
53 atheris.Setup(sys.argv, TestOneInput)
54 atheris.Fuzz()
57if __name__ == "__main__":
58 main()