Skip to content

Commit

Permalink
Add: nvti set functions that use the given string
Browse files Browse the repository at this point in the history
  • Loading branch information
timopollmeier authored May 15, 2023
2 parents 4f8cecb + 0789097 commit 1b38b8d
Show file tree
Hide file tree
Showing 2 changed files with 176 additions and 0 deletions.
160 changes: 160 additions & 0 deletions base/nvti.c
Original file line number Diff line number Diff line change
Expand Up @@ -1294,6 +1294,26 @@ nvti_set_name (nvti_t *n, const gchar *name)
return 0;
}

/**
* @brief Set the name of a NVT, using the given memory.
*
* @param n The NVT Info structure.
*
* @param name The name to set. The string will be used directly.
*
* @return 0 for success. Anything else indicates an error.
*/
int
nvti_put_name (nvti_t *n, gchar *name)
{
if (!n)
return -1;

g_free (n->name);
n->name = name;
return 0;
}

/**
* @brief Set the summary of a NVT.
*
Expand All @@ -1314,6 +1334,26 @@ nvti_set_summary (nvti_t *n, const gchar *summary)
return 0;
}

/**
* @brief Set the summary of a NVT, using the given memory.
*
* @param n The NVT Info structure.
*
* @param solution The summary to set. The string will be used directly.
*
* @return 0 for success. Anything else indicates an error.
*/
int
nvti_put_summary (nvti_t *n, gchar *summary)
{
if (!n)
return -1;

g_free (n->summary);
n->summary = summary;
return 0;
}

/**
* @brief Set the insight text of a NVT.
*
Expand All @@ -1334,6 +1374,26 @@ nvti_set_insight (nvti_t *n, const gchar *insight)
return 0;
}

/**
* @brief Set the insight text of a NVT, using the given memory.
*
* @param n The NVT Info structure.
*
* @param insight The insight text to set. The string will be used directly.
*
* @return 0 for success. Anything else indicates an error.
*/
int
nvti_put_insight (nvti_t *n, gchar *insight)
{
if (!n)
return -1;

g_free (n->insight);
n->insight = insight;
return 0;
}

/**
* @brief Set the affected text of a NVT.
*
Expand All @@ -1354,6 +1414,26 @@ nvti_set_affected (nvti_t *n, const gchar *affected)
return 0;
}

/**
* @brief Set the affected text of a NVT, using the given memory.
*
* @param n The NVT Info structure.
*
* @param affected The affected text to set. The string will be used directly.
*
* @return 0 for success. Anything else indicates an error.
*/
int
nvti_put_affected (nvti_t *n, gchar *affected)
{
if (!n)
return -1;

g_free (n->affected);
n->affected = affected;
return 0;
}

/**
* @brief Set the impact text of a NVT.
*
Expand All @@ -1374,6 +1454,26 @@ nvti_set_impact (nvti_t *n, const gchar *impact)
return 0;
}

/**
* @brief Set the impact text of a NVT, using the given memory.
*
* @param n The NVT Info structure.
*
* @param affected The impact text to set. The string will be used directly.
*
* @return 0 for success. Anything else indicates an error.
*/
int
nvti_put_impact (nvti_t *n, gchar *impact)
{
if (!n)
return -1;

g_free (n->impact);
n->impact = impact;
return 0;
}

/**
* @brief Set the creation time of a NVT.
*
Expand Down Expand Up @@ -1432,6 +1532,26 @@ nvti_set_solution (nvti_t *n, const gchar *solution)
return 0;
}

/**
* @brief Set the solution of a NVT, using the given memory.
*
* @param n The NVT Info structure.
*
* @param solution The solution to set. The string will be used directly.
*
* @return 0 for success. Anything else indicates an error.
*/
int
nvti_put_solution (nvti_t *n, gchar *solution)
{
if (!n)
return -1;

g_free (n->solution);
n->solution = solution;
return 0;
}

/**
* @brief Set the solution type of a NVT.
*
Expand Down Expand Up @@ -1755,6 +1875,26 @@ nvti_set_detection (nvti_t *n, const gchar *detection)
return 0;
}

/**
* @brief Set the detection text of a NVT, using the given memory.
*
* @param n The NVT Info structure.
*
* @param detection The detection text to set. The string will be used directly.
*
* @return 0 for success. Anything else indicates an error.
*/
int
nvti_put_detection (nvti_t *n, gchar *detection)
{
if (!n)
return -1;

g_free (n->detection);
n->detection = detection;
return 0;
}

/**
* @brief Set the QoD type of a NVT.
*
Expand Down Expand Up @@ -1823,6 +1963,26 @@ nvti_set_family (nvti_t *n, const gchar *family)
return 0;
}

/**
* @brief Set the family of a NVT, using the given memory.
*
* @param n The NVT Info structure.
*
* @param family The family to set. The string will be used directly.
*
* @return 0 for success. Anything else indicates an error.
*/
int
nvti_put_family (nvti_t *n, gchar *family)
{
if (!n)
return -1;

g_free (n->family);
n->family = family;
return 0;
}

/**
* @brief Set the category type of a NVT Info.
*
Expand Down
16 changes: 16 additions & 0 deletions base/nvti.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,20 +179,32 @@ nvti_set_oid (nvti_t *, const gchar *);
int
nvti_set_name (nvti_t *, const gchar *);
int
nvti_put_name (nvti_t *, gchar *);
int
nvti_set_summary (nvti_t *, const gchar *);
int
nvti_put_summary (nvti_t *, gchar *);
int
nvti_set_insight (nvti_t *, const gchar *);
int
nvti_put_insight (nvti_t *, gchar *);
int
nvti_set_affected (nvti_t *, const gchar *);
int
nvti_put_affected (nvti_t *, gchar *);
int
nvti_set_impact (nvti_t *, const gchar *);
int
nvti_put_impact (nvti_t *, 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_put_solution (nvti_t *, gchar *);
int
nvti_set_solution_type (nvti_t *, const gchar *);
int
nvti_set_solution_method (nvti_t *, const gchar *);
Expand All @@ -217,6 +229,8 @@ nvti_set_required_udp_ports (nvti_t *, const gchar *);
int
nvti_set_detection (nvti_t *, const gchar *);
int
nvti_put_detection (nvti_t *, gchar *);
int
nvti_set_qod_type (nvti_t *, const gchar *);
int
nvti_set_qod (nvti_t *, const gchar *);
Expand All @@ -226,6 +240,8 @@ int
nvti_set_category (nvti_t *, const gint);
int
nvti_set_family (nvti_t *, const gchar *);
int
nvti_put_family (nvti_t *, gchar *);

int
nvti_add_refs (nvti_t *, const gchar *, const gchar *, const gchar *);
Expand Down

0 comments on commit 1b38b8d

Please sign in to comment.