Skip to content

Commit

Permalink
Added some necessary amendments.
Browse files Browse the repository at this point in the history
  • Loading branch information
jhelmold committed Sep 19, 2024
1 parent 0b94d1b commit 78a45e3
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/manage_sql_secinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -2716,7 +2716,7 @@ save_node (resource_t parent_id, resource_t cve_id, char *operator)
("INSERT INTO scap2.cpe_match_nodes"
" (parent_id, cve_id, operator)"
" VALUES"
" (%i, %i, '%s')"
" (%llu, %llu, '%s')"
" RETURNING scap2.cpe_match_nodes.id;",
parent_id,
cve_id,
Expand All @@ -2730,7 +2730,7 @@ save_node (resource_t parent_id, resource_t cve_id, char *operator)
* @param[in] match_rules The JSON object that contains the rules.
*/
static void
add_cpe_match_rules (long int id, cJSON *match_rules)
add_cpe_match_rules (result_t id, cJSON *match_rules)

Check warning on line 2733 in src/manage_sql_secinfo.c

View check run for this annotation

Codecov / codecov/patch

src/manage_sql_secinfo.c#L2733

Added line #L2733 was not covered by tests
{
cJSON *match_rule;
cJSON *ver_se;
Expand Down Expand Up @@ -2780,10 +2780,10 @@ add_cpe_match_rules (long int id, cJSON *match_rules)
" version_start_incl, version_start_excl,"
" version_end_incl, version_end_excl)"
" VALUES"
" (%ld, %d, '%s', '%s', '%s', '%s', '%s')",
" (%llu, %d, '%s', '%s', '%s', '%s', '%s')",
id,
vulnerable ? 1 : 0,
quoted_cpe,
quoted_cpe,
version_start_incl,
version_start_excl,
version_end_incl,
Expand All @@ -2806,7 +2806,7 @@ static void
load_nodes (resource_t parent_id, resource_t cveid, cJSON *nodes)

Check warning on line 2806 in src/manage_sql_secinfo.c

View check run for this annotation

Codecov / codecov/patch

src/manage_sql_secinfo.c#L2806

Added line #L2806 was not covered by tests
{
cJSON *node;
long int id;
resource_t id;
cJSON *operator;
cJSON *cpe_match_rules;
cJSON *child_nodes;
Expand Down Expand Up @@ -3280,10 +3280,21 @@ update_scap_cves ()
(gpointer*) g_strdup (iterator_string (&cpes, 0)),
GINT_TO_POINTER (iterator_int (&cpes, 1)));

count = 0;
gboolean read_json = FALSE;

Check warning on line 3283 in src/manage_sql_secinfo.c

View check run for this annotation

Codecov / codecov/patch

src/manage_sql_secinfo.c#L3283

Added line #L3283 was not covered by tests
while ((cve_path = g_dir_read_name (dir)))
{
if (fnmatch ("nvdcve-1.1-*.json", cve_path, 0) == 0)
{
read_json = TRUE;
break;

Check warning on line 3289 in src/manage_sql_secinfo.c

View check run for this annotation

Codecov / codecov/patch

src/manage_sql_secinfo.c#L3288-L3289

Added lines #L3288 - L3289 were not covered by tests
}
}
g_dir_rewind (dir);

Check warning on line 3292 in src/manage_sql_secinfo.c

View check run for this annotation

Codecov / codecov/patch

src/manage_sql_secinfo.c#L3292

Added line #L3292 was not covered by tests

count = 0;
while ((cve_path = g_dir_read_name (dir)))
{
if ((fnmatch ("nvdcve-1.1-*.json", cve_path, 0) == 0) && read_json)
{
if (update_cve_json (cve_path, hashed_cpes))
{
Expand All @@ -3294,7 +3305,7 @@ update_scap_cves ()
}
count++;

Check warning on line 3306 in src/manage_sql_secinfo.c

View check run for this annotation

Codecov / codecov/patch

src/manage_sql_secinfo.c#L3306

Added line #L3306 was not covered by tests
}
else if (fnmatch ("nvdcve-2.0-*.xml", cve_path, 0) == 0)
else if ((fnmatch ("nvdcve-2.0-*.xml", cve_path, 0) == 0) && !read_json)

Check warning on line 3308 in src/manage_sql_secinfo.c

View check run for this annotation

Codecov / codecov/patch

src/manage_sql_secinfo.c#L3308

Added line #L3308 was not covered by tests
{
if (update_cve_xml (cve_path, hashed_cpes))
{
Expand Down

0 comments on commit 78a45e3

Please sign in to comment.