summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/analysis/db
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-01-16 19:02:56 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-01-16 19:02:56 (GMT)
commit9da8f8b37e3edebc917b4e223dd2447cd7cbc818 (patch)
tree3f330b13e7ca2a0a163882be3043ca9571f25211 /plugins/pychrysalide/analysis/db
parenteb9b7fd76451db5c9f07a800c0394480e4b88c9c (diff)
Changed the Python bindings source directory and updated code.
Diffstat (limited to 'plugins/pychrysalide/analysis/db')
-rw-r--r--plugins/pychrysalide/analysis/db/Makefile.am19
-rw-r--r--plugins/pychrysalide/analysis/db/certs.c327
-rw-r--r--plugins/pychrysalide/analysis/db/certs.h42
-rw-r--r--plugins/pychrysalide/analysis/db/collection.c110
-rw-r--r--plugins/pychrysalide/analysis/db/collection.h42
-rw-r--r--plugins/pychrysalide/analysis/db/item.c182
-rw-r--r--plugins/pychrysalide/analysis/db/item.h42
-rw-r--r--plugins/pychrysalide/analysis/db/items/Makefile.am14
-rw-r--r--plugins/pychrysalide/analysis/db/items/comment.c241
-rw-r--r--plugins/pychrysalide/analysis/db/items/comment.h42
-rw-r--r--plugins/pychrysalide/analysis/db/items/module.c93
-rw-r--r--plugins/pychrysalide/analysis/db/items/module.h39
-rw-r--r--plugins/pychrysalide/analysis/db/module.c100
-rw-r--r--plugins/pychrysalide/analysis/db/module.h39
14 files changed, 1332 insertions, 0 deletions
diff --git a/plugins/pychrysalide/analysis/db/Makefile.am b/plugins/pychrysalide/analysis/db/Makefile.am
new file mode 100644
index 0000000..a6bb701
--- /dev/null
+++ b/plugins/pychrysalide/analysis/db/Makefile.am
@@ -0,0 +1,19 @@
+
+noinst_LTLIBRARIES = libpychrysaanalysisdb.la
+
+libpychrysaanalysisdb_la_SOURCES = \
+ certs.h certs.c \
+ collection.h collection.c \
+ item.h item.c \
+ module.h module.c
+
+libpychrysaanalysisdb_la_LDFLAGS = \
+ items/libpychrysaanalysisdbitems.la
+
+
+AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) $(LIBPYTHON_CFLAGS) $(LIBPYGOBJECT_CFLAGS) \
+ -I../../../../src
+
+AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS)
+
+SUBDIRS = items
diff --git a/plugins/pychrysalide/analysis/db/certs.c b/plugins/pychrysalide/analysis/db/certs.c
new file mode 100644
index 0000000..e0358d1
--- /dev/null
+++ b/plugins/pychrysalide/analysis/db/certs.c
@@ -0,0 +1,327 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * certs.c - équivalent Python du fichier "analysis/db/certs.c"
+ *
+ * Copyright (C) 2017 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chrysalide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#include "certs.h"
+
+
+#include <pygobject.h>
+#include <string.h>
+
+
+#include <i18n.h>
+#include <analysis/db/certs.h>
+
+
+#include "../../helpers.h"
+
+
+
+/* Traduit en version native une identité de certificat. */
+static bool py_certs_fill_x509_entries(PyObject *, x509_entries *);
+
+/* Crée un certificat de signature racine. */
+static PyObject *py_certs_make_ca(PyObject *, PyObject *);
+
+/* Crée un certificat pour application. */
+static PyObject *py_certs_make_request(PyObject *, PyObject *);
+
+/* Signe un certificat pour application. */
+static PyObject *py_certs_sign_cert(PyObject *, PyObject *);
+
+
+
+/******************************************************************************
+* *
+* Paramètres : dict = ensemble de propriétés renseignées. *
+* out = résumé des entrées regroupées. [OUT] *
+* *
+* Description : Traduit en version native une identité de certificat. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static bool py_certs_fill_x509_entries(PyObject *dict, x509_entries *out)
+{
+ bool result; /* Bilan à retourner */
+ PyObject *value; /* Valeur au format Python */
+
+#define TRANSLATE_ENTRY(name, dest) \
+ do \
+ { \
+ value = PyDict_GetItemString(dict, name); \
+ if (value != NULL) \
+ { \
+ result = PyUnicode_Check(value); \
+ if (result) \
+ out->dest = strdup((char *)PyUnicode_DATA(value)); \
+ else \
+ PyErr_Format(PyExc_TypeError, _("The %s property must be a string."), name); \
+ } \
+ } \
+ while (0)
+
+ result = true;
+
+ memset(out, 0, sizeof(x509_entries));
+
+ TRANSLATE_ENTRY("C", country);
+
+ if (result)
+ TRANSLATE_ENTRY("ST", state);
+
+ if (result)
+ TRANSLATE_ENTRY("L", locality);
+
+ if (result)
+ TRANSLATE_ENTRY("O", organisation);
+
+ if (result)
+ TRANSLATE_ENTRY("OU", organisational_unit);
+
+ if (result)
+ TRANSLATE_ENTRY("CN", common_name);
+
+ if (!result)
+ free_x509_entries(out);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : self = NULL car méthode statique. *
+* args = paramètres à transmettre à l'appel natif. *
+* *
+* Description : Crée un certificat de signature racine. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_certs_make_ca(PyObject *self, PyObject *args)
+{
+ PyObject *result; /* Désignation à retourner */
+ const char *dir; /* Répertoire de sortie */
+ const char *label; /* Nom principal du certificat */
+ unsigned long valid; /* Durée de validité en sec. */
+ PyObject *dict; /* Détails identitaires */
+ int ret; /* Bilan de lecture des args. */
+ x509_entries entries; /* Définition d'une identité */
+ bool status; /* Bilan d'une constitution */
+
+ ret = PyArg_ParseTuple(args, "sskO!", &dir, &label, &valid, &PyDict_Type, &dict);
+ if (!ret) return NULL;
+
+ status = py_certs_fill_x509_entries(dict, &entries);
+ if (!status) return NULL;
+
+ status = make_ca(dir, label, valid, &entries);
+
+ free_x509_entries(&entries);
+
+ result = status ? Py_True : Py_False;
+
+ Py_INCREF(result);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : self = NULL car méthode statique. *
+* args = paramètres à transmettre à l'appel natif. *
+* *
+* Description : Crée un certificat pour application. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_certs_make_request(PyObject *self, PyObject *args)
+{
+ PyObject *result; /* Désignation à retourner */
+ const char *dir; /* Répertoire de sortie */
+ const char *label; /* Nom principal du certificat */
+ PyObject *dict; /* Détails identitaires */
+ int ret; /* Bilan de lecture des args. */
+ x509_entries entries; /* Définition d'une identité */
+ bool status; /* Bilan d'une constitution */
+
+ ret = PyArg_ParseTuple(args, "ssO!", &dir, &label, &PyDict_Type, &dict);
+ if (!ret) return NULL;
+
+ status = py_certs_fill_x509_entries(dict, &entries);
+ if (!status) return NULL;
+
+ status = make_request(dir, label, &entries);
+
+ free_x509_entries(&entries);
+
+ result = status ? Py_True : Py_False;
+
+ Py_INCREF(result);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : self = NULL car méthode statique. *
+* args = paramètres à transmettre à l'appel natif. *
+* *
+* Description : Signe un certificat pour application. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_certs_sign_cert(PyObject *self, PyObject *args)
+{
+ PyObject *result; /* Désignation à retourner */
+ const char *csr; /* Requête à satisfaire */
+ const char *cacert; /* Certificat de confiance */
+ const char *cakey; /* Clef de ce certificat */
+ const char *cert; /* Certificat en sortie */
+ unsigned long valid; /* Durée de validité en sec. */
+ int ret; /* Bilan de lecture des args. */
+ bool status; /* Bilan de l'opération */
+
+ ret = PyArg_ParseTuple(args, "ssssk", &csr, &cacert, &cakey, &cert, &valid);
+ if (!ret) return NULL;
+
+ status = sign_cert(csr, cacert, cakey, cert, valid);
+
+ result = status ? Py_True : Py_False;
+
+ Py_INCREF(result);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Fournit un accès à une définition de type à diffuser. *
+* *
+* Retour : Définition d'objet pour Python. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+PyTypeObject *get_python_certs_type(void)
+{
+ static PyMethodDef py_certs_methods[] = {
+
+ { "make_ca", py_certs_make_ca,
+ METH_VARARGS | METH_STATIC,
+ "make_ca(dir, label, valid, entries, /)\n--\n\nCreate a certificate authority."
+ },
+ { "make_request", py_certs_make_request,
+ METH_VARARGS | METH_STATIC,
+ "make_request(dir, label, entries, /)\n--\n\nCreate a certificate sign request."
+ },
+ { "sign_cert", py_certs_sign_cert,
+ METH_VARARGS | METH_STATIC,
+ "sign_cert(csr, cacert, cakey, cert, valid, /)\n--\n\nSign a certificate sign request.."
+ },
+ { NULL }
+
+ };
+
+ static PyGetSetDef py_certs_getseters[] = {
+
+ { NULL }
+
+ };
+
+ static PyTypeObject py_certs_type = {
+
+ PyVarObject_HEAD_INIT(NULL, 0)
+
+ .tp_name = "pychrysalide.analysis.db.certs",
+ .tp_basicsize = sizeof(PyGObject),
+
+ .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+
+ .tp_doc = "PyChrysalide support for DataBase certicates",
+
+ .tp_methods = py_certs_methods,
+ .tp_getset = py_certs_getseters,
+
+ };
+
+ return &py_certs_type;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : module = module dont la définition est à compléter. *
+* *
+* Description : Prend en charge l'objet 'pychrysalide....db.certs'. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool register_python_certs(PyObject *module)
+{
+ PyTypeObject *py_certs_type; /* Type Python pour 'certs' */
+ int ret; /* Bilan d'un appel */
+
+ py_certs_type = get_python_certs_type();
+
+ py_certs_type->tp_new = PyType_GenericNew;
+
+ if (PyType_Ready(py_certs_type) != 0)
+ return false;
+
+ Py_INCREF(py_certs_type);
+ ret = PyModule_AddObject(module, "certs", (PyObject *)py_certs_type);
+
+ return (ret == 0);
+
+}
diff --git a/plugins/pychrysalide/analysis/db/certs.h b/plugins/pychrysalide/analysis/db/certs.h
new file mode 100644
index 0000000..2e90778
--- /dev/null
+++ b/plugins/pychrysalide/analysis/db/certs.h
@@ -0,0 +1,42 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * certs.h - prototypes pour l'équivalent Python du fichier "analysis/db/certs.h"
+ *
+ * Copyright (C) 2017 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chrysalide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#ifndef _PLUGINS_PYCHRYSALIDE_ANALYSIS_DB_CERTS_H
+#define _PLUGINS_PYCHRYSALIDE_ANALYSIS_DB_CERTS_H
+
+
+#include <Python.h>
+#include <stdbool.h>
+
+
+
+/* Fournit un accès à une définition de type à diffuser. */
+PyTypeObject *get_python_certs_type(void);
+
+/* Prend en charge l'objet 'pychrysalide.analysis.db.certs'. */
+bool register_python_certs(PyObject *);
+
+
+
+#endif /* _PLUGINS_PYCHRYSALIDE_ANALYSIS_DB_CERTSS_H */
diff --git a/plugins/pychrysalide/analysis/db/collection.c b/plugins/pychrysalide/analysis/db/collection.c
new file mode 100644
index 0000000..80fcfc2
--- /dev/null
+++ b/plugins/pychrysalide/analysis/db/collection.c
@@ -0,0 +1,110 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * collection.c - équivalent Python du fichier "analysis/db/collection.c"
+ *
+ * Copyright (C) 2014-2017 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chrysalide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#include "collection.h"
+
+
+#include <pygobject.h>
+
+
+#include <i18n.h>
+#include <analysis/db/collection.h>
+
+
+#include "../../helpers.h"
+
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Fournit un accès à une définition de type à diffuser. *
+* *
+* Retour : Définition d'objet pour Python. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+PyTypeObject *get_python_db_collection_type(void)
+{
+ static PyMethodDef py_db_collection_methods[] = {
+ { NULL }
+ };
+
+ static PyGetSetDef py_db_collection_getseters[] = {
+
+ { NULL }
+
+ };
+
+ static PyTypeObject py_db_collection_type = {
+
+ PyVarObject_HEAD_INIT(NULL, 0)
+
+ .tp_name = "pychrysalide.analysis.db.DbCollection",
+ .tp_basicsize = sizeof(PyGObject),
+
+ .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+
+ .tp_doc = "PyChrysalide collection for DataBase collection",
+
+ .tp_methods = py_db_collection_methods,
+ .tp_getset = py_db_collection_getseters,
+
+ };
+
+ return &py_db_collection_type;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : module = module dont la définition est à compléter. *
+* *
+* Description : Prend en charge l'objet 'pychrysalide....db.DbCollection'. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool register_python_db_collection(PyObject *module)
+{
+ PyTypeObject *py_db_collection_type; /* Type Python 'DbCollection' */
+ PyObject *dict; /* Dictionnaire du module */
+
+ py_db_collection_type = get_python_db_collection_type();
+
+ dict = PyModule_GetDict(module);
+
+ if (!register_class_for_pygobject(dict, G_TYPE_DB_COLLECTION, py_db_collection_type, &PyGObject_Type))
+ return false;
+
+ return true;
+
+}
diff --git a/plugins/pychrysalide/analysis/db/collection.h b/plugins/pychrysalide/analysis/db/collection.h
new file mode 100644
index 0000000..76256bc
--- /dev/null
+++ b/plugins/pychrysalide/analysis/db/collection.h
@@ -0,0 +1,42 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * collection.h - prototypes pour l'équivalent Python du fichier "analysis/db/collection.h"
+ *
+ * Copyright (C) 2014-2017 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chrysalide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#ifndef _PLUGINS_PYCHRYSALIDE_ANALYSIS_DB_COLLECTION_H
+#define _PLUGINS_PYCHRYSALIDE_ANALYSIS_DB_COLLECTION_H
+
+
+#include <Python.h>
+#include <stdbool.h>
+
+
+
+/* Fournit un accès à une définition de type à diffuser. */
+PyTypeObject *get_python_db_collection_type(void);
+
+/* Prend en charge l'objet 'pychrysalide.analysis.db.DbCollection'. */
+bool register_python_db_collection(PyObject *);
+
+
+
+#endif /* _PLUGINS_PYCHRYSALIDE_ANALYSIS_DB_COLLECTIONS_H */
diff --git a/plugins/pychrysalide/analysis/db/item.c b/plugins/pychrysalide/analysis/db/item.c
new file mode 100644
index 0000000..27b5bac
--- /dev/null
+++ b/plugins/pychrysalide/analysis/db/item.c
@@ -0,0 +1,182 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * item.c - équivalent Python du fichier "analysis/db/item.c"
+ *
+ * Copyright (C) 2014-2017 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chrysalide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#include "item.h"
+
+
+#include <pygobject.h>
+
+
+#include <i18n.h>
+#include <analysis/db/item.h>
+
+
+#include "../../helpers.h"
+
+
+
+/* Indique si l'élément contient des données à oublier ou non. */
+static PyObject *py_db_item_get_volatile(PyObject *, void *);
+
+/* Définit si l'élément contient des données à oublier ou non. */
+static int py_db_item_set_volatile(PyObject *, PyObject *, void *);
+
+
+
+/******************************************************************************
+* *
+* Paramètres : self = objet Python concerné par l'appel. *
+* closure = non utilisé ici. *
+* *
+* Description : Indique si l'élément contient des données à oublier ou non. *
+* *
+* Retour : Etat de la sauegarde de l'élément consulté. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_db_item_get_volatile(PyObject *self, void *closure)
+{
+ PyObject *result; /* Valeur à retourner */
+ GDbItem *item; /* Elément à consulter */
+
+ item = G_DB_ITEM(pygobject_get(self));
+
+ result = (g_db_item_is_volatile(item) ? Py_True : Py_False);
+ Py_INCREF(result);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : self = objet Python concerné par l'appel. *
+* value = valeur fournie à intégrer ou prendre en compte. *
+* closure = non utilisé ici. *
+* *
+* Description : Définit si l'élément contient des données à oublier ou non. *
+* *
+* Retour : Bilan de l'opération pour Python. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static int py_db_item_set_volatile(PyObject *self, PyObject *value, void *closure)
+{
+ GDbItem *item; /* Elément à modifier */
+
+ if (!PyBool_Check(value))
+ {
+ PyErr_SetString(PyExc_TypeError, _("The attribute value must be a boolean."));
+ return -1;
+ }
+
+ item = G_DB_ITEM(pygobject_get(self));
+ g_db_item_set_volatile(item, (bool)(value == Py_True));
+
+ return 0;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Fournit un accès à une définition de type à diffuser. *
+* *
+* Retour : Définition d'objet pour Python. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+PyTypeObject *get_python_db_item_type(void)
+{
+ static PyMethodDef py_db_item_methods[] = {
+ { NULL }
+ };
+
+ static PyGetSetDef py_db_item_getseters[] = {
+
+ {
+ "volatile", py_db_item_get_volatile, py_db_item_set_volatile,
+ "Define if a Database item can be forgotten.", NULL
+ },
+ { NULL }
+
+ };
+
+ static PyTypeObject py_db_item_type = {
+
+ PyVarObject_HEAD_INIT(NULL, 0)
+
+ .tp_name = "pychrysalide.analysis.db.DbItem",
+ .tp_basicsize = sizeof(PyGObject),
+
+ .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+
+ .tp_doc = "PyChrysalide item for DataBase collection",
+
+ .tp_methods = py_db_item_methods,
+ .tp_getset = py_db_item_getseters,
+
+ };
+
+ return &py_db_item_type;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : module = module dont la définition est à compléter. *
+* *
+* Description : Prend en charge l'objet 'pychrysalide....db.items.DbItem'. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool register_python_db_item(PyObject *module)
+{
+ PyTypeObject *py_db_item_type; /* Type Python 'DbItem' */
+ PyObject *dict; /* Dictionnaire du module */
+
+ py_db_item_type = get_python_db_item_type();
+
+ dict = PyModule_GetDict(module);
+
+ if (!register_class_for_pygobject(dict, G_TYPE_DB_ITEM, py_db_item_type, &PyGObject_Type))
+ return false;
+
+ return true;
+
+}
diff --git a/plugins/pychrysalide/analysis/db/item.h b/plugins/pychrysalide/analysis/db/item.h
new file mode 100644
index 0000000..96122e6
--- /dev/null
+++ b/plugins/pychrysalide/analysis/db/item.h
@@ -0,0 +1,42 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * item.h - prototypes pour l'équivalent Python du fichier "analysis/db/item.h"
+ *
+ * Copyright (C) 2014-2017 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chrysalide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#ifndef _PLUGINS_PYCHRYSALIDE_ANALYSIS_DB_ITEM_H
+#define _PLUGINS_PYCHRYSALIDE_ANALYSIS_DB_ITEM_H
+
+
+#include <Python.h>
+#include <stdbool.h>
+
+
+
+/* Fournit un accès à une définition de type à diffuser. */
+PyTypeObject *get_python_db_item_type(void);
+
+/* Prend en charge l'objet 'pychrysalide.analysis.db.DbItem'. */
+bool register_python_db_item(PyObject *);
+
+
+
+#endif /* _PLUGINS_PYCHRYSALIDE_ANALYSIS_DB_ITEM_H */
diff --git a/plugins/pychrysalide/analysis/db/items/Makefile.am b/plugins/pychrysalide/analysis/db/items/Makefile.am
new file mode 100644
index 0000000..b08a558
--- /dev/null
+++ b/plugins/pychrysalide/analysis/db/items/Makefile.am
@@ -0,0 +1,14 @@
+
+noinst_LTLIBRARIES = libpychrysaanalysisdbitems.la
+
+libpychrysaanalysisdbitems_la_SOURCES = \
+ comment.h comment.c \
+ module.h module.c
+
+libpychrysaanalysisdbitems_la_LDFLAGS =
+
+
+AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) $(LIBPYTHON_CFLAGS) $(LIBPYGOBJECT_CFLAGS) \
+ -I../../../../../src
+
+AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS)
diff --git a/plugins/pychrysalide/analysis/db/items/comment.c b/plugins/pychrysalide/analysis/db/items/comment.c
new file mode 100644
index 0000000..28886f5
--- /dev/null
+++ b/plugins/pychrysalide/analysis/db/items/comment.c
@@ -0,0 +1,241 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * comment.c - équivalent Python du fichier "analysis/db/items/comment.c"
+ *
+ * Copyright (C) 2014-2017 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chrysalide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#include "comment.h"
+
+
+#include <malloc.h>
+#include <pygobject.h>
+
+
+#include <i18n.h>
+#include <analysis/db/items/comment.h>
+
+
+#include "../item.h"
+#include "../../../helpers.h"
+#include "../../../arch/vmpa.h"
+
+
+
+/* Crée un nouvel objet Python de type 'DbComment'. */
+static PyObject *py_db_comment_new(PyTypeObject *, PyObject *, PyObject *);
+
+/* Fournit le commentaire associé à un commentaire. */
+static PyObject *py_db_comment_get_text(PyObject *, void *);
+
+/* Définit le commentaire associé à un commentaire. */
+static int py_db_comment_set_text(PyObject *, PyObject *, void *);
+
+
+
+/******************************************************************************
+* *
+* Paramètres : type = type de l'objet à instancier. *
+* args = arguments fournis à l'appel. *
+* kwds = arguments de type key=val fournis. *
+* *
+* Description : Crée un nouvel objet Python de type 'DbComment'. *
+* *
+* Retour : Instance Python mise en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_db_comment_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ PyObject *result; /* Instance à retourner */
+ PyObject *py_vmpa; /* Localisation version Python */
+ const char *text; /* Texte à associer */
+ int is_volatile; /* Conservation en mémoire */
+ int ret; /* Bilan de lecture des args. */
+ vmpa2t *addr; /* Localisation version C */
+ GDbComment *comment; /* Version GLib du commentaire */
+
+ ret = PyArg_ParseTuple(args, "Osp", &py_vmpa, &text, &is_volatile);
+ if (!ret) Py_RETURN_NONE;
+
+ ret = PyObject_IsInstance(py_vmpa, (PyObject *)get_python_vmpa_type());
+ if (!ret) return NULL;
+
+ addr = get_internal_vmpa(py_vmpa);
+ if (py_vmpa == NULL) Py_RETURN_NONE;
+
+ return NULL;/* FIXME */
+ //comment = g_db_comment_new(addr, text, is_volatile);
+
+ result = pygobject_new(G_OBJECT(comment));
+ g_object_unref(comment);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : self = objet Python concerné par l'appel. *
+* closure = non utilisé ici. *
+* *
+* Description : Fournit le commentaire associé à un commentaire. *
+* *
+* Retour : Texte manipulable en Python. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_db_comment_get_text(PyObject *self, void *closure)
+{
+ PyObject *result; /* Résultat à retourner */
+ GDbComment *comment; /* Commentaire à consulter */
+ char *text; /* Contenu textuel associé */
+
+ comment = G_DB_COMMENT(pygobject_get(self));
+ text = g_db_comment_get_text(comment);
+
+ if (text == NULL)
+ {
+ result = Py_None;
+ Py_INCREF(result);
+ }
+ else
+ {
+ result = PyUnicode_FromString(text);
+ free(text);
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : self = objet Python concerné par l'appel. *
+* value = valeur fournie à intégrer ou prendre en compte. *
+* closure = non utilisé ici. *
+* *
+* Description : Définit le commentaire associé à un commentaire. *
+* *
+* Retour : Bilan de l'opération pour Python. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static int py_db_comment_set_text(PyObject *self, PyObject *value, void *closure)
+{
+ GDbComment *comment; /* Commentaire à consulter */
+
+ if (!PyUnicode_Check(value))
+ {
+ PyErr_SetString(PyExc_TypeError, _("The attribute value must be a string."));
+ return -1;
+ }
+
+ comment = G_DB_COMMENT(pygobject_get(self));
+ //g_db_comment_set_text(comment, PyUnicode_DATA(value));
+
+ return 0;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Fournit un accès à une définition de type à diffuser. *
+* *
+* Retour : Définition d'objet pour Python. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+PyTypeObject *get_python_db_comment_type(void)
+{
+ static PyMethodDef py_db_comment_methods[] = {
+ { NULL }
+ };
+
+ static PyGetSetDef py_db_comment_getseters[] = {
+ {
+ "text", py_db_comment_get_text, py_db_comment_set_text,
+ "Give access to the content of a given comment.", NULL
+ },
+ { NULL }
+ };
+
+ static PyTypeObject py_db_comment_type = {
+
+ PyVarObject_HEAD_INIT(NULL, 0)
+
+ .tp_name = "pychrysalide.analysis.db.items.DbComment",
+ .tp_basicsize = sizeof(PyGObject),
+
+ .tp_flags = Py_TPFLAGS_DEFAULT,
+
+ .tp_doc = "PyChrysalide comment for edited binary",
+
+ .tp_methods = py_db_comment_methods,
+ .tp_getset = py_db_comment_getseters,
+ .tp_new = (newfunc)py_db_comment_new
+
+ };
+
+ return &py_db_comment_type;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : module = module dont la définition est à compléter. *
+* *
+* Description : Prend en charge l'objet 'pychrysalide....db.items.DbComment'.*
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool register_python_db_comment(PyObject *module)
+{
+ PyTypeObject *py_db_comment_type; /* Type Python 'DbComment' */
+ PyObject *dict; /* Dictionnaire du module */
+
+ py_db_comment_type = get_python_db_comment_type();
+
+ dict = PyModule_GetDict(module);
+
+ if (!register_class_for_pygobject(dict, G_TYPE_DB_COMMENT, py_db_comment_type, get_python_db_item_type()))
+ return false;
+
+ return true;
+
+}
diff --git a/plugins/pychrysalide/analysis/db/items/comment.h b/plugins/pychrysalide/analysis/db/items/comment.h
new file mode 100644
index 0000000..2b4f130
--- /dev/null
+++ b/plugins/pychrysalide/analysis/db/items/comment.h
@@ -0,0 +1,42 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * comment.h - prototypes pour l'équivalent Python du fichier "analysis/db/items/comment.h"
+ *
+ * Copyright (C) 2014-2017 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chrysalide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#ifndef _PLUGINS_PYCHRYSALIDE_ANALYSIS_DB_ITEMS_COMMENT_H
+#define _PLUGINS_PYCHRYSALIDE_ANALYSIS_DB_ITEMS_COMMENT_H
+
+
+#include <Python.h>
+#include <stdbool.h>
+
+
+
+/* Fournit un accès à une définition de type à diffuser. */
+PyTypeObject *get_python_db_comment_type(void);
+
+/* Prend en charge l'objet 'pychrysalide.analysis.db.items.DbComment'. */
+bool register_python_db_comment(PyObject *);
+
+
+
+#endif /* _PLUGINS_PYCHRYSALIDE_ANALYSIS_DB_ITEMS_COMMENT_H */
diff --git a/plugins/pychrysalide/analysis/db/items/module.c b/plugins/pychrysalide/analysis/db/items/module.c
new file mode 100644
index 0000000..cf0fe56
--- /dev/null
+++ b/plugins/pychrysalide/analysis/db/items/module.c
@@ -0,0 +1,93 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * module.c - intégration du répertoire items en tant que module
+ *
+ * Copyright (C) 2014-2017 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chrysalide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#include "module.h"
+
+
+#include <assert.h>
+
+
+#include "comment.h"
+#include "../../../access.h"
+
+
+
+/******************************************************************************
+* *
+* Paramètres : module = module dont la définition est à compléter. *
+* *
+* Description : Ajoute le module 'items' au module Python. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool add_analysis_db_items_module_to_python_module(PyObject *super)
+{
+ bool result; /* Bilan à retourner */
+ PyObject *module; /* Sous-module mis en place */
+ int ret; /* Bilan d'un appel */
+
+ static PyModuleDef py_chrysalide_items_module = {
+
+ .m_base = PyModuleDef_HEAD_INIT,
+
+ .m_name = "pychrysalide.analysis.db.items",
+ .m_doc = "Python module for Chrysalide.analysis.db.items",
+
+ .m_size = -1,
+
+ };
+
+ result = false;
+
+ module = PyModule_Create(&py_chrysalide_items_module);
+ if (module == NULL) return false;
+
+ ret = PyState_AddModule(super, &py_chrysalide_items_module);
+ if (ret != 0) goto loading_failed;
+
+ ret = _PyImport_FixupBuiltin(module, "pychrysalide.analysis.db.items");
+ if (ret != 0) goto loading_failed;
+
+ Py_INCREF(module);
+ ret = PyModule_AddObject(super, "items", module);
+ if (ret != 0) goto loading_failed;
+
+ result = true;
+
+ result &= register_python_db_comment(module);
+
+ if (result)
+ register_access_to_python_module("pychrysalide.analysis.db.items", module);
+
+ loading_failed:
+
+ assert(result);
+
+ return result;
+
+}
diff --git a/plugins/pychrysalide/analysis/db/items/module.h b/plugins/pychrysalide/analysis/db/items/module.h
new file mode 100644
index 0000000..1382226
--- /dev/null
+++ b/plugins/pychrysalide/analysis/db/items/module.h
@@ -0,0 +1,39 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * module.h - prototypes pour l'intégration du répertoire items en tant que module
+ *
+ * Copyright (C) 2014-2017 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chrysalide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#ifndef _PLUGINS_PYCHRYSALIDE_ANALYSIS_DB_ITEMS_MODULE_H
+#define _PLUGINS_PYCHRYSALIDE_ANALYSIS_DB_ITEMS_MODULE_H
+
+
+#include <Python.h>
+#include <stdbool.h>
+
+
+
+/* Ajoute le module 'items' au module Python. */
+bool add_analysis_db_items_module_to_python_module(PyObject *);
+
+
+
+#endif /* _PLUGINS_PYCHRYSALIDE_ANALYSIS_DB_ITEMS_MODULE_H */
diff --git a/plugins/pychrysalide/analysis/db/module.c b/plugins/pychrysalide/analysis/db/module.c
new file mode 100644
index 0000000..1c4da25
--- /dev/null
+++ b/plugins/pychrysalide/analysis/db/module.c
@@ -0,0 +1,100 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * module.c - intégration du répertoire db en tant que module
+ *
+ * Copyright (C) 2014-2017 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chrysalide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#include "module.h"
+
+
+#include <assert.h>
+
+
+#include "certs.h"
+#include "collection.h"
+#include "item.h"
+#include "items/module.h"
+#include "../../access.h"
+
+
+
+/******************************************************************************
+* *
+* Paramètres : module = module dont la définition est à compléter. *
+* *
+* Description : Ajoute le module 'db' au module Python. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool add_analysis_db_module_to_python_module(PyObject *super)
+{
+ bool result; /* Bilan à retourner */
+ PyObject *module; /* Sous-module mis en place */
+ int ret; /* Bilan d'un appel */
+
+ static PyModuleDef py_chrysalide_db_module = {
+
+ .m_base = PyModuleDef_HEAD_INIT,
+
+ .m_name = "pychrysalide.analysis.db",
+ .m_doc = "Python module for Chrysalide.analysis.db",
+
+ .m_size = -1,
+
+ };
+
+ result = false;
+
+ module = PyModule_Create(&py_chrysalide_db_module);
+ if (module == NULL) return false;
+
+ ret = PyState_AddModule(super, &py_chrysalide_db_module);
+ if (ret != 0) goto loading_failed;
+
+ ret = _PyImport_FixupBuiltin(module, "pychrysalide.analysis.db");
+ if (ret != 0) goto loading_failed;
+
+ Py_INCREF(module);
+ ret = PyModule_AddObject(super, "db", module);
+ if (ret != 0) goto loading_failed;
+
+ result = true;
+
+ result &= register_python_certs(module);
+ result &= register_python_db_collection(module);
+ result &= register_python_db_item(module);
+
+ result &= add_analysis_db_items_module_to_python_module(module);
+
+ if (result)
+ register_access_to_python_module("pychrysalide.analysis.db", module);
+
+ loading_failed:
+
+ assert(result);
+
+ return result;
+
+}
diff --git a/plugins/pychrysalide/analysis/db/module.h b/plugins/pychrysalide/analysis/db/module.h
new file mode 100644
index 0000000..d545ecb
--- /dev/null
+++ b/plugins/pychrysalide/analysis/db/module.h
@@ -0,0 +1,39 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * module.h - prototypes pour l'intégration du répertoire db en tant que module
+ *
+ * Copyright (C) 2014-2017 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chrysalide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#ifndef _PLUGINS_PYCHRYSALIDE_ANALYSIS_DB_MODULE_H
+#define _PLUGINS_PYCHRYSALIDE_ANALYSIS_DB_MODULE_H
+
+
+#include <Python.h>
+#include <stdbool.h>
+
+
+
+/* Ajoute le module 'db' au module Python. */
+bool add_analysis_db_module_to_python_module(PyObject *);
+
+
+
+#endif /* _PLUGINS_PYCHRYSALIDE_ANALYSIS_DB_MODULE_H */