Skip to content

Commit

Permalink
Merge pull request #365 from doronz88/bugfix/wrap-all-pb2-imports
Browse files Browse the repository at this point in the history
client: wrap more _pb2 imports
  • Loading branch information
doronz88 authored Oct 14, 2024
2 parents 7706b1c + ada2c7c commit ceeafc7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/rpcclient/rpcclient/darwin/processes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import dataclasses
import errno
import logging
import os
import posixpath
import re
import struct
Expand Down Expand Up @@ -30,11 +31,14 @@
from rpcclient.exceptions import ArgumentError, BadReturnValueError, MissingLibraryError, ProcessSymbolAbsentError, \
RpcClientException, SymbolAbsentError, UnrecognizedSelectorError
from rpcclient.processes import Processes
from rpcclient.protos.rpc_pb2 import ARCH_ARM64
from rpcclient.structs.consts import RTLD_NOW, SEEK_SET, SIGKILL, SIGTERM
from rpcclient.symbol import ADDRESS_SIZE_TO_STRUCT_FORMAT, Symbol
from rpcclient.sysctl import CTL, KERN

# make sure imports from the *_pb2 modules don't depend on the locally installed protobuf version
os.environ['PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION'] = 'python'
from rpcclient.protos.rpc_pb2 import ARCH_ARM64 # noqa: E402

_CF_STRING_ARRAY_PREFIX_LEN = len(' "')
_CF_STRING_ARRAY_SUFFIX_LEN = len('",')
_BACKTRACE_FRAME_REGEX = re.compile(r'\[\s*(\d+)\] (0x[0-9a-f]+)\s+\{(.+?) \+ (.+?)\} (.*)')
Expand Down
6 changes: 5 additions & 1 deletion src/rpcclient/rpcclient/protosocket.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import os
import socket
import struct
import threading

from rpcclient.exceptions import InvalidServerVersionMagicError, ServerDiedError, ServerResponseError
from rpcclient.protos.rpc_pb2 import CmdClose, Command, Handshake, Response

# make sure imports from the *_pb2 modules don't depend on the locally installed protobuf version
os.environ['PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION'] = 'python'
from rpcclient.protos.rpc_pb2 import CmdClose, Command, Handshake, Response # noqa: E402

# field[0] is MAGIC - skip
COMMAND_MAPPING = {field.message_type.name: field.name for field in Command.DESCRIPTOR.fields[1:]}
Expand Down
6 changes: 5 additions & 1 deletion src/rpcclient/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from contextlib import closing
from uuid import uuid4

Expand All @@ -7,7 +8,10 @@
from rpcclient.darwin.client import DarwinClient
from rpcclient.exceptions import BadReturnValueError
from rpcclient.ios.client import IosClient
from rpcclient.protos.rpc_pb2 import ARCH_ARM64

# make sure imports from the *_pb2 modules don't depend on the locally installed protobuf version
os.environ['PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION'] = 'python'
from rpcclient.protos.rpc_pb2 import ARCH_ARM64 # noqa: E402


@pytest.fixture
Expand Down

0 comments on commit ceeafc7

Please sign in to comment.