summaryrefslogtreecommitdiff
path: root/src/analysis
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2023-10-05 07:03:16 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2023-10-05 07:03:16 (GMT)
commit1e28e6b94d5561129162d760d99bcf1e81f9528c (patch)
treedf531593c73732f130b9ea5edeff53602042ca54 /src/analysis
parent7464e2bf0ba5469e20eef5f16643ab6043b0179e (diff)
Rename search tokens from "string" to "bytes".
Diffstat (limited to 'src/analysis')
-rw-r--r--src/analysis/scan/patterns/token-int.h6
-rw-r--r--src/analysis/scan/patterns/token.c52
-rw-r--r--src/analysis/scan/patterns/token.h26
-rw-r--r--src/analysis/scan/patterns/tokens/hex-int.h4
-rw-r--r--src/analysis/scan/patterns/tokens/hex.c4
-rw-r--r--src/analysis/scan/patterns/tokens/node.c1
-rw-r--r--src/analysis/scan/patterns/tokens/plain-int.h4
-rw-r--r--src/analysis/scan/patterns/tokens/plain.c4
-rw-r--r--src/analysis/scan/rule.c6
9 files changed, 54 insertions, 53 deletions
diff --git a/src/analysis/scan/patterns/token-int.h b/src/analysis/scan/patterns/token-int.h
index f1d63f0..7ba0aa4 100644
--- a/src/analysis/scan/patterns/token-int.h
+++ b/src/analysis/scan/patterns/token-int.h
@@ -33,7 +33,7 @@
/* Encadrement d'une bribe de recherche textuelle (instance) */
-struct _GStringToken
+struct _GBytesToken
{
GSearchPattern parent; /* A laisser en premier */
@@ -47,7 +47,7 @@ struct _GStringToken
};
/* Encadrement d'une bribe de recherche textuelle (classe) */
-struct _GStringTokenClass
+struct _GBytesTokenClass
{
GSearchPatternClass parent; /* A laisser en premier */
@@ -55,7 +55,7 @@ struct _GStringTokenClass
/* Met en place un gestionnaire de recherche de binaire. */
-bool g_string_token_create(GStringToken *, GScanTokenNode *, bool, bool);
+bool g_bytes_token_create(GBytesToken *, GScanTokenNode *, bool, bool);
diff --git a/src/analysis/scan/patterns/token.c b/src/analysis/scan/patterns/token.c
index f44680c..8b3a843 100644
--- a/src/analysis/scan/patterns/token.c
+++ b/src/analysis/scan/patterns/token.c
@@ -39,16 +39,16 @@
/* Initialise la classe des bribes de recherche textuelle. */
-static void g_string_token_class_init(GStringTokenClass *);
+static void g_bytes_token_class_init(GBytesTokenClass *);
/* Initialise une instance de bribe de recherche textuelle. */
-static void g_string_token_init(GStringToken *);
+static void g_bytes_token_init(GBytesToken *);
/* Supprime toutes les références externes. */
-static void g_string_token_dispose(GStringToken *);
+static void g_bytes_token_dispose(GBytesToken *);
/* Procède à la libération totale de la mémoire. */
-static void g_string_token_finalize(GStringToken *);
+static void g_bytes_token_finalize(GBytesToken *);
@@ -56,10 +56,10 @@ static void g_string_token_finalize(GStringToken *);
/* Affiche un motif de recherche au format texte. */
-static void g_string_token_output_to_text(const GStringToken *, GScanContext *, int);
+static void g_bytes_token_output_to_text(const GBytesToken *, GScanContext *, int);
/* Affiche un motif de recherche au format JSON. */
-static void g_string_token_output_to_json(const GStringToken *, GScanContext *, const sized_string_t *, unsigned int, int);
+static void g_bytes_token_output_to_json(const GBytesToken *, GScanContext *, const sized_string_t *, unsigned int, int);
@@ -69,7 +69,7 @@ static void g_string_token_output_to_json(const GStringToken *, GScanContext *,
/* Indique le type défini pour une bribe de recherche textuelle. */
-G_DEFINE_TYPE(GStringToken, g_string_token, G_TYPE_SEARCH_PATTERN);
+G_DEFINE_TYPE(GBytesToken, g_bytes_token, G_TYPE_SEARCH_PATTERN);
/******************************************************************************
@@ -84,20 +84,20 @@ G_DEFINE_TYPE(GStringToken, g_string_token, G_TYPE_SEARCH_PATTERN);
* *
******************************************************************************/
-static void g_string_token_class_init(GStringTokenClass *klass)
+static void g_bytes_token_class_init(GBytesTokenClass *klass)
{
GObjectClass *object; /* Autre version de la classe */
GSearchPatternClass *pattern; /* Version de classe parente */
object = G_OBJECT_CLASS(klass);
- object->dispose = (GObjectFinalizeFunc/* ! */)g_string_token_dispose;
- object->finalize = (GObjectFinalizeFunc)g_string_token_finalize;
+ object->dispose = (GObjectFinalizeFunc/* ! */)g_bytes_token_dispose;
+ object->finalize = (GObjectFinalizeFunc)g_bytes_token_finalize;
pattern = G_SEARCH_PATTERN_CLASS(klass);
- pattern->to_text = (output_pattern_to_text_fc)g_string_token_output_to_text;
- pattern->to_json = (output_pattern_to_json_fc)g_string_token_output_to_json;
+ pattern->to_text = (output_pattern_to_text_fc)g_bytes_token_output_to_text;
+ pattern->to_json = (output_pattern_to_json_fc)g_bytes_token_output_to_json;
}
@@ -114,7 +114,7 @@ static void g_string_token_class_init(GStringTokenClass *klass)
* *
******************************************************************************/
-static void g_string_token_init(GStringToken *token)
+static void g_bytes_token_init(GBytesToken *token)
{
token->root = NULL;
token->slow = 0;
@@ -138,9 +138,9 @@ static void g_string_token_init(GStringToken *token)
* *
******************************************************************************/
-static void g_string_token_dispose(GStringToken *token)
+static void g_bytes_token_dispose(GBytesToken *token)
{
- G_OBJECT_CLASS(g_string_token_parent_class)->dispose(G_OBJECT(token));
+ G_OBJECT_CLASS(g_bytes_token_parent_class)->dispose(G_OBJECT(token));
}
@@ -157,9 +157,9 @@ static void g_string_token_dispose(GStringToken *token)
* *
******************************************************************************/
-static void g_string_token_finalize(GStringToken *token)
+static void g_bytes_token_finalize(GBytesToken *token)
{
- G_OBJECT_CLASS(g_string_token_parent_class)->finalize(G_OBJECT(token));
+ G_OBJECT_CLASS(g_bytes_token_parent_class)->finalize(G_OBJECT(token));
}
@@ -179,7 +179,7 @@ static void g_string_token_finalize(GStringToken *token)
* *
******************************************************************************/
-bool g_string_token_create(GStringToken *token, GScanTokenNode *root, bool fullword, bool private)
+bool g_bytes_token_create(GBytesToken *token, GScanTokenNode *root, bool fullword, bool private)
{
bool result; /* Bilan à retourner */
@@ -208,7 +208,7 @@ bool g_string_token_create(GStringToken *token, GScanTokenNode *root, bool fullw
* *
******************************************************************************/
-bool g_string_token_target_fullword(const GStringToken *token)
+bool g_bytes_token_target_fullword(const GBytesToken *token)
{
bool result; /* Statut à renvoyer */
@@ -231,7 +231,7 @@ bool g_string_token_target_fullword(const GStringToken *token)
* *
******************************************************************************/
-bool g_string_token_is_private(const GStringToken *token)
+bool g_bytes_token_is_private(const GBytesToken *token)
{
bool result; /* Statut à renvoyer */
@@ -257,7 +257,7 @@ bool g_string_token_is_private(const GStringToken *token)
* *
******************************************************************************/
-bool g_string_token_enroll(GStringToken *token, GScanContext *context, GEngineBackend *backend, size_t maxsize)
+bool g_bytes_token_enroll(GBytesToken *token, GScanContext *context, GEngineBackend *backend, size_t maxsize)
{
bool result; /* Statut à retourner */
@@ -285,7 +285,7 @@ bool g_string_token_enroll(GStringToken *token, GScanContext *context, GEngineBa
* *
******************************************************************************/
-void g_string_token_check(const GStringToken *token, GScanContext *context, GBinContent *content, pending_matches_t *matches)
+void g_bytes_token_check(const GBytesToken *token, GScanContext *context, GBinContent *content, pending_matches_t *matches)
{
size_t p; /* Boucle de parcours #3 */
match_area_t *pending; /* Correspondance à traiter */
@@ -362,13 +362,13 @@ void g_string_token_check(const GStringToken *token, GScanContext *context, GBin
* *
******************************************************************************/
-static void g_string_token_output_to_text(const GStringToken *pattern, GScanContext *context, int fd)
+static void g_bytes_token_output_to_text(const GBytesToken *pattern, GScanContext *context, int fd)
{
const GScanMatch **matches; /* Correspondances établies */
size_t count; /* Quantité de cette liste */
size_t i; /* Boucle de parcours */
- if (g_string_token_is_private(pattern))
+ if (g_bytes_token_is_private(pattern))
return;
matches = g_scan_context_get_full_matches(context, G_SEARCH_PATTERN(pattern), &count);
@@ -395,7 +395,7 @@ static void g_string_token_output_to_text(const GStringToken *pattern, GScanCont
* *
******************************************************************************/
-static void g_string_token_output_to_json(const GStringToken *pattern, GScanContext *context, const sized_string_t *padding, unsigned int level, int fd)
+static void g_bytes_token_output_to_json(const GBytesToken *pattern, GScanContext *context, const sized_string_t *padding, unsigned int level, int fd)
{
unsigned int i; /* Boucle de parcours #1 */
const GScanMatch **matches; /* Correspondances établies */
@@ -405,7 +405,7 @@ static void g_string_token_output_to_json(const GStringToken *pattern, GScanCont
size_t k; /* Boucle de parcours #2 */
bool trailing; /* Virgule finale */
- if (g_string_token_is_private(pattern))
+ if (g_bytes_token_is_private(pattern))
return;
matches = g_scan_context_get_full_matches(context, G_SEARCH_PATTERN(pattern), &count);
diff --git a/src/analysis/scan/patterns/token.h b/src/analysis/scan/patterns/token.h
index b361ecc..a71e367 100644
--- a/src/analysis/scan/patterns/token.h
+++ b/src/analysis/scan/patterns/token.h
@@ -34,35 +34,35 @@
-#define G_TYPE_STRING_TOKEN g_string_token_get_type()
-#define G_STRING_TOKEN(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_STRING_TOKEN, GStringToken))
-#define G_IS_STRING_TOKEN(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_STRING_TOKEN))
-#define G_STRING_TOKEN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_STRING_TOKEN, GStringTokenClass))
-#define G_IS_STRING_TOKEN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_STRING_TOKEN))
-#define G_STRING_TOKEN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_STRING_TOKEN, GStringTokenClass))
+#define G_TYPE_BYTES_TOKEN g_bytes_token_get_type()
+#define G_BYTES_TOKEN(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_BYTES_TOKEN, GBytesToken))
+#define G_IS_BYTES_TOKEN(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_BYTES_TOKEN))
+#define G_BYTES_TOKEN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_BYTES_TOKEN, GBytesTokenClass))
+#define G_IS_BYTES_TOKEN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_BYTES_TOKEN))
+#define G_BYTES_TOKEN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_BYTES_TOKEN, GBytesTokenClass))
/* Encadrement d'une bribe de recherche textuelle (instance) */
-typedef struct _GStringToken GStringToken;
+typedef struct _GBytesToken GBytesToken;
/* Encadrement d'une bribe de recherche textuelle (classe) */
-typedef struct _GStringTokenClass GStringTokenClass;
+typedef struct _GBytesTokenClass GBytesTokenClass;
/* Indique le type défini pour une bribe de recherche textuelle. */
-GType g_string_token_get_type(void);
+GType g_bytes_token_get_type(void);
/* Indique si seuls des mots entiers sont retenus des analyses. */
-bool g_string_token_target_fullword(const GStringToken *);
+bool g_bytes_token_target_fullword(const GBytesToken *);
/* Détermine si le gestionnaire est à vocation privée. */
-bool g_string_token_is_private(const GStringToken *);
+bool g_bytes_token_is_private(const GBytesToken *);
/* Inscrit la définition d'un motif dans un moteur de recherche. */
-bool g_string_token_enroll(GStringToken *, GScanContext *, GEngineBackend *, size_t);
+bool g_bytes_token_enroll(GBytesToken *, GScanContext *, GEngineBackend *, size_t);
/* Transforme les correspondances locales en trouvailles. */
-void g_string_token_check(const GStringToken *, GScanContext *, GBinContent *, pending_matches_t *);
+void g_bytes_token_check(const GBytesToken *, GScanContext *, GBinContent *, pending_matches_t *);
diff --git a/src/analysis/scan/patterns/tokens/hex-int.h b/src/analysis/scan/patterns/tokens/hex-int.h
index 440f693..dca9848 100644
--- a/src/analysis/scan/patterns/tokens/hex-int.h
+++ b/src/analysis/scan/patterns/tokens/hex-int.h
@@ -36,14 +36,14 @@
/* Encadrement d'une recherche de morceaux de binaire (instance) */
struct _GScanHexBytes
{
- GStringToken parent; /* A laisser en premier */
+ GBytesToken parent; /* A laisser en premier */
};
/* Encadrement d'une recherche de morceaux de binaire (classe) */
struct _GScanHexBytesClass
{
- GStringTokenClass parent; /* A laisser en premier */
+ GBytesTokenClass parent; /* A laisser en premier */
};
diff --git a/src/analysis/scan/patterns/tokens/hex.c b/src/analysis/scan/patterns/tokens/hex.c
index 1fda597..89d7ca4 100644
--- a/src/analysis/scan/patterns/tokens/hex.c
+++ b/src/analysis/scan/patterns/tokens/hex.c
@@ -66,7 +66,7 @@ static void g_scan_hex_bytes_output_to_json(const GScanHexBytes *, GScanContext
/* Indique le type défini pour une suite d'octets à retrouver dans un binaire. */
-G_DEFINE_TYPE(GScanHexBytes, g_scan_hex_bytes, G_TYPE_STRING_TOKEN);
+G_DEFINE_TYPE(GScanHexBytes, g_scan_hex_bytes, G_TYPE_BYTES_TOKEN);
/******************************************************************************
@@ -200,7 +200,7 @@ bool g_scan_hex_bytes_create(GScanHexBytes *bytes, GScanTokenNode *root, bool pr
{
bool result; /* Bilan à retourner */
- result = g_string_token_create(G_STRING_TOKEN(bytes), root, false, private);
+ result = g_bytes_token_create(G_BYTES_TOKEN(bytes), root, false, private);
return result;
diff --git a/src/analysis/scan/patterns/tokens/node.c b/src/analysis/scan/patterns/tokens/node.c
index cdbad4f..604cf86 100644
--- a/src/analysis/scan/patterns/tokens/node.c
+++ b/src/analysis/scan/patterns/tokens/node.c
@@ -253,6 +253,7 @@ bool g_scan_token_node_setup_tree(GScanTokenNode *node)
/* Phase d'application */
+ // TODO : REMME
//g_scan_token_node_set_flags(points.first_node, STNF_FIRST);
//g_scan_token_node_set_flags(points.last_node, STNF_LAST);
diff --git a/src/analysis/scan/patterns/tokens/plain-int.h b/src/analysis/scan/patterns/tokens/plain-int.h
index 5748160..b0ef106 100644
--- a/src/analysis/scan/patterns/tokens/plain-int.h
+++ b/src/analysis/scan/patterns/tokens/plain-int.h
@@ -36,14 +36,14 @@
/* Encadrement d'une recherche de texte brut (instance) */
struct _GScanPlainBytes
{
- GStringToken parent; /* A laisser en premier */
+ GBytesToken parent; /* A laisser en premier */
};
/* Encadrement d'une recherche de texte brut (classe) */
struct _GScanPlainBytesClass
{
- GStringTokenClass parent; /* A laisser en premier */
+ GBytesTokenClass parent; /* A laisser en premier */
};
diff --git a/src/analysis/scan/patterns/tokens/plain.c b/src/analysis/scan/patterns/tokens/plain.c
index 2eb6bbc..3d6c39d 100644
--- a/src/analysis/scan/patterns/tokens/plain.c
+++ b/src/analysis/scan/patterns/tokens/plain.c
@@ -67,7 +67,7 @@ static void g_scan_plain_bytes_output_to_json(const GScanPlainBytes *, GScanCont
/* Indique le type défini pour une suite d'octets à retrouver dans un binaire. */
-G_DEFINE_TYPE(GScanPlainBytes, g_scan_plain_bytes, G_TYPE_STRING_TOKEN);
+G_DEFINE_TYPE(GScanPlainBytes, g_scan_plain_bytes, G_TYPE_BYTES_TOKEN);
/******************************************************************************
@@ -207,7 +207,7 @@ bool g_scan_plain_bytes_create(GScanPlainBytes *bytes, GScanTokenNode *root)
fullword = (flags & SPNF_FULLWORD);
private = (flags & SPNF_PRIVATE);
- result = g_string_token_create(G_STRING_TOKEN(bytes), root, fullword, private);
+ result = g_bytes_token_create(G_BYTES_TOKEN(bytes), root, fullword, private);
return result;
diff --git a/src/analysis/scan/rule.c b/src/analysis/scan/rule.c
index 60842c2..77a05b4 100644
--- a/src/analysis/scan/rule.c
+++ b/src/analysis/scan/rule.c
@@ -342,7 +342,7 @@ const char * const *g_scan_rule_list_tags(const GScanRule *rule, size_t *count)
void g_scan_rule_add_local_variable(GScanRule *rule, GSearchPattern *pattern)
{
- if (G_IS_STRING_TOKEN(pattern))
+ if (G_IS_BYTES_TOKEN(pattern))
{
if (rule->bytes_used == rule->bytes_allocated)
{
@@ -553,7 +553,7 @@ bool g_scan_rule_setup_backend(GScanRule *rule, GEngineBackend *backend, GScanCo
for (i = 0; i < rule->bytes_used && result; i++)
{
pattern = rule->bytes_locals[i];
- result = g_string_token_enroll(G_STRING_TOKEN(pattern), context, backend, maxsize);
+ result = g_bytes_token_enroll(G_BYTES_TOKEN(pattern), context, backend, maxsize);
}
g_engine_backend_warm_up(backend);
@@ -614,7 +614,7 @@ void g_scan_rule_check(GScanRule *rule, GEngineBackend *backend, GScanContext *c
pattern = rule->bytes_locals[i];
- g_string_token_check(G_STRING_TOKEN(pattern), context, content, &matches);
+ g_bytes_token_check(G_BYTES_TOKEN(pattern), context, content, &matches);
for (k = 0; k < matches.used; k++)
{