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

Add option to set finished hosts in OSP targets (11.0) #298

Merged
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [11.0.1] (unreleased)

### Added
- Add option to set finished hosts in OSP targets [#298](https://github.com/greenbone/gvm-libs/pull/298)

### Fixed
- Fix sigsegv when no plugin_feed_info.inc file present. [#278](https://github.com/greenbone/gvm-libs/pull/278)

Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ cmake_minimum_required(VERSION 3.0)
message ("-- Configuring the Greenbone Vulnerability Management Libraries...")

project (gvm-libs
VERSION 11.0.0
VERSION 11.0.1
LANGUAGES C)

if (POLICY CMP0005)
Expand Down
26 changes: 22 additions & 4 deletions osp/osp.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,11 @@ struct osp_credential
*/
struct osp_target
{
GSList *credentials; /** Credentials to use in the scan */
gchar *exclude_hosts; /** String defining one or many hosts to exclude */
gchar *hosts; /** String defining one or many hosts to scan */
gchar *ports; /** String defining the ports to scan */
GSList *credentials; /** Credentials to use in the scan */
gchar *exclude_hosts; /** String defining one or many hosts to exclude */
gchar *hosts; /** String defining one or many hosts to scan */
gchar *ports; /** String defining the ports to scan */
gchar *finished_hosts; /** String defining hosts to exclude as finished */
};

/**
Expand Down Expand Up @@ -858,9 +859,11 @@ target_append_as_xml (osp_target_t *target, GString *xml_string)
"<target>"
"<hosts>%s</hosts>"
"<exclude_hosts>%s</exclude_hosts>"
"<finished_hosts>%s</finished_hosts>"
"<ports>%s</ports>",
target->hosts ? target->hosts : "",
target->exclude_hosts ? target->exclude_hosts : "",
target->finished_hosts ? target->finished_hosts : "",
target->ports ? target->ports : "");

if (target->credentials)
Expand Down Expand Up @@ -1399,10 +1402,25 @@ osp_target_new (const char *hosts,
new_target->exclude_hosts = exclude_hosts ? g_strdup (exclude_hosts) : NULL;
new_target->hosts = hosts ? g_strdup (hosts) : NULL;
new_target->ports = ports ? g_strdup (ports) : NULL;
new_target->finished_hosts = NULL;

return new_target;
}

/**
* @brief Set the finished hosts of an OSP target.
*
* @param[in] target The OSP target to modify.
* @param[in] finished_hosts The hostnames to consider finished.
*/
void
osp_target_set_finished_hosts (osp_target_t *target,
const char *finished_hosts)
{
g_free (target->finished_hosts);
target->finished_hosts = finished_hosts ? g_strdup (finished_hosts) : NULL;
}

/**
* @brief Free an OSP target, including all added credentials.
*
Expand Down
3 changes: 3 additions & 0 deletions osp/osp.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ osp_credential_set_auth_data (osp_credential_t *, const char*, const char*);
osp_target_t *
osp_target_new (const char *, const char *, const char *);

void
osp_target_set_finished_hosts (osp_target_t *, const char *);

void
osp_target_free (osp_target_t *);

Expand Down