mirror of
https://github.com/nmap/nmap.git
synced 2025-12-07 13:11:28 +00:00
Use script ids instead of full paths in NSE start/finish/error debug output.
This commit is contained in:
12
nse_main.cc
12
nse_main.cc
@@ -35,11 +35,11 @@ struct thread_record {
|
|||||||
unsigned int registry_idx; // index in the main state registry
|
unsigned int registry_idx; // index in the main state registry
|
||||||
double runlevel;
|
double runlevel;
|
||||||
struct run_record rr;
|
struct run_record rr;
|
||||||
std::string get_id();
|
std::string get_id() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Gets the basename of a script filename and removes any ".nse" extension. */
|
/* Gets the basename of a script filename and removes any ".nse" extension. */
|
||||||
std::string thread_record::get_id() {
|
std::string thread_record::get_id() const {
|
||||||
char *abbrev;
|
char *abbrev;
|
||||||
|
|
||||||
abbrev = path_get_basename(filename.c_str());
|
abbrev = path_get_basename(filename.c_str());
|
||||||
@@ -414,19 +414,19 @@ static const char *thread_id_str(const thread_record &thr) {
|
|||||||
void log_script_started(const thread_record &thr) {
|
void log_script_started(const thread_record &thr) {
|
||||||
log_write(LOG_STDOUT, "%s (%.3fs): Starting %s against %s.\n",
|
log_write(LOG_STDOUT, "%s (%.3fs): Starting %s against %s.\n",
|
||||||
SCRIPT_ENGINE, o.TimeSinceStartMS() / 1000.0,
|
SCRIPT_ENGINE, o.TimeSinceStartMS() / 1000.0,
|
||||||
thr.filename.c_str(), thread_id_str(thr));
|
thr.get_id().c_str(), thread_id_str(thr));
|
||||||
}
|
}
|
||||||
|
|
||||||
void log_script_finished(const thread_record &thr) {
|
void log_script_finished(const thread_record &thr) {
|
||||||
log_write(LOG_STDOUT, "%s (%.3fs): Finished %s against %s.\n",
|
log_write(LOG_STDOUT, "%s (%.3fs): Finished %s against %s.\n",
|
||||||
SCRIPT_ENGINE, o.TimeSinceStartMS() / 1000.0,
|
SCRIPT_ENGINE, o.TimeSinceStartMS() / 1000.0,
|
||||||
thr.filename.c_str(), thread_id_str(thr));
|
thr.get_id().c_str(), thread_id_str(thr));
|
||||||
}
|
}
|
||||||
|
|
||||||
void log_script_timeout(const thread_record &thr) {
|
void log_script_timeout(const thread_record &thr) {
|
||||||
log_write(LOG_STDOUT, "%s (%.3fs): Stopped %s against %s because of host timeout.\n",
|
log_write(LOG_STDOUT, "%s (%.3fs): Stopped %s against %s because of host timeout.\n",
|
||||||
SCRIPT_ENGINE, o.TimeSinceStartMS() / 1000.0,
|
SCRIPT_ENGINE, o.TimeSinceStartMS() / 1000.0,
|
||||||
thr.filename.c_str(), thread_id_str(thr));
|
thr.get_id().c_str(), thread_id_str(thr));
|
||||||
}
|
}
|
||||||
|
|
||||||
void log_script_error(const thread_record &thr) {
|
void log_script_error(const thread_record &thr) {
|
||||||
@@ -436,7 +436,7 @@ void log_script_error(const thread_record &thr) {
|
|||||||
errmsg = lua_tostring(thr.thread, -1);
|
errmsg = lua_tostring(thr.thread, -1);
|
||||||
log_write(LOG_STDOUT, "%s (%.3fs): %s against %s ended with error: %s\n",
|
log_write(LOG_STDOUT, "%s (%.3fs): %s against %s ended with error: %s\n",
|
||||||
SCRIPT_ENGINE, o.TimeSinceStartMS() / 1000.0,
|
SCRIPT_ENGINE, o.TimeSinceStartMS() / 1000.0,
|
||||||
thr.filename.c_str(), thread_id_str(thr), errmsg);
|
thr.get_id().c_str(), thread_id_str(thr), errmsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
int process_mainloop(lua_State *L) {
|
int process_mainloop(lua_State *L) {
|
||||||
|
|||||||
Reference in New Issue
Block a user