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:
24
output.cc
24
output.cc
@@ -785,7 +785,8 @@ void printportoutput(Target *currenths, PortList *plist) {
|
|||||||
#ifndef NOLUA
|
#ifndef NOLUA
|
||||||
if (o.script) {
|
if (o.script) {
|
||||||
ScriptResults::const_iterator ssr_iter;
|
ScriptResults::const_iterator ssr_iter;
|
||||||
|
//Sort the results before outputing them on the screen
|
||||||
|
current->scriptResults.sort(comparescriptids);
|
||||||
for (ssr_iter = current->scriptResults.begin();
|
for (ssr_iter = current->scriptResults.begin();
|
||||||
ssr_iter != current->scriptResults.end(); ssr_iter++) {
|
ssr_iter != current->scriptResults.end(); ssr_iter++) {
|
||||||
xml_open_start_tag("script");
|
xml_open_start_tag("script");
|
||||||
@@ -2165,7 +2166,9 @@ void printscriptresults(ScriptResults *scriptResults, stype scantype) {
|
|||||||
char *script_output;
|
char *script_output;
|
||||||
|
|
||||||
if (scriptResults->size() > 0) {
|
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");
|
xml_start_tag("prescript");
|
||||||
log_write(LOG_PLAIN, "Pre-scan script results:\n");
|
log_write(LOG_PLAIN, "Pre-scan script results:\n");
|
||||||
}
|
}
|
||||||
@@ -2194,6 +2197,8 @@ void printhostscriptresults(Target *currenths) {
|
|||||||
char *script_output;
|
char *script_output;
|
||||||
|
|
||||||
if (currenths->scriptResults.size() > 0) {
|
if (currenths->scriptResults.size() > 0) {
|
||||||
|
//no point sorting an empty list
|
||||||
|
currenths->scriptResults.sort(comparescriptids);
|
||||||
xml_start_tag("hostscript");
|
xml_start_tag("hostscript");
|
||||||
log_write(LOG_PLAIN, "\nHost script results:\n");
|
log_write(LOG_PLAIN, "\nHost script results:\n");
|
||||||
for (iter = currenths->scriptResults.begin();
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
4
output.h
4
output.h
@@ -251,4 +251,8 @@ void printfinaloutput();
|
|||||||
were found. */
|
were found. */
|
||||||
void printdatafilepaths();
|
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 */
|
#endif /* OUTPUT_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user