Skip to content
New issue

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

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

Already on GitHub? # to your account

Add nvti_add_tag() for adding a single tag to tags. #263

Merged
merged 5 commits into from
Sep 8, 2019
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- A new data model for unified handling of cross references in the NVT meta data as been added. All previous API elements to handle cve, bid, xref werehas been removed. [#225](https://github.com/greenbone/gvm-libs/pull/225) [#232](https://github.com/greenbone/gvm-libs/pull/232).
- A function to get an osp scan status and a enum type for the different status [#259](https://github.com/greenbone/gvm-libs/pull/259)
- API functions for NVTI to handle timestamps [#261](https://github.com/greenbone/gvm-libs/pull/261)
- API function for NVTI to add a single tag [#263](https://github.com/greenbone/gvm-libs/pull/263)
### Changed
- Change the default path to the redis socket to /run/redis/redis.sock [#256](https://github.com/greenbone/gvm-libs/pull/256)
- Handle EAI_AGAIN in gvm_host_reverse_lookup() IPv6 case and function refactor. [#229](https://github.com/greenbone/gvm-libs/pull/229)
Expand Down
37 changes: 37 additions & 0 deletions base/nvti.c
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,43 @@ nvti_set_solution_type (nvti_t *n, const gchar *solution_type)
return (0);
}

/**
* @brief Add a tag to the NVT tags.
*
* @param n The NVT Info structure.
*
* @param name The tag name. A copy will be created from this.
*
* @param value The tag value. A copy will be created from this.
mattmundell marked this conversation as resolved.
Show resolved Hide resolved
*
* @return 0 for success. Anything else indicates an error.
*/
int
nvti_add_tag (nvti_t *n, const gchar *name, const gchar *value)
{
if (!n)
return (-1);

if (!name || !name[0])
return (-2);

if (!value || !value[0])
return (-3);

if (n->tag)
{
gchar *newtag;

newtag = g_strconcat (n->tag, "|", name, "=", value, NULL);
g_free (n->tag);
n->tag = newtag;
}
else
n->tag = g_strconcat (name, "=", value, NULL);

return (0);
}

/**
* @brief Set the tags of a NVT.
*
Expand Down
2 changes: 2 additions & 0 deletions base/nvti.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ nvti_set_solution (nvti_t *, const gchar *);
int
nvti_set_solution_type (nvti_t *, const gchar *);
int
nvti_add_tag (nvti_t *, const gchar *, const gchar *);
int
nvti_set_tag (nvti_t *, const gchar *);
int
nvti_set_cvss_base (nvti_t *, const gchar *);
Expand Down