Skip to content

Commit

Permalink
Merge pull request #473 from greenbone/mergify/bp/master/pr-472
Browse files Browse the repository at this point in the history
Use double for scores in vtseverity_t and helpers (bp #472)
  • Loading branch information
nichtsfrei authored Apr 13, 2021
2 parents 83a30b7 + 9db1859 commit 830ec41
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Allow to re allocate the finish flag in the host queue for alive tests.
[#407](https://github.com/greenbone/gvm-libs/pull/407)
[#410](https://github.com/greenbone/gvm-libs/pull/410)
- Add multiple severities for nvti [#317](https://github.com/greenbone/gvm-libs/pull/317)
- Add multiple severities for nvti [#317](https://github.com/greenbone/gvm-libs/pull/317) [#472](https://github.com/greenbone/gvm-libs/pull/472)
- Add support for new OSP element for defining alive test methods via separate subelements. [#409](https://github.com/greenbone/gvm-libs/pull/409)
- Add v3 handling to get_cvss_score_from_base_metrics. [#411](https://github.com/greenbone/gvm-libs/pull/411)
- Add severity_date tag in epoch time format. [#412](https://github.com/greenbone/gvm-libs/pull/412)
Expand Down
20 changes: 10 additions & 10 deletions base/nvti.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,25 +172,25 @@ typedef struct vtseverity
gchar *origin; ///< Optional: Where does the severity come from
///< ("CVE-2018-1234", "Greenbone Research")
int date; ///< Timestamp in seconds since epoch, defaults to VT creation date.
int score; ///< The score derived from the value in range [0-100]
double score; ///< The score derived from the value in range [0.0-10.0]
gchar *value; ///< The value which corresponds to the type.
} vtseverity_t;

/**
* @brief Create a new vtseverity structure filled with the given values.
*
* @param type The severity type to be set.
*
* @param origin The origin reference to be set, can be NULL.
*
* @param value The value corresponding to the type.
* @param[in] type The severity type to be set.
* @param[in] origin The origin reference to be set, can be NULL.
* @param[in] date The date to be set.
* @param[in] score The score to be set.
* @param[in] value The value corresponding to the type.
*
* @return NULL in case the memory could not be allocated.
* Else a vtref structure which needs to be
* released using @ref vtref_free .
*/
vtseverity_t *
vtseverity_new (const gchar *type, const gchar *origin, int date, int score,
vtseverity_new (const gchar *type, const gchar *origin, int date, double score,
const gchar *value)
{
vtseverity_t *s = g_malloc0 (sizeof (vtseverity_t));
Expand Down Expand Up @@ -288,7 +288,7 @@ vtseverity_date (const vtseverity_t *s)
*
* @return The score.
*/
int
double
vtseverity_score (const vtseverity_t *s)
{
return s->score;
Expand Down Expand Up @@ -915,11 +915,11 @@ nvti_vtseverity (const nvti_t *n, guint p)
*
* @return The severity score, -1 indicates an error.
*/
int
double
nvti_severity_score (const nvti_t *n)
{
unsigned int i;
int score = -1;
double score = -1.0;

for (i = 0; i < nvti_vtseverities_len (n); i++)
{
Expand Down
6 changes: 3 additions & 3 deletions base/nvti.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const gchar *
vtref_text (const vtref_t *);

vtseverity_t *
vtseverity_new (const gchar *, const gchar *, int, int, const gchar *);
vtseverity_new (const gchar *, const gchar *, int, double, const gchar *);
void
vtseverity_free (vtseverity_t *);
const gchar *
Expand All @@ -87,7 +87,7 @@ const gchar *
vtseverity_value (const vtseverity_t *);
int
vtseverity_date (const vtseverity_t *);
int
double
vtseverity_score (const vtseverity_t *);

int
Expand All @@ -103,7 +103,7 @@ guint
nvti_vtseverities_len (const nvti_t *);
vtseverity_t *
nvti_vtseverity (const nvti_t *, guint);
int
double
nvti_severity_score (const nvti_t *);

nvti_t *
Expand Down

0 comments on commit 830ec41

Please sign in to comment.