diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2023-08-18 00:07:39 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2023-08-18 00:07:39 (GMT) |
commit | 2424c52c4f3bc44ce5f36348442cfa103e0989c2 (patch) | |
tree | f68aea488f403b234d4fcc6fd6e0f7b88a628ac8 /src/analysis/scan/pattern.c | |
parent | 1c5a0e67186def152536d9c506e2e6c3a3a265c5 (diff) |
Create some modifiers and handle match properties inside ROST.
Diffstat (limited to 'src/analysis/scan/pattern.c')
-rw-r--r-- | src/analysis/scan/pattern.c | 111 |
1 files changed, 104 insertions, 7 deletions
diff --git a/src/analysis/scan/pattern.c b/src/analysis/scan/pattern.c index 53a2662..5b966d2 100644 --- a/src/analysis/scan/pattern.c +++ b/src/analysis/scan/pattern.c @@ -186,25 +186,122 @@ void g_search_pattern_set_name(GSearchPattern *pattern, const char *name, size_t /****************************************************************************** * * -* Paramètres : pattern = définition de motif à consulter. * +* Paramètres : pattern = définition de motif à considérer. * +* context = contexte de l'analyse à mener. * +* fd = canal d'écriture. * * * -* Description : Décompte le nombre de correspondances identifiées. * +* Description : Affiche un motif de recherche au format texte. * * * -* Retour : Quantité d'identifications réalisées. * +* Retour : - * * * * Remarques : - * * * ******************************************************************************/ -size_t g_search_pattern_count_matchs(const GSearchPattern *pattern) +void g_search_pattern_output_to_text(const GSearchPattern *pattern, GScanContext *context, int fd) { - size_t result; /* Décompte à retourner */ GSearchPatternClass *class; /* Classe à activer */ class = G_SEARCH_PATTERN_GET_CLASS(pattern); - result = 0;//class->count(pattern); + class->to_text(pattern, context, fd); - return result; +} + + +/****************************************************************************** +* * +* Paramètres : pattern = définition de motif à considérer. * +* context = contexte de l'analyse à mener. * +* * +* Description : Convertit un motif de recherche en texte. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void g_search_pattern_convert_as_text(const GSearchPattern *pattern, GScanContext *context) +{ + +} + + +/****************************************************************************** +* * +* Paramètres : pattern = définition de motif à considérer. * +* context = contexte de l'analyse à mener. * +* padding = éventuel bourrage initial à placer ou NULL. * +* level = profondeur actuelle. * +* fd = canal d'écriture. * +* trailing = impose une virgule finale ? * +* * +* Description : Affiche un motif de recherche au format JSON. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void g_search_pattern_output_to_json(const GSearchPattern *pattern, GScanContext *context, const sized_string_t *padding, unsigned int level, int fd, bool trailing) +{ + unsigned int i; /* Boucle de parcours */ + GSearchPatternClass *class; /* Classe à activer */ + + /* Introduction */ + + for (i = 0; i < level; i++) + write(fd, padding->data, padding->len); + + write(fd, "{\n", 2); + + /* Désignation du motif */ + + for (i = 0; i < (level + 1); i++) + write(fd, padding->data, padding->len); + + write(fd, "\"name\": \"$", 10); + + write(fd, pattern->name, strlen(pattern->name)); + + write(fd, "\",\n", 3); + + /* Affichage du contenu */ + + class = G_SEARCH_PATTERN_GET_CLASS(pattern); + + class->to_json(pattern, context, padding, level + 1, fd); + + /* Conclusion */ + + for (i = 0; i < level; i++) + write(fd, padding->data, padding->len); + + if (trailing) + write(fd, "},\n", 3); + else + write(fd, "}\n", 2); + +} + + +/****************************************************************************** +* * +* Paramètres : pattern = définition de motif à considérer. * +* context = contexte de l'analyse à mener. * +* * +* Description : Convertit un motif de recherche en JSON. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void g_search_pattern_convert_as_json(const GSearchPattern *pattern, GScanContext *context) +{ + /* TODO */ } |