28 GFileInputStream *fis = NULL;
29 GDataInputStream *dis = NULL;
32 file = g_file_new_for_path (filename);
33 fis = g_file_read (file, NULL, &error);
39 g_error (
"%s\n\n", error->message);
41 dis = g_data_input_stream_new (G_INPUT_STREAM (fis));
90 g_data_input_stream_read_line (nvt_list, NULL, NULL, &error);
96 g_error (
"%s\n\n", error->message);
106 g_object_unref (nvt_list);
138 const gchar *message, gpointer user_data)
140 gint log_mask = GPOINTER_TO_INT (user_data);
141 if ((log_level & log_mask) != 0)
142 g_log_default_handler (log_domain, log_level, message, user_data);
155 static gboolean debug = FALSE;
156 static gchar *include_dir = NULL;
157 static gchar *nvt_file_list = NULL;
158 static unsigned char strict_includes = 0;
159 static const gchar **nvt_files = NULL;
161 GError *error = NULL;
162 GOptionContext *option_context;
164 static GOptionEntry entries[] = {
165 {
"debug",
'd', 0, G_OPTION_ARG_NONE, &debug,
"Output debug log messages.",
167 {
"nvt-list",
'l', 0, G_OPTION_ARG_STRING, &nvt_file_list,
168 "Process files from <file>",
"<file>"},
169 {
"include-dir",
'i', 0, G_OPTION_ARG_STRING, &include_dir,
170 "Search for includes in <dir>",
"<dir>"},
171 {G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &nvt_files,
172 "Absolute path to one or more nasl scripts",
"NASL_FILE..."},
173 {
"strict-includes", 0, 0, G_OPTION_ARG_NONE, &strict_includes,
174 "Enables check for strict include order.", NULL},
175 {NULL, 0, 0, 0, NULL, NULL, NULL}};
178 g_option_context_new (
"- standalone NASL linter for OpenVAS");
179 g_option_context_add_main_entries (option_context, entries, NULL);
180 if (!g_option_context_parse (option_context, &argc, &argv, &error))
182 g_error (
"%s\n\n", error->message);
184 g_option_context_free (option_context);
185 fflag |= strict_includes;
197 if (include_dir != NULL)
203 GINT_TO_POINTER (G_LOG_LEVEL_DEBUG | G_LOG_LEVEL_INFO
204 | G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_WARNING
205 | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_ERROR));
208 GINT_TO_POINTER (G_LOG_LEVEL_WARNING
209 | G_LOG_LEVEL_CRITICAL
210 | G_LOG_LEVEL_ERROR));
213 if (nvt_file_list != NULL)
217 if (nvt_files != NULL)
220 g_print (
"%d scripts with one or more errors found\n", err);
static int process_file_list(const gchar *list_file, int mode, struct script_infos *script_args)
Process each files in the list_file through the linter.
static int process_files(const gchar **files, int mode, struct script_infos *script_args)
Process each given files through the linter.
static int process_file(const gchar *filepath, int mode, struct script_infos *script_args)
Process a file through the linter.