summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2019-09-08 17:41:58 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2019-09-08 17:41:58 (GMT)
commit1430874c1ce9d5e38a23bf27049ebc5f6a6619bb (patch)
tree5b57937b6b5a98244b8d63f969d2350eb00739ec /plugins
parent8002f34e4060e25cb3acee76a0c2ae2970f9e9dc (diff)
Provided a way to save the database updates from Python.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/pychrysalide/analysis/binary.c56
-rw-r--r--plugins/pychrysalide/analysis/db/client.c45
2 files changed, 101 insertions, 0 deletions
diff --git a/plugins/pychrysalide/analysis/binary.c b/plugins/pychrysalide/analysis/binary.c
index 98b20dc..9d57952 100644
--- a/plugins/pychrysalide/analysis/binary.c
+++ b/plugins/pychrysalide/analysis/binary.c
@@ -45,6 +45,9 @@
/* Crée un nouvel objet Python de type 'LoadedBinary'. */
static PyObject *py_loaded_binary_new(PyTypeObject *, PyObject *, PyObject *);
+/* Fournit un client assurant la liaison avec un serveur. */
+static PyObject *py_loaded_binary_get_client(PyObject *, PyObject *);
+
/* Demande l'intégration d'une modification dans une collection. */
static PyObject *py_loaded_binary_add_to_collection(PyObject *, PyObject *);
@@ -103,6 +106,58 @@ static PyObject *py_loaded_binary_new(PyTypeObject *type, PyObject *args, PyObje
* Paramètres : self = objet représentant un binaire chargé. *
* args = arguments fournis pour l'opération. *
* *
+* Description : Fournit un client assurant la liaison avec un serveur. *
+* *
+* Retour : Client connecté ou None. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_loaded_binary_get_client(PyObject *self, PyObject *args)
+{
+ PyObject *result; /* Bilan à retourner */
+ bool internal; /* Nature du client visé */
+ int ret; /* Bilan de lecture des args. */
+ GLoadedBinary *binary; /* Binaire en cours d'analyse */
+ GHubClient *client; /* Eventuel client en place */
+
+#define LOADED_BINARY_GET_CLIENT_METHOD PYTHON_METHOD_DEF \
+( \
+ get_client, "$self, /, internal=True", \
+ METH_VARARGS, py_loaded_binary, \
+ "Provide the client connected to an internal or remote server" \
+ " if defined, or return None otherwise.\n" \
+)
+
+ ret = PyArg_ParseTuple(args, "|p", &internal);
+ if (!ret) return NULL;
+
+ binary = G_LOADED_BINARY(pygobject_get(self));
+
+ client = g_loaded_binary_get_client(binary, internal);
+
+ if (client != NULL)
+ {
+ result = pygobject_new(G_OBJECT(client));
+ g_object_unref(G_OBJECT(client));
+ }
+ else
+ {
+ result = Py_None;
+ Py_INCREF(result);
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : self = objet représentant un binaire chargé. *
+* args = arguments fournis pour l'opération. *
+* *
* Description : Demande l'intégration d'une modification dans une collection.*
* *
* Retour : Bilan partiel de l'opération demandée. *
@@ -303,6 +358,7 @@ static PyObject *py_loaded_binary_get_disassembled_cache(PyObject *self, void *c
PyTypeObject *get_python_loaded_binary_type(void)
{
static PyMethodDef py_loaded_binary_methods[] = {
+ LOADED_BINARY_GET_CLIENT_METHOD,
LOADED_BINARY_ADD_TO_COLLECTION_METHOD,
{ NULL }
};
diff --git a/plugins/pychrysalide/analysis/db/client.c b/plugins/pychrysalide/analysis/db/client.c
index a9ad930..13966f5 100644
--- a/plugins/pychrysalide/analysis/db/client.c
+++ b/plugins/pychrysalide/analysis/db/client.c
@@ -48,6 +48,9 @@ static PyObject *py_hub_client_start(PyObject *, PyObject *);
/* Arrête la connexion à la base de données. */
static PyObject *py_hub_client_stop(PyObject *, PyObject *);
+/* Effectue une demande de sauvegarde de l'état courant. */
+static PyObject *py_hub_client_save(PyObject *, PyObject *);
+
/******************************************************************************
@@ -235,6 +238,47 @@ static PyObject *py_hub_client_stop(PyObject *self, PyObject *args)
/******************************************************************************
* *
+* Paramètres : self = serveur à manipuler. *
+* args = arguments d'appel non utilisés ici. *
+* *
+* Description : Effectue une demande de sauvegarde de l'état courant. *
+* *
+* Retour : True si la commande a bien été envoyée, False sinon. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_hub_client_save(PyObject *self, PyObject *args)
+{
+ PyObject *result; /* Bilan à retourner */
+ GHubClient *client; /* Version native du serveur */
+ bool status; /* Bilan de l'opération */
+
+#define HUB_CLIENT_SAVE_METHOD PYTHON_METHOD_DEF \
+( \
+ save, "$self, /", \
+ METH_NOARGS, py_hub_client, \
+ "Ask the server for saving the current state of the analyzed binary," \
+ " and returns the status of the request transmission." \
+)
+
+ client = G_HUB_CLIENT(pygobject_get(self));
+
+ status = g_hub_client_save(client);
+
+ result = status ? Py_True : Py_False;
+ Py_INCREF(result);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : - *
* *
* Description : Fournit un accès à une définition de type à diffuser. *
@@ -250,6 +294,7 @@ PyTypeObject *get_python_hub_client_type(void)
static PyMethodDef py_hub_client_methods[] = {
HUB_CLIENT_START_METHOD,
HUB_CLIENT_STOP_METHOD,
+ HUB_CLIENT_SAVE_METHOD,
{ NULL }
};