Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change: Send a message with excluded hosts count to ospd. #1528

Merged
merged 1 commit into from
Mar 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions src/attack.c
Original file line number Diff line number Diff line change
Expand Up @@ -993,22 +993,23 @@ attack_start (struct ipc_context *ipcc, struct attack_start_args *args)
}
}

static void
static int
apply_hosts_excluded (gvm_hosts_t *hosts)
{
const char *exclude_hosts = prefs_get ("exclude_hosts");

int ret = 0;
/* Exclude hosts ? */
if (exclude_hosts)
{
/* Exclude hosts, resolving hostnames. */
int ret = gvm_hosts_exclude (hosts, exclude_hosts);
ret = gvm_hosts_exclude (hosts, exclude_hosts);

if (ret > 0)
g_message ("exclude_hosts: Skipped %d host(s).", ret);
if (ret < 0)
g_message ("exclude_hosts: Error.");
}
return ret;
}

#ifdef FEATURE_HOSTS_ALLOWED_ONLY
Expand Down Expand Up @@ -1360,16 +1361,23 @@ attack_network (struct scan_globals *globals)
apply_hosts_allow_deny (hosts);
#endif

// Remove the excluded hosts
int exc = apply_hosts_excluded (hosts);

/* Send the excluded hosts count to the client, after removing duplicated and
* unresolved hosts.*/
sprintf (buf, "%d", exc + already_excluded);
connect_main_kb (&main_kb);
message_to_client (main_kb, buf, NULL, NULL, "HOSTS_EXCLUDED");
kb_lnk_reset (main_kb);

/* Send the hosts count to the client, after removing duplicated and
* unresolved hosts.*/
sprintf (buf, "%d", gvm_hosts_count (hosts) + already_excluded);
sprintf (buf, "%d", gvm_hosts_count (hosts));
connect_main_kb (&main_kb);
message_to_client (main_kb, buf, NULL, NULL, "HOSTS_COUNT");
kb_lnk_reset (main_kb);

// Remove the excluded hosts
apply_hosts_excluded (hosts);

host = gvm_hosts_next (hosts);
if (host == NULL)
goto stop;
Expand Down
Loading