diff options
Diffstat (limited to 'plugins/pychrysalide/analysis')
| -rw-r--r-- | plugins/pychrysalide/analysis/db/client.c | 145 | 
1 files changed, 136 insertions, 9 deletions
| diff --git a/plugins/pychrysalide/analysis/db/client.c b/plugins/pychrysalide/analysis/db/client.c index f9ce001..80e15b8 100644 --- a/plugins/pychrysalide/analysis/db/client.c +++ b/plugins/pychrysalide/analysis/db/client.c @@ -56,6 +56,12 @@ static PyObject *py_hub_client_save(PyObject *, PyObject *);  /* Active les éléments en amont d'un horodatage donné. */  static PyObject *py_hub_client_set_last_active(PyObject *, PyObject *); +/* Définit la désignation d'un instantané donné. */ +static PyObject *py_hub_client_set_snapshot_name(PyObject *, PyObject *); + +/* Définit la désignation d'un instantané donné. */ +static PyObject *py_hub_client_set_snapshot_desc(PyObject *, PyObject *); +  /* Fournit la liste des instantanés existants. */  static PyObject *py_hub_client_get_snapshots(PyObject *, void *); @@ -92,7 +98,8 @@ static PyObject *py_hub_client_new(PyTypeObject *type, PyObject *args, PyObject      GHubClient *client;                     /* Serveur mis en place        */  #define HUB_CLIENT_DOC                                                                  \ -    "HubClient provides binary updates to a given server.\n"                            \ +    "HubClient provides and receives binary updates to and from a connected"            \ +    " to a server.\n"                                                                   \      "\n"                                                                                \      "Such clients must be authenticated and communications are encrypted using TLS.\n"  \      "\n"                                                                                \ @@ -101,10 +108,20 @@ static PyObject *py_hub_client_new(PyTypeObject *type, PyObject *args, PyObject      "    HubClient(hash, list)"                                                         \      "\n"                                                                                \      "Where hash is a SHA256 fingerprint of the studied binary and list is a list of"    \ -    " pychrysalide.analysis.db.DbCollection instances.\n"                               \ +    " pychrysalide.analysis.db.DbCollection instances ; this kind of list can be"       \ +    " retrived with the pychrysalide.analysis.LoadedBinary.collections attribute."      \ +    "\n"                                                                                \ +    "HubClient instances emit the following signals:\n"                                 \ +    "* 'snapshots-updated'\n"                                                           \ +    "    This signal is emitted when the snapshot list has evolved.\n"                  \      "\n"                                                                                \ -    "This kind of list can be retrived with the"                                        \ -    " pychrysalide.analysis.LoadedBinary.collections attribute." +    "    Handlers are expected to have only one argument: the client managing the"      \ +    "    updated snapshots.\n"                                                          \ +    "* 'snapshot-changed'\n"                                                            \ +    "    This signal is emitted when the identifier of the current snapshot changed.\n" \ +    "\n"                                                                                \ +    "    Handlers are expected to have only one argument: the client managing the"      \ +    "    snapshots."      ret = PyArg_ParseTuple(args, "sO", &hash, &list);      if (!ret) return NULL; @@ -256,8 +273,6 @@ static PyObject *py_hub_client_stop(PyObject *self, PyObject *args)  *                                                                             *  *  Retour      : True si la commande a bien été envoyée, False sinon.         *  *                                                                             * -*  Retour      : -                                                            * -*                                                                             *  *  Remarques   : -                                                            *  *                                                                             *  ******************************************************************************/ @@ -272,7 +287,7 @@ static PyObject *py_hub_client_save(PyObject *self, PyObject *args)  (                                                                           \      save, "$self, /",                                                       \      METH_NOARGS, py_hub_client,                                             \ -    "Ask the server for saving the current state of the analyzed binary,"   \ +    "Ask the server for saving the current state of the analyzed binary"    \      " and returns the status of the request transmission."                  \  ) @@ -297,8 +312,6 @@ static PyObject *py_hub_client_save(PyObject *self, PyObject *args)  *                                                                             *  *  Retour      : True si la commande a bien été envoyée, False sinon.         *  *                                                                             * -*  Retour      : -                                                            * -*                                                                             *  *  Remarques   : -                                                            *  *                                                                             *  ******************************************************************************/ @@ -340,6 +353,118 @@ static PyObject *py_hub_client_set_last_active(PyObject *self, PyObject *args)  /******************************************************************************  *                                                                             * +*  Paramètres  : self = client à manipuler.                                   * +*                args = arguments d'appel à consulter.                        * +*                                                                             * +*  Description : Définit la désignation d'un instantané donné.                * +*                                                                             * +*  Retour      : True si la commande a bien été envoyée, False sinon.         * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static PyObject *py_hub_client_set_snapshot_name(PyObject *self, PyObject *args) +{ +    PyObject *result;                       /* Bilan à retourner           */ +    const char *raw_id;                     /* Identifiant brut            */ +    const char *text;                       /* Texte fourni à transmettre  */ +    int ret;                                /* Bilan de lecture des args.  */ +    snapshot_id_t id;                       /* Identifiant utilisable      */ +    bool status;                            /* Bilan d'opération           */ +    GHubClient *client;                     /* Version native du serveur   */ + +#define HUB_CLIENT_SET_SNAPSHOT_NAME_METHOD PYTHON_METHOD_DEF               \ +(                                                                           \ +    set_snapshot_name, "$self, id, name, /",                                \ +    METH_VARARGS, py_hub_client,                                            \ +    "Ask the server for defining a new name of for a snapshot using its"    \ +    " identifier and returns the status of the request transmission."       \ +    "\n"                                                                    \ +    "A 'snapshots-updated' signal is emitted once the request has been"     \ +    " processed with success."                                              \ +) + +    ret = PyArg_ParseTuple(args, "ss", &raw_id, &text); +    if (!ret) return NULL; + +    status = init_snapshot_id_from_text(&id, raw_id); +    if (!status) +    { +        PyErr_SetString(PyExc_TypeError, _("provided value is not a valid snapshot identifier.")); +        return NULL; +    } + +    client = G_HUB_CLIENT(pygobject_get(self)); + +    status = g_hub_client_set_snapshot_name(client, &id, text); + +    result = status ? Py_True : Py_False; +    Py_INCREF(result); + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : self = client à manipuler.                                   * +*                args = arguments d'appel à consulter.                        * +*                                                                             * +*  Description : Définit la désignation d'un instantané donné.                * +*                                                                             * +*  Retour      : True si la commande a bien été envoyée, False sinon.         * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static PyObject *py_hub_client_set_snapshot_desc(PyObject *self, PyObject *args) +{ +    PyObject *result;                       /* Bilan à retourner           */ +    const char *raw_id;                     /* Identifiant brut            */ +    const char *text;                       /* Texte fourni à transmettre  */ +    int ret;                                /* Bilan de lecture des args.  */ +    snapshot_id_t id;                       /* Identifiant utilisable      */ +    bool status;                            /* Bilan d'opération           */ +    GHubClient *client;                     /* Version native du serveur   */ + +#define HUB_CLIENT_SET_SNAPSHOT_DESC_METHOD PYTHON_METHOD_DEF               \ +(                                                                           \ +    set_snapshot_desc, "$self, id, desc, /",                                \ +    METH_VARARGS, py_hub_client,                                            \ +    "Ask the server for defining a new description for a snapshot using"    \ +    " its identifier and returns the status of the request transmission."   \ +    "\n"                                                                    \ +    "A 'snapshots-updated' signal is emitted once the request has been"     \ +    " processed with success."                                              \ +) + +    ret = PyArg_ParseTuple(args, "ss", &raw_id, &text); +    if (!ret) return NULL; + +    status = init_snapshot_id_from_text(&id, raw_id); +    if (!status) +    { +        PyErr_SetString(PyExc_TypeError, _("provided value is not a valid snapshot identifier.")); +        return NULL; +    } + +    client = G_HUB_CLIENT(pygobject_get(self)); + +    status = g_hub_client_set_snapshot_desc(client, &id, text); + +    result = status ? Py_True : Py_False; +    Py_INCREF(result); + +    return result; + +} + + +/****************************************************************************** +*                                                                             *  *  Paramètres  : self    = objet Python concerné par l'appel.                 *  *                closure = non utilisé ici.                                   *  *                                                                             * @@ -584,6 +709,8 @@ PyTypeObject *get_python_hub_client_type(void)          HUB_CLIENT_STOP_METHOD,          HUB_CLIENT_SAVE_METHOD,          HUB_CLIENT_SET_LAST_ACTIVE_METHOD, +        HUB_CLIENT_SET_SNAPSHOT_NAME_METHOD, +        HUB_CLIENT_SET_SNAPSHOT_DESC_METHOD,          { NULL }      }; | 
