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 timestamps as explicit elements of nvti. #261

Merged
merged 4 commits into from
Sep 6, 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 @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Allow to configure the path to the redis socket via CMake [#256](https://github.com/greenbone/gvm-libs/pull/256)
- 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)
### 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
69 changes: 69 additions & 0 deletions base/nvti.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ typedef struct nvti
gchar *affected; /**< @brief Affected systems */
gchar *impact; /**< @brief Impact of vulnerability */

time_t creation_time; /**< @brief Time of creation, seconds since epoch */
time_t modification_time; /**< @brief Time of last change, sec. since epoch */

gchar *solution; /**< @brief The solution */
gchar *solution_type; /**< @brief The solution type */

Expand Down Expand Up @@ -464,6 +467,34 @@ nvti_impact (const nvti_t *n)
return (n ? n->impact : NULL);
}

/**
* @brief Get the creation time.
*
* @param n The NVT Info structure of which the creation time should
* be returned.
*
* @return The creation time in seconds since epoch.
*/
time_t
nvti_creation_time (const nvti_t *n)
{
return (n ? n->creation_time : 0);
}

/**
* @brief Get the modification time.
*
* @param n The NVT Info structure of which the modification time should
* be returned.
*
* @return The modification time in seconds since epoch.
*/
time_t
nvti_modification_time (const nvti_t *n)
{
return (n ? n->modification_time : 0);
}

/**
* @brief Get the number of references of the NVT.
*
Expand Down Expand Up @@ -945,6 +976,44 @@ nvti_set_impact (nvti_t *n, const gchar *impact)
return (0);
}

/**
* @brief Set the creation time of a NVT.
*
* @param n The NVT Info structure.
*
* @param creation_time The creation time to set.
*
* @return 0 for success. Anything else indicates an error.
*/
int
nvti_set_creation_time (nvti_t *n, const time_t creation_time)
{
if (!n)
return (-1);

n->creation_time = creation_time;
return (0);
}

/**
* @brief Set the modification time of a NVT.
*
* @param n The NVT Info structure.
*
* @param modification_time The modification time to set.
*
* @return 0 for success. Anything else indicates an error.
*/
int
nvti_set_modification_time (nvti_t *n, const time_t modification_time)
{
if (!n)
return (-1);

n->modification_time = modification_time;
return (0);
}

/**
* @brief Set the solution of a NVT.
*
Expand Down
8 changes: 8 additions & 0 deletions base/nvti.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ gchar *
nvti_affected (const nvti_t *);
gchar *
nvti_impact (const nvti_t *);
time_t
nvti_creation_time (const nvti_t *);
time_t
nvti_modification_time (const nvti_t *);
gchar *
nvti_insight (const nvti_t *);
gchar *
Expand Down Expand Up @@ -144,6 +148,10 @@ nvti_set_affected (nvti_t *, const gchar *);
int
nvti_set_impact (nvti_t *, const gchar *);
int
nvti_set_creation_time (nvti_t *, const time_t);
int
nvti_set_modification_time (nvti_t *, const time_t);
int
nvti_set_solution (nvti_t *, const gchar *);
int
nvti_set_solution_type (nvti_t *, const gchar *);
Expand Down