Skip to content

Commit

Permalink
Add: hostname to CVE scan report
Browse files Browse the repository at this point in the history
  • Loading branch information
timopollmeier authored Mar 21, 2023
2 parents efd3a94 + db7c22e commit f6c6a09
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -2990,9 +2990,19 @@ cve_scan_host (task_t task, report_t report, gvm_host_t *gvm_host)

if (prognosis_report_host)
{
gchar *hostname;

/* Complete the report_host. */

report_host_set_end_time (prognosis_report_host, time (NULL));

hostname = report_host_hostname (report_host);
if (hostname) {
insert_report_host_detail (report, ip, "cve", "",
"CVE Scanner", "hostname", hostname);
g_free(hostname);
}

insert_report_host_detail (report, ip, "cve", "",
"CVE Scanner", "CVE Scan", "1");
update_report_modification_time (report);
Expand Down
19 changes: 19 additions & 0 deletions src/manage_sql.c
Original file line number Diff line number Diff line change
Expand Up @@ -28860,6 +28860,25 @@ report_host_ip (const char *host)
return ret;
}

/**
* @brief Get the hostname of a report_host.
*
* The most recent host detail takes preference.
*
* @param[in] report_host Report host.
*
* @return Newly allocated hostname if available, else NULL.
*/
gchar*
report_host_hostname (report_host_t report_host)
{
return sql_string ("SELECT value FROM report_host_details"
" WHERE report_host = %llu"
" AND name = 'hostname'"
" ORDER BY id DESC LIMIT 1;",
report_host);
}

/**
* @brief Check if a report host is alive and has at least one result.
*
Expand Down
2 changes: 2 additions & 0 deletions src/manage_sql.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ host_nthlast_report_host (const char *, report_host_t *, int);
char*
report_host_ip (const char *);

gchar *report_host_hostname (report_host_t);

void trim_report (report_t);

int delete_report_internal (report_t);
Expand Down

0 comments on commit f6c6a09

Please sign in to comment.