diff options
Diffstat (limited to 'src/analysis/db/analyst.c')
-rw-r--r-- | src/analysis/db/analyst.c | 48 |
1 files changed, 36 insertions, 12 deletions
diff --git a/src/analysis/db/analyst.c b/src/analysis/db/analyst.c index 49585c2..ab12cc1 100644 --- a/src/analysis/db/analyst.c +++ b/src/analysis/db/analyst.c @@ -40,7 +40,10 @@ struct _GAnalystClient { GHubClient parent; /* A laisser en premier */ - char *hash; /* Empreinte du binaire lié */ + char *cnt_hash; /* Empreinte du binaire lié */ + char *cnt_class; /* Interprétation du contenu */ + + GLoadedContent *loaded; /* Contenu chargé */ GList *collections; /* Collections d'un binaire */ bool can_get_updates; /* Réception de maj possibles ?*/ @@ -159,7 +162,10 @@ static void g_analyst_client_class_init(GAnalystClientClass *klass) static void g_analyst_client_init(GAnalystClient *client) { - client->hash = NULL; + client->cnt_hash = NULL; + client->cnt_class = NULL; + + client->loaded = NULL; client->collections = NULL; client->can_get_updates = false; @@ -195,6 +201,8 @@ static void g_analyst_client_dispose(GAnalystClient *client) g_mutex_clear(&client->snap_lock); + g_clear_object(&client->loaded); + G_OBJECT_CLASS(g_analyst_client_parent_class)->dispose(G_OBJECT(client)); } @@ -216,8 +224,11 @@ static void g_analyst_client_finalize(GAnalystClient *client) { size_t i; /* Boucle de parcours */ - if (client->hash != NULL) - free(client->hash); + if (client->cnt_hash != NULL) + free(client->cnt_hash); + + if (client->cnt_class != NULL) + free(client->cnt_class); if (client->snapshots != NULL) { @@ -236,7 +247,9 @@ static void g_analyst_client_finalize(GAnalystClient *client) /****************************************************************************** * * * Paramètres : hash = empreinte d'un binaire en cours d'analyse. * +* class = nature de l'interprétation de ce contenu. * * collections = ensemble de collections existantes. * +* loaded = éventuel élément local préchargé. * * * * Description : Prépare un client pour une connexion à une BD. * * * @@ -246,13 +259,18 @@ static void g_analyst_client_finalize(GAnalystClient *client) * * ******************************************************************************/ -GAnalystClient *g_analyst_client_new(const char *hash, GList *collections) +GAnalystClient *g_analyst_client_new(const char *hash, const char *class, GList *collections, GLoadedContent *loaded) { GAnalystClient *result; /* Adresse à retourner */ result = g_object_new(G_TYPE_ANALYST_CLIENT, NULL); - result->hash = strdup(hash); + result->cnt_hash = strdup(hash); + result->cnt_class = strdup(class); + + result->loaded = loaded; + if (loaded != NULL) g_object_ref(G_OBJECT(loaded)); + result->collections = collections; return result; @@ -278,7 +296,13 @@ static bool g_analyst_client_complete_hello(GAnalystClient *client, packed_buffe bool result; /* Bilan à retourner */ rle_string str; /* Chaîne à communiquer */ - init_static_rle_string(&str, client->hash); + init_static_rle_string(&str, client->cnt_hash); + + result = pack_rle_string(&str, pbuf); + + exit_rle_string(&str); + + init_static_rle_string(&str, client->cnt_class); result = pack_rle_string(&str, pbuf); @@ -414,10 +438,10 @@ static void *g_analyst_client_update(GAnalystClient *client) error = tmp32; if (error == DBE_NONE) - log_variadic_message(LMT_INFO, _("Archive saved for binary '%s'"), client->hash); + log_variadic_message(LMT_INFO, _("Archive saved for binary '%s'"), client->cnt_hash); else log_variadic_message(LMT_ERROR, _("Failed to save the archive for binary '%s'"), - client->hash); + client->cnt_hash); break; @@ -669,10 +693,10 @@ bool g_analyst_client_send_content(GAnalystClient *client, GBinContent *content) hash = g_binary_content_get_checksum(content); - if (strcmp(hash, client->hash) != 0) + if (strcmp(hash, client->cnt_hash) != 0) { log_variadic_message(LMT_ERROR, _("Provided ontent does not match client content (hash: '%s')"), - client->hash); + client->cnt_hash); goto exit; } @@ -680,7 +704,7 @@ bool g_analyst_client_send_content(GAnalystClient *client, GBinContent *content) init_packed_buffer(&cnt_pbuf); - storage = g_object_storage_new(client->hash); + storage = g_object_storage_new(client->cnt_hash); result = g_object_storage_store_object(storage, "contents", G_SERIALIZABLE_OBJECT(content), &pos); if (!result) goto exit_with_failure; |