1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-07 13:11:28 +00:00

Output for script results is now sortedi alphabetically.

This commit is contained in:
sean
2012-06-23 04:17:24 +00:00
parent b6f66fba81
commit bfeecd1895
2 changed files with 26 additions and 2 deletions

View File

@@ -785,7 +785,8 @@ void printportoutput(Target *currenths, PortList *plist) {
#ifndef NOLUA
if (o.script) {
ScriptResults::const_iterator ssr_iter;
//Sort the results before outputing them on the screen
current->scriptResults.sort(comparescriptids);
for (ssr_iter = current->scriptResults.begin();
ssr_iter != current->scriptResults.end(); ssr_iter++) {
xml_open_start_tag("script");
@@ -2165,7 +2166,9 @@ void printscriptresults(ScriptResults *scriptResults, stype scantype) {
char *script_output;
if (scriptResults->size() > 0) {
if (scantype == SCRIPT_PRE_SCAN) {
// No sense sorting if we don't need too
scriptResults->sort(comparescriptids);
if (scantype == SCRIPT_PRE_SCAN) {
xml_start_tag("prescript");
log_write(LOG_PLAIN, "Pre-scan script results:\n");
}
@@ -2194,6 +2197,8 @@ void printhostscriptresults(Target *currenths) {
char *script_output;
if (currenths->scriptResults.size() > 0) {
//no point sorting an empty list
currenths->scriptResults.sort(comparescriptids);
xml_start_tag("hostscript");
log_write(LOG_PLAIN, "\nHost script results:\n");
for (iter = currenths->scriptResults.begin();
@@ -2603,3 +2608,18 @@ void printdatafilepaths() {
}
}
}
/*This is a helper function to determine the ordering of the script results
based on their id */
bool comparescriptids(ScriptResult first, ScriptResult second){
//Pull the two id fields out for comparison
std::string firstid(first.get_id());
std::string secondid(second.get_id());
if (firstid < secondid)
return true;
else
return false;
}

View File

@@ -251,4 +251,8 @@ void printfinaloutput();
were found. */
void printdatafilepaths();
/*This is a helper function to determine the ordering of the script results
based on their id */
bool comparescriptids(ScriptResult first, ScriptResult second);
#endif /* OUTPUT_H */