mirror of
https://github.com/frida/frida-python
synced 2026-06-08 14:16:17 +00:00
Compare commits
34 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2c757a08f3 | |||
| fc735c048f | |||
| 4d84536160 | |||
| 9e51c78c5c | |||
| a6d51e8384 | |||
| 3e80ed726d | |||
| 985410b6ff | |||
| 21c7b9ee6a | |||
| 7fba1cdc67 | |||
| a709856e2a | |||
| c3afe6089d | |||
| 6435a78d13 | |||
| 09175036ea | |||
| e0c90c5203 | |||
| 9f463fb602 | |||
| 9fdee2270f | |||
| 6e536a56b1 | |||
| 74925d082e | |||
| bf1245ddb0 | |||
| 0f247e9439 | |||
| 17aae5fe5c | |||
| 477a90534e | |||
| c87cdca293 | |||
| 30968b3805 | |||
| 5e3f27d0cb | |||
| 904461eb01 | |||
| dc652faa90 | |||
| f5ba22ad36 | |||
| dccb6810ca | |||
| 82441c6d61 | |||
| 323dca48c2 | |||
| ef71f0fa92 | |||
| e92e829f6d | |||
| 5793fb5528 |
@@ -754,8 +754,13 @@ class Compiler(Object):
|
||||
self,
|
||||
entrypoint: str,
|
||||
project_root: Optional[str] = None,
|
||||
output_format: Optional[str] = None,
|
||||
bundle_format: Optional[str] = None,
|
||||
type_check: Optional[str] = None,
|
||||
source_maps: Optional[str] = None,
|
||||
compression: Optional[str] = None,
|
||||
platform: Optional[str] = None,
|
||||
externals: Optional[Sequence[str]] = None,
|
||||
) -> str:
|
||||
"""
|
||||
Build an agent.
|
||||
@@ -766,8 +771,13 @@ class Compiler(Object):
|
||||
self,
|
||||
entrypoint: str,
|
||||
project_root: Optional[str] = None,
|
||||
output_format: Optional[str] = None,
|
||||
bundle_format: Optional[str] = None,
|
||||
type_check: Optional[str] = None,
|
||||
source_maps: Optional[str] = None,
|
||||
compression: Optional[str] = None,
|
||||
platform: Optional[str] = None,
|
||||
externals: Optional[Sequence[str]] = None,
|
||||
) -> None:
|
||||
"""
|
||||
Continuously build an agent.
|
||||
|
||||
+57
-12
@@ -533,7 +533,8 @@ static void PyCompiler_dealloc (PyCompiler * self);
|
||||
static PyObject * PyCompiler_build (PyCompiler * self, PyObject * args, PyObject * kw);
|
||||
static PyObject * PyCompiler_watch (PyCompiler * self, PyObject * args, PyObject * kw);
|
||||
static gboolean PyCompiler_set_options (FridaCompilerOptions * options, const gchar * project_root_value, const gchar * output_format_value,
|
||||
const gchar * bundle_format_value, const gchar * type_check_value, const gchar * source_maps_value, const gchar * compression_value);
|
||||
const gchar * bundle_format_value, const gchar * type_check_value, const gchar * source_maps_value, const gchar * compression_value,
|
||||
const gchar * platform_value, PyObject * externals_value);
|
||||
|
||||
static int PyPackageManager_init (PyPackageManager * self, PyObject * args, PyObject * kw);
|
||||
static void PyPackageManager_dealloc (PyPackageManager * self);
|
||||
@@ -4904,8 +4905,8 @@ static PyObject *
|
||||
PyCompiler_build (PyCompiler * self, PyObject * args, PyObject * kw)
|
||||
{
|
||||
PyObject * result;
|
||||
static char * keywords[] =
|
||||
{ "entrypoint", "project_root", "output_format", "bundle_format", "type_check", "source_maps", "compression", NULL };
|
||||
static char * keywords[] = { "entrypoint", "project_root", "output_format", "bundle_format", "type_check", "source_maps", "compression",
|
||||
"platform", "externals", NULL };
|
||||
const char * entrypoint;
|
||||
const char * project_root = NULL;
|
||||
const char * output_format = NULL;
|
||||
@@ -4913,17 +4914,19 @@ PyCompiler_build (PyCompiler * self, PyObject * args, PyObject * kw)
|
||||
const char * type_check = NULL;
|
||||
const char * source_maps = NULL;
|
||||
const char * compression = NULL;
|
||||
const char * platform = NULL;
|
||||
PyObject * externals = NULL;
|
||||
FridaBuildOptions * options;
|
||||
GError * error = NULL;
|
||||
gchar * bundle;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords (args, kw, "s|ssssss", keywords, &entrypoint, &project_root, &output_format, &bundle_format, &type_check,
|
||||
&source_maps, &compression))
|
||||
if (!PyArg_ParseTupleAndKeywords (args, kw, "s|sssssssO", keywords, &entrypoint, &project_root, &output_format, &bundle_format,
|
||||
&type_check, &source_maps, &compression, &platform, &externals))
|
||||
return NULL;
|
||||
|
||||
options = frida_build_options_new ();
|
||||
if (!PyCompiler_set_options (FRIDA_COMPILER_OPTIONS (options), project_root, output_format, bundle_format, type_check, source_maps,
|
||||
compression))
|
||||
compression, platform, externals))
|
||||
goto invalid_option_value;
|
||||
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
@@ -4950,8 +4953,8 @@ invalid_option_value:
|
||||
static PyObject *
|
||||
PyCompiler_watch (PyCompiler * self, PyObject * args, PyObject * kw)
|
||||
{
|
||||
static char * keywords[] =
|
||||
{ "entrypoint", "project_root", "output_format", "bundle_format", "type_check", "source_maps", "compression", NULL };
|
||||
static char * keywords[] = { "entrypoint", "project_root", "output_format", "bundle_format", "type_check", "source_maps", "compression",
|
||||
"platform", "externals", NULL };
|
||||
const char * entrypoint;
|
||||
const char * project_root = NULL;
|
||||
const char * output_format = NULL;
|
||||
@@ -4959,16 +4962,18 @@ PyCompiler_watch (PyCompiler * self, PyObject * args, PyObject * kw)
|
||||
const char * type_check = NULL;
|
||||
const char * source_maps = NULL;
|
||||
const char * compression = NULL;
|
||||
const char * platform = NULL;
|
||||
PyObject * externals = NULL;
|
||||
FridaWatchOptions * options;
|
||||
GError * error = NULL;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords (args, kw, "s|ssssss", keywords, &entrypoint, &project_root, &output_format, &bundle_format, &type_check,
|
||||
&source_maps, &compression))
|
||||
if (!PyArg_ParseTupleAndKeywords (args, kw, "s|sssssssO", keywords, &entrypoint, &project_root, &output_format, &bundle_format,
|
||||
&type_check, &source_maps, &compression, &platform, &externals))
|
||||
return NULL;
|
||||
|
||||
options = frida_watch_options_new ();
|
||||
if (!PyCompiler_set_options (FRIDA_COMPILER_OPTIONS (options), project_root, output_format, bundle_format, type_check, source_maps,
|
||||
compression))
|
||||
compression, platform, externals))
|
||||
goto invalid_option_value;
|
||||
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
@@ -4991,7 +4996,8 @@ invalid_option_value:
|
||||
|
||||
static gboolean
|
||||
PyCompiler_set_options (FridaCompilerOptions * options, const gchar * project_root_value, const gchar * output_format_value,
|
||||
const gchar * bundle_format_value, const gchar * type_check_value, const gchar * source_maps_value, const gchar * compression_value)
|
||||
const gchar * bundle_format_value, const gchar * type_check_value, const gchar * source_maps_value, const gchar * compression_value,
|
||||
const gchar * platform_value, PyObject * externals_value)
|
||||
{
|
||||
if (project_root_value != NULL)
|
||||
frida_compiler_options_set_project_root (options, project_root_value);
|
||||
@@ -5046,6 +5052,43 @@ PyCompiler_set_options (FridaCompilerOptions * options, const gchar * project_ro
|
||||
frida_compiler_options_set_compression (options, compression);
|
||||
}
|
||||
|
||||
if (platform_value != NULL)
|
||||
{
|
||||
FridaJsPlatform platform;
|
||||
|
||||
if (!PyGObject_unmarshal_enum (platform_value, FRIDA_TYPE_JS_PLATFORM, &platform))
|
||||
return FALSE;
|
||||
|
||||
frida_compiler_options_set_platform (options, platform);
|
||||
}
|
||||
|
||||
if (externals_value != NULL)
|
||||
{
|
||||
gint n, i;
|
||||
|
||||
n = PySequence_Size (externals_value);
|
||||
if (n == -1)
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i != n; i++)
|
||||
{
|
||||
PyObject * element;
|
||||
gchar * external = NULL;
|
||||
|
||||
element = PySequence_GetItem (externals_value, i);
|
||||
if (element == NULL)
|
||||
return FALSE;
|
||||
PyGObject_unmarshal_string (element, &external);
|
||||
Py_DecRef (element);
|
||||
if (external == NULL)
|
||||
return FALSE;
|
||||
|
||||
frida_compiler_options_add_external (options, external);
|
||||
|
||||
g_free (external);
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -5208,6 +5251,8 @@ PyPackageManager_parse_install_options (const gchar * project_root, const char *
|
||||
goto propagate_error;
|
||||
|
||||
frida_package_install_options_add_spec (options, spec);
|
||||
|
||||
g_free (spec);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+54
-86
@@ -33,10 +33,15 @@ if sys.version_info >= (3, 8):
|
||||
else:
|
||||
from typing_extensions import Literal, TypedDict
|
||||
|
||||
if sys.version_info >= (3, 11):
|
||||
from typing import NotRequired
|
||||
if sys.version_info >= (3, 10):
|
||||
from typing import ParamSpec
|
||||
else:
|
||||
from typing_extensions import NotRequired
|
||||
from typing_extensions import ParamSpec
|
||||
|
||||
if sys.version_info >= (3, 11):
|
||||
from typing import NotRequired, cast
|
||||
else:
|
||||
from typing_extensions import NotRequired, cast
|
||||
|
||||
from . import _frida
|
||||
|
||||
@@ -72,15 +77,18 @@ def _filter_missing_kwargs(d: MutableMapping[Any, Any]) -> None:
|
||||
d.pop(key)
|
||||
|
||||
|
||||
R = TypeVar("R")
|
||||
P = ParamSpec("P")
|
||||
R = TypeVar("R", covariant=True)
|
||||
|
||||
|
||||
def cancellable(f: Callable[..., R]) -> Callable[..., R]:
|
||||
def cancellable(f: Callable[P, R]) -> Callable[P, R]:
|
||||
# currently there is no way to type properly the extended callable with optional cancellable parameter
|
||||
# ref: https://github.com/python/typing/discussions/1905#discussioncomment-11696995
|
||||
@functools.wraps(f)
|
||||
def wrapper(*args: Any, **kwargs: Any) -> R:
|
||||
def wrapper(*args: P.args, **kwargs: P.kwargs) -> R:
|
||||
cancellable = kwargs.pop("cancellable", None)
|
||||
if cancellable is not None:
|
||||
with cancellable:
|
||||
with cast(Cancellable, cancellable):
|
||||
return f(*args, **kwargs)
|
||||
|
||||
return f(*args, **kwargs)
|
||||
@@ -351,9 +359,6 @@ class Script:
|
||||
@overload
|
||||
def on(self, signal: Literal["message"], callback: ScriptMessageCallback) -> None: ...
|
||||
|
||||
@overload
|
||||
def on(self, signal: str, callback: Callable[..., Any]) -> None: ...
|
||||
|
||||
def on(self, signal: str, callback: Callable[..., Any]) -> None:
|
||||
"""
|
||||
Add a signal handler
|
||||
@@ -370,9 +375,6 @@ class Script:
|
||||
@overload
|
||||
def off(self, signal: Literal["message"], callback: ScriptMessageCallback) -> None: ...
|
||||
|
||||
@overload
|
||||
def off(self, signal: str, callback: Callable[..., Any]) -> None: ...
|
||||
|
||||
def off(self, signal: str, callback: Callable[..., Any]) -> None:
|
||||
"""
|
||||
Remove a signal handler
|
||||
@@ -693,34 +695,22 @@ class Session:
|
||||
_filter_missing_kwargs(kwargs)
|
||||
return PortalMembership(self._impl.join_portal(address, **kwargs))
|
||||
|
||||
@overload
|
||||
def on(
|
||||
self,
|
||||
signal: Literal["detached"],
|
||||
callback: SessionDetachedCallback,
|
||||
) -> None: ...
|
||||
|
||||
@overload
|
||||
def on(self, signal: str, callback: Callable[..., Any]) -> None: ...
|
||||
|
||||
def on(self, signal: str, callback: Callable[..., Any]) -> None:
|
||||
) -> None:
|
||||
"""
|
||||
Add a signal handler
|
||||
"""
|
||||
|
||||
self._impl.on(signal, callback)
|
||||
|
||||
@overload
|
||||
def off(
|
||||
self,
|
||||
signal: Literal["detached"],
|
||||
callback: SessionDetachedCallback,
|
||||
) -> None: ...
|
||||
|
||||
@overload
|
||||
def off(self, signal: str, callback: Callable[..., Any]) -> None: ...
|
||||
|
||||
def off(self, signal: str, callback: Callable[..., Any]) -> None:
|
||||
) -> None:
|
||||
"""
|
||||
Remove a signal handler
|
||||
"""
|
||||
@@ -763,9 +753,6 @@ class Bus:
|
||||
@overload
|
||||
def on(self, signal: Literal["message"], callback: BusMessageCallback) -> None: ...
|
||||
|
||||
@overload
|
||||
def on(self, signal: str, callback: Callable[..., Any]) -> None: ...
|
||||
|
||||
def on(self, signal: str, callback: Callable[..., Any]) -> None:
|
||||
"""
|
||||
Add a signal handler
|
||||
@@ -782,9 +769,6 @@ class Bus:
|
||||
@overload
|
||||
def off(self, signal: Literal["message"], callback: BusMessageCallback) -> None: ...
|
||||
|
||||
@overload
|
||||
def off(self, signal: str, callback: Callable[..., Any]) -> None: ...
|
||||
|
||||
def off(self, signal: str, callback: Callable[..., Any]) -> None:
|
||||
"""
|
||||
Remove a signal handler
|
||||
@@ -842,9 +826,6 @@ class Service:
|
||||
@overload
|
||||
def on(self, signal: Literal["message"], callback: ServiceMessageCallback) -> None: ...
|
||||
|
||||
@overload
|
||||
def on(self, signal: str, callback: Callable[..., Any]) -> None: ...
|
||||
|
||||
def on(self, signal: str, callback: Callable[..., Any]) -> None:
|
||||
"""
|
||||
Add a signal handler
|
||||
@@ -858,9 +839,6 @@ class Service:
|
||||
@overload
|
||||
def off(self, signal: Literal["message"], callback: ServiceMessageCallback) -> None: ...
|
||||
|
||||
@overload
|
||||
def off(self, signal: str, callback: Callable[..., Any]) -> None: ...
|
||||
|
||||
def off(self, signal: str, callback: Callable[..., Any]) -> None:
|
||||
"""
|
||||
Remove a signal handler
|
||||
@@ -1144,9 +1122,6 @@ class Device:
|
||||
@overload
|
||||
def on(self, signal: Literal["lost"], callback: DeviceLostCallback) -> None: ...
|
||||
|
||||
@overload
|
||||
def on(self, signal: str, callback: Callable[..., Any]) -> None: ...
|
||||
|
||||
def on(self, signal: str, callback: Callable[..., Any]) -> None:
|
||||
"""
|
||||
Add a signal handler
|
||||
@@ -1178,9 +1153,6 @@ class Device:
|
||||
@overload
|
||||
def off(self, signal: Literal["lost"], callback: DeviceLostCallback) -> None: ...
|
||||
|
||||
@overload
|
||||
def off(self, signal: str, callback: Callable[..., Any]) -> None: ...
|
||||
|
||||
def off(self, signal: str, callback: Callable[..., Any]) -> None:
|
||||
"""
|
||||
Remove a signal handler
|
||||
@@ -1298,9 +1270,6 @@ class DeviceManager:
|
||||
@overload
|
||||
def on(self, signal: Literal["changed"], callback: DeviceManagerChangedCallback) -> None: ...
|
||||
|
||||
@overload
|
||||
def on(self, signal: str, callback: Callable[..., Any]) -> None: ...
|
||||
|
||||
def on(self, signal: str, callback: Callable[..., Any]) -> None:
|
||||
"""
|
||||
Add a signal handler
|
||||
@@ -1317,9 +1286,6 @@ class DeviceManager:
|
||||
@overload
|
||||
def off(self, signal: Literal["changed"], callback: DeviceManagerChangedCallback) -> None: ...
|
||||
|
||||
@overload
|
||||
def off(self, signal: str, callback: Callable[..., Any]) -> None: ...
|
||||
|
||||
def off(self, signal: str, callback: Callable[..., Any]) -> None:
|
||||
"""
|
||||
Remove a signal handler
|
||||
@@ -1490,9 +1456,6 @@ class PortalService:
|
||||
@overload
|
||||
def on(self, signal: Literal["message"], callback: PortalServiceMessageCallback) -> None: ...
|
||||
|
||||
@overload
|
||||
def on(self, signal: str, callback: Callable[..., Any]) -> None: ...
|
||||
|
||||
def on(self, signal: str, callback: Callable[..., Any]) -> None:
|
||||
"""
|
||||
Add a signal handler
|
||||
@@ -1554,6 +1517,13 @@ CompilerFinishedCallback = Callable[[], None]
|
||||
CompilerOutputCallback = Callable[[str], None]
|
||||
CompilerDiagnosticsCallback = Callable[[List[CompilerDiagnostic]], None]
|
||||
|
||||
CompilerOutputFormat = Literal["unescaped", "hex-bytes", "c-string"]
|
||||
CompilerBundleFormat = Literal["esm", "iife"]
|
||||
CompilerTypeCheck = Literal["full", "none"]
|
||||
CompilerSourceMaps = Literal["included", "omitted"]
|
||||
CompilerCompression = Literal["none", "terser"]
|
||||
CompilerPlatform = Literal["neutral", "gum", "browser"]
|
||||
|
||||
|
||||
class Compiler:
|
||||
def __init__(self) -> None:
|
||||
@@ -1567,19 +1537,23 @@ class Compiler:
|
||||
self,
|
||||
entrypoint: str,
|
||||
project_root: Optional[str] = None,
|
||||
output_format: Optional[str] = None,
|
||||
bundle_format: Optional[str] = None,
|
||||
type_check: Optional[str] = None,
|
||||
source_maps: Optional[str] = None,
|
||||
compression: Optional[str] = None,
|
||||
output_format: Optional[CompilerOutputFormat] = None,
|
||||
bundle_format: Optional[CompilerBundleFormat] = None,
|
||||
type_check: Optional[CompilerTypeCheck] = None,
|
||||
source_maps: Optional[CompilerSourceMaps] = None,
|
||||
compression: Optional[CompilerCompression] = None,
|
||||
platform: Optional[CompilerPlatform] = None,
|
||||
externals: Optional[Sequence[str]] = None,
|
||||
) -> str:
|
||||
kwargs = {
|
||||
kwargs: dict[str, Any] = {
|
||||
"project_root": project_root,
|
||||
"output_format": output_format,
|
||||
"bundle_format": bundle_format,
|
||||
"type_check": type_check,
|
||||
"source_maps": source_maps,
|
||||
"compression": compression,
|
||||
"platform": platform,
|
||||
"externals": externals,
|
||||
}
|
||||
_filter_missing_kwargs(kwargs)
|
||||
return self._impl.build(entrypoint, **kwargs)
|
||||
@@ -1589,19 +1563,23 @@ class Compiler:
|
||||
self,
|
||||
entrypoint: str,
|
||||
project_root: Optional[str] = None,
|
||||
output_format: Optional[str] = None,
|
||||
bundle_format: Optional[str] = None,
|
||||
type_check: Optional[str] = None,
|
||||
source_maps: Optional[str] = None,
|
||||
compression: Optional[str] = None,
|
||||
output_format: Optional[CompilerOutputFormat] = None,
|
||||
bundle_format: Optional[CompilerBundleFormat] = None,
|
||||
type_check: Optional[CompilerTypeCheck] = None,
|
||||
source_maps: Optional[CompilerSourceMaps] = None,
|
||||
compression: Optional[CompilerCompression] = None,
|
||||
platform: Optional[CompilerPlatform] = None,
|
||||
externals: Optional[Sequence[str]] = None,
|
||||
) -> None:
|
||||
kwargs = {
|
||||
kwargs: dict[str, Any] = {
|
||||
"project_root": project_root,
|
||||
"output_format": output_format,
|
||||
"bundle_format": bundle_format,
|
||||
"type_check": type_check,
|
||||
"source_maps": source_maps,
|
||||
"compression": compression,
|
||||
"platform": platform,
|
||||
"externals": externals,
|
||||
}
|
||||
_filter_missing_kwargs(kwargs)
|
||||
return self._impl.watch(entrypoint, **kwargs)
|
||||
@@ -1618,10 +1596,11 @@ class Compiler:
|
||||
@overload
|
||||
def on(self, signal: Literal["diagnostics"], callback: CompilerDiagnosticsCallback) -> None: ...
|
||||
|
||||
@overload
|
||||
def on(self, signal: str, callback: Callable[..., Any]) -> None: ...
|
||||
|
||||
def on(self, signal: str, callback: Callable[..., Any]) -> None:
|
||||
"""
|
||||
Add a signal handler
|
||||
"""
|
||||
|
||||
self._impl.on(signal, callback)
|
||||
|
||||
@overload
|
||||
@@ -1636,10 +1615,11 @@ class Compiler:
|
||||
@overload
|
||||
def off(self, signal: Literal["diagnostics"], callback: CompilerDiagnosticsCallback) -> None: ...
|
||||
|
||||
@overload
|
||||
def off(self, signal: str, callback: Callable[..., Any]) -> None: ...
|
||||
|
||||
def off(self, signal: str, callback: Callable[..., Any]) -> None:
|
||||
"""
|
||||
Remove a signal handler
|
||||
"""
|
||||
|
||||
self._impl.off(signal, callback)
|
||||
|
||||
|
||||
@@ -1711,22 +1691,10 @@ class PackageManager:
|
||||
_filter_missing_kwargs(kwargs)
|
||||
return self._impl.install(**kwargs)
|
||||
|
||||
@overload
|
||||
def on(self, signal: Literal["install-progress"], callback: PackageManagerInstallProgressCallback) -> None: ...
|
||||
|
||||
@overload
|
||||
def on(self, signal: str, callback: Callable[..., Any]) -> None: ...
|
||||
|
||||
def on(self, signal: str, callback: Callable[..., Any]) -> None:
|
||||
def on(self, signal: Literal["install-progress"], callback: PackageManagerInstallProgressCallback) -> None:
|
||||
self._impl.on(signal, callback)
|
||||
|
||||
@overload
|
||||
def off(self, signal: Literal["install-progress"], callback: PackageManagerInstallProgressCallback) -> None: ...
|
||||
|
||||
@overload
|
||||
def off(self, signal: str, callback: Callable[..., Any]) -> None: ...
|
||||
|
||||
def off(self, signal: str, callback: Callable[..., Any]) -> None:
|
||||
def off(self, signal: Literal["install-progress"], callback: PackageManagerInstallProgressCallback) -> None:
|
||||
self._impl.off(signal, callback)
|
||||
|
||||
|
||||
|
||||
+1
-1
Submodule releng updated: 800f2385c3...60585cf5cf
@@ -1,6 +1,6 @@
|
||||
[wrap-git]
|
||||
url = https://github.com/frida/frida-core.git
|
||||
revision = 17.4.1
|
||||
revision = 17.6.1
|
||||
depth = 1
|
||||
|
||||
[provide]
|
||||
|
||||
Reference in New Issue
Block a user