summaryrefslogtreecommitdiff
path: root/src/rost.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2023-11-12 22:19:44 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2023-11-12 22:19:44 (GMT)
commite279139b7dcae080723412ea475787123c2389d4 (patch)
treec3549c7028fd7e6979a9ee87d8dbdc4a39952060 /src/rost.c
parent1e34d59e3fb62bc699d4e561c89e68adbf594f4e (diff)
Dump some ROST keywords on request.
Diffstat (limited to 'src/rost.c')
-rw-r--r--src/rost.c85
1 files changed, 78 insertions, 7 deletions
diff --git a/src/rost.c b/src/rost.c
index 96fc8e1..ba19b4f 100644
--- a/src/rost.c
+++ b/src/rost.c
@@ -36,6 +36,7 @@
#include "gleak.h"
#include "analysis/contents/file.h"
+#include "analysis/scan/core.h"
#include "analysis/scan/options.h"
#include "analysis/scan/scanner.h"
#include "analysis/scan/patterns/backends/bitap.h"
@@ -102,6 +103,11 @@ static void show_rost_help(const char *name)
printf("\n");
+ printf("\t--dump-modifiers\tList all registered modifiers for string patterns.\n");
+ printf("\t--dump-namespaces\tExplore the root namespace with all its functions and sub-namespaces.\n");
+
+ printf("\n");
+
free(tmp);
}
@@ -220,10 +226,18 @@ int main(int argc, char **argv)
bool show_version; /* Affichage de la version ? */
bool check_only; /* Validation uniquement */
LogMessageType verbosity; /* Niveau de filtre de message */
+ bool dump_modifiers; /* Affichage des modificateurs */
+ bool dump_namespaces; /* Affichage des fonctions */
GScanOptions *options; /* Options d'analyses */
int index; /* Indice d'argument */
int ret; /* Bilan d'un appel */
char *edir; /* Répertoire de base effectif */
+ size_t mod_count; /* Quantité de modificateurs */
+ char **modifiers; /* Liste de modificateurs */
+ size_t i; /* Boucle de parcours */
+ GScanNamespace *root_ns; /* Espace de noms ROST racine */
+ size_t items_count; /* Quantité de modificateurs */
+ char **items; /* Liste de modificateurs */
char *rules; /* Définition de règles */
char *target; /* Cible communiquée */
size_t rule_length; /* Taille d'un contenu */
@@ -234,6 +248,8 @@ int main(int argc, char **argv)
sized_string_t padding; /* Bourrage pour le JSON */
bool full; /* Détailler l'affichage ? */
+#define LONG_ID(n) (0x40570000 | n)
+
static struct option long_options[] = {
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, 'v' },
@@ -245,6 +261,8 @@ int main(int argc, char **argv)
{ "print-tags", no_argument, NULL, 'g' },
{ "tag", required_argument, NULL, 't' },
{ "verbosity", required_argument, NULL, 'V' },
+ { "dump-modifiers", no_argument, NULL, LONG_ID(1) },
+ { "dump-namespaces",no_argument, NULL, LONG_ID(2) },
{ NULL, 0, NULL, 0 }
};
@@ -257,6 +275,8 @@ int main(int argc, char **argv)
check_only = false;
verbosity = LMT_COUNT;
+ dump_modifiers = false;
+ dump_namespaces = false;
options = g_scan_options_new();
@@ -315,15 +335,16 @@ int main(int argc, char **argv)
verbosity = strtoul(optarg, NULL, 10);
break;
- }
+ case LONG_ID(1):
+ dump_modifiers = true;
+ break;
- }
+ case LONG_ID(2):
+ dump_namespaces = true;
+ break;
+
+ }
- if ((check_only && (optind + 0) != argc && (optind + 1) != argc)
- || (!check_only && (optind + 1) != argc && (optind + 2) != argc))
- {
- show_rost_help(argv[0]);
- goto done;
}
/* Actions de base */
@@ -371,6 +392,56 @@ int main(int argc, char **argv)
init_all_plugins(true);
+ if (dump_modifiers)
+ {
+ modifiers = list_all_scan_token_modifiers(&mod_count);
+
+ for (i = 0; i < mod_count; i++)
+ {
+ printf("%s\n", modifiers[i]);
+ free(modifiers[i]);
+ }
+
+ if (modifiers != NULL)
+ free(modifiers);
+
+ result = EXIT_SUCCESS;
+
+ }
+
+ if (dump_namespaces)
+ {
+ root_ns = get_rost_root_namespace();
+
+ items = g_scan_namespace_explore(root_ns, &items_count);
+
+ for (i = 0; i < items_count; i++)
+ {
+ printf("%s\n", items[i]);
+ free(items[i]);
+ }
+
+ if (items != NULL)
+ free(items);
+
+ result = EXIT_SUCCESS;
+
+ g_object_unref(G_OBJECT(root_ns));
+
+ }
+
+ if ((check_only && (optind + 0) != argc && (optind + 1) != argc)
+ || (!check_only && (optind + 1) != argc && (optind + 2) != argc))
+ {
+ if (result == EXIT_FAILURE)
+ show_rost_help(argv[0]);
+ goto done;
+ }
+
+ /* Réinitialisation en cas de dump... */
+ else
+ result = EXIT_FAILURE;
+
/* Traitement des recherches */
if ((optind + 0) == argc)