diff options
Diffstat (limited to 'pathod/language')
-rw-r--r-- | pathod/language/actions.py | 6 | ||||
-rw-r--r-- | pathod/language/base.py | 15 | ||||
-rw-r--r-- | pathod/language/http.py | 4 | ||||
-rw-r--r-- | pathod/language/http2.py | 6 | ||||
-rw-r--r-- | pathod/language/message.py | 3 | ||||
-rw-r--r-- | pathod/language/websockets.py | 14 |
6 files changed, 27 insertions, 21 deletions
diff --git a/pathod/language/actions.py b/pathod/language/actions.py index e85affac..fc57a18b 100644 --- a/pathod/language/actions.py +++ b/pathod/language/actions.py @@ -2,9 +2,7 @@ import abc import copy import random from functools import total_ordering - import pyparsing as pp - from . import base @@ -52,7 +50,7 @@ class _Action(base.Token): class PauseAt(_Action): - unique_name = None + unique_name = None # type: ignore def __init__(self, offset, seconds): _Action.__init__(self, offset) @@ -103,7 +101,7 @@ class DisconnectAt(_Action): class InjectAt(_Action): - unique_name = None + unique_name = None # type: ignore def __init__(self, offset, value): _Action.__init__(self, offset) diff --git a/pathod/language/base.py b/pathod/language/base.py index 3a810ef0..c8892748 100644 --- a/pathod/language/base.py +++ b/pathod/language/base.py @@ -3,10 +3,9 @@ import os import abc import functools import pyparsing as pp - from mitmproxy.utils import strutils from mitmproxy.utils import human - +import typing # noqa from . import generators, exceptions @@ -84,7 +83,7 @@ class Token: return None @property - def unique_name(self): + def unique_name(self) -> typing.Optional[str]: """ Controls uniqueness constraints for tokens. No two tokens with the same name will be allowed. If no uniquness should be applied, this @@ -334,7 +333,7 @@ class OptionsOrValue(_Component): Can be any of a specified set of options, or a value specifier. """ preamble = "" - options = [] + options = [] # type: typing.List[str] def __init__(self, value): # If it's a string, we were passed one of the options, so we lower-case @@ -376,7 +375,7 @@ class OptionsOrValue(_Component): class Integer(_Component): - bounds = (None, None) + bounds = (None, None) # type: typing.Tuple[typing.Union[int, None], typing.Union[int , None]] preamble = "" def __init__(self, value): @@ -442,7 +441,7 @@ class FixedLengthValue(Value): A value component lead by an optional preamble. """ preamble = "" - length = None + length = None # type: typing.Optional[int] def __init__(self, value): Value.__init__(self, value) @@ -511,7 +510,7 @@ class IntField(_Component): """ An integer field, where values can optionally specified by name. """ - names = {} + names = {} # type: typing.Dict[str, int] max = 16 preamble = "" @@ -546,7 +545,7 @@ class NestedMessage(Token): A nested message, as an escaped string with a preamble. """ preamble = "" - nest_type = None + nest_type = None # type: ignore def __init__(self, value): Token.__init__(self) diff --git a/pathod/language/http.py b/pathod/language/http.py index 8fcf9edc..5cd717a9 100644 --- a/pathod/language/http.py +++ b/pathod/language/http.py @@ -54,7 +54,7 @@ class Method(base.OptionsOrValue): class _HeaderMixin: - unique_name = None + unique_name = None # type: ignore def format_header(self, key, value): return [key, b": ", value, b"\r\n"] @@ -143,7 +143,7 @@ class _HTTPMessage(message.Message): class Response(_HTTPMessage): - unique_name = None + unique_name = None # type: ignore comps = ( Header, ShortcutContentType, diff --git a/pathod/language/http2.py b/pathod/language/http2.py index 08c5f6d7..47d6e370 100644 --- a/pathod/language/http2.py +++ b/pathod/language/http2.py @@ -1,9 +1,9 @@ import pyparsing as pp - from mitmproxy.net import http from mitmproxy.net.http import user_agents, Headers from . import base, message + """ Normal HTTP requests: <method>:<path>:<header>:<body> @@ -41,7 +41,7 @@ def get_header(val, headers): class _HeaderMixin: - unique_name = None + unique_name = None # type: ignore def values(self, settings): return ( @@ -146,7 +146,7 @@ class Times(base.Integer): class Response(_HTTP2Message): - unique_name = None + unique_name = None # type: ignore comps = ( Header, Body, diff --git a/pathod/language/message.py b/pathod/language/message.py index 6cdaaa0b..6b4c5021 100644 --- a/pathod/language/message.py +++ b/pathod/language/message.py @@ -1,13 +1,14 @@ import abc from . import actions, exceptions from mitmproxy.utils import strutils +import typing # noqa LOG_TRUNCATE = 1024 class Message: __metaclass__ = abc.ABCMeta - logattrs = [] + logattrs = [] # type: typing.List[str] def __init__(self, tokens): track = set([]) diff --git a/pathod/language/websockets.py b/pathod/language/websockets.py index a237381c..b4faf59b 100644 --- a/pathod/language/websockets.py +++ b/pathod/language/websockets.py @@ -4,6 +4,7 @@ import mitmproxy.net.websockets from mitmproxy.utils import strutils import pyparsing as pp from . import base, generators, actions, message +import typing # noqa NESTED_LEADER = b"pathod!" @@ -20,7 +21,7 @@ class OpCode(base.IntField): "close": mitmproxy.net.websockets.OPCODE.CLOSE, "ping": mitmproxy.net.websockets.OPCODE.PING, "pong": mitmproxy.net.websockets.OPCODE.PONG, - } + } # type: typing.Dict[str, int] max = 15 preamble = "c" @@ -239,7 +240,14 @@ class NestedFrame(base.NestedMessage): nest_type = WebsocketFrame +COMP = typing.Tuple[ + typing.Type[OpCode], typing.Type[Length], typing.Type[Fin], typing.Type[RSV1], typing.Type[RSV2], typing.Type[RSV3], typing.Type[Mask], + typing.Type[actions.PauseAt], typing.Type[actions.DisconnectAt], typing.Type[actions.InjectAt], typing.Type[KeyNone], typing.Type[Key], + typing.Type[Times], typing.Type[Body], typing.Type[RawBody] +] + + class WebsocketClientFrame(WebsocketFrame): - components = COMPONENTS + ( + components = typing.cast(COMP, COMPONENTS + ( NestedFrame, - ) + )) |