diff options
Diffstat (limited to 'src/analysis/scan/patterns')
-rw-r--r-- | src/analysis/scan/patterns/token.c | 66 | ||||
-rw-r--r-- | src/analysis/scan/patterns/token.h | 2 |
2 files changed, 26 insertions, 42 deletions
diff --git a/src/analysis/scan/patterns/token.c b/src/analysis/scan/patterns/token.c index 76a5e66..b3c6d53 100644 --- a/src/analysis/scan/patterns/token.c +++ b/src/analysis/scan/patterns/token.c @@ -300,6 +300,7 @@ bool g_bytes_token_build_id(GBytesToken *token, GEngineBackend *backend) * * * Paramètres : token = définition de la bribe à manipuler. * * matches = suivi des correspondances à consolider. * +* params = paramètres des opérations de validation. * * * * Description : Transforme les correspondances locales en trouvailles. * * * @@ -309,83 +310,70 @@ bool g_bytes_token_build_id(GBytesToken *token, GEngineBackend *backend) * * ******************************************************************************/ -void g_bytes_token_check(const GBytesToken *token, GScanBytesMatches *matches) +void g_bytes_token_check(const GBytesToken *token, GScanBytesMatches *matches, scan_node_check_params_t *params) { - scan_node_check_params_t params; /* Rassemblement de paramètres */ - vmpa2t start; /* Point de début du contenu */ - vmpa2t end; /* Point de fin du contenu */ match_area_t *area; /* Correspondance à valider */ match_area_t *next; /* Correspondance suivante */ vmpa2t pos; /* Tête de lecture */ const bin_t *byte; /* Octet à valider */ - /* Définition d'un contexte */ + /* Réinitialisation */ - params.context = g_scan_bytes_matches_get_context(matches); - params.content = g_scan_context_get_content(params.context); - params.allocator = g_umem_slice_new(sizeof(match_area_t)); + // TODO: offset - g_binary_content_compute_start_pos(params.content, &start); - g_binary_content_compute_end_pos(params.content, &end); + params->initialized = false; - params.content_start = start.physical; - params.content_end = end.physical; + params->main_areas = NULL; + params->main_count = 0; - // offset + params->created_areas = NULL; + params->created_count = 0; - params.initialized = false; - - params.main_areas = NULL; - params.main_count = 0; - - params.created_areas = NULL; - params.created_count = 0; - - params.kept_areas = NULL; - params.kept_count = 0; + params->kept_areas = NULL; + params->kept_count = 0; /* Lancement des analyses */ - g_scan_token_node_check_forward(token->root, ¶ms); + g_scan_token_node_check_forward(token->root, params); if (token->need_backward) - g_scan_token_node_check_backward(token->root, ¶ms); + g_scan_token_node_check_backward(token->root, params); // REMME ? sort_and_filter_pending_matches(matches); if (token->fullword) { - for_each_match_area_safe(area, ¶ms.main_areas, next) + for_each_match_area_safe(area, ¶ms->main_areas, next) { /* Validation de l'octet précédent, s'il existe */ - if (area->start > params.content_start) + if (area->start > params->content_start) { init_vmpa(&pos, area->start - 1, VMPA_NO_VIRTUAL); - byte = g_binary_content_get_raw_access(params.content, &pos, 1); + byte = g_binary_content_get_raw_access(params->content, &pos, 1); if (isalnum(*byte)) { - del_match_area(area, ¶ms.main_areas); - assert(¶ms.main_count > 0); - params.main_count--; + del_match_area(area, ¶ms->main_areas); + assert(¶ms->main_count > 0); + params->main_count--; continue; } } /* Validation de l'octet suivant, s'il existe */ - if (area->end < params.content_end) + if (area->end < params->content_end) { init_vmpa(&pos, area->end, VMPA_NO_VIRTUAL); - byte = g_binary_content_get_raw_access(params.content, &pos, 1); + byte = g_binary_content_get_raw_access(params->content, &pos, 1); if (isalnum(*byte)) { - del_match_area(area, ¶ms.main_areas); - assert(¶ms.main_count > 0); - params.main_count--; + del_match_area(area, ¶ms->main_areas); + assert(¶ms->main_count > 0); + params->main_count--; continue; } @@ -395,11 +383,7 @@ void g_bytes_token_check(const GBytesToken *token, GScanBytesMatches *matches) } - g_scan_bytes_matches_set_list(matches, params.main_areas, params.main_count); - - g_object_unref(G_OBJECT(params.context)); - g_object_unref(G_OBJECT(params.content)); - //g_object_unref(G_OBJECT(params.allocator)); + g_scan_bytes_matches_set_list(matches, params->main_areas, params->main_count); } diff --git a/src/analysis/scan/patterns/token.h b/src/analysis/scan/patterns/token.h index 3bc5cb7..f5b78f6 100644 --- a/src/analysis/scan/patterns/token.h +++ b/src/analysis/scan/patterns/token.h @@ -65,7 +65,7 @@ bool g_bytes_token_enroll(GBytesToken *, GEngineBackend *, size_t); bool g_bytes_token_build_id(GBytesToken *, GEngineBackend *); /* Transforme les correspondances locales en trouvailles. */ -void g_bytes_token_check(const GBytesToken *, GScanBytesMatches *); +void g_bytes_token_check(const GBytesToken *, GScanBytesMatches *, scan_node_check_params_t *); /* Retrouve l'origine d'une correspondance à partir d'un indice. */ char *g_bytes_token_get_modifier_path(const GBytesToken *, size_t); |