Skip to content

Commit

Permalink
Merge pull request #263 from janowagner/resolve_tags
Browse files Browse the repository at this point in the history
Add nvti_add_tag() for adding a single tag to tags.
  • Loading branch information
mattmundell authored Sep 8, 2019
2 parents ee097fe + 27d8fd2 commit a9b645e
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
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.
*
* @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

0 comments on commit a9b645e

Please # to comment.