Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
a-h-abdelsalam committed Jul 3, 2024
1 parent 44eaef2 commit e3a9627
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
6 changes: 4 additions & 2 deletions src/manage_pg.c
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ manage_create_sql_functions ()
"$$ LANGUAGE plpgsql"
" IMMUTABLE;");

sql ("CREATE OR REPLACE FUNCTION compliance_status ("
sql ("CREATE OR REPLACE FUNCTION report_compliance_status ("

Check warning on line 898 in src/manage_pg.c

View check run for this annotation

Codecov / codecov/patch

src/manage_pg.c#L898

Added line #L898 was not covered by tests
" report_id integer)"
"RETURNS text AS $$ "
"BEGIN"
Expand All @@ -918,7 +918,9 @@ manage_create_sql_functions ()
"$$ LANGUAGE plpgsql"
" IMMUTABLE;");

sql ("CREATE OR REPLACE FUNCTION compliance_count (report_id integer, compliance text)"
sql ("CREATE OR REPLACE FUNCTION report_compliance_count ("

Check warning on line 921 in src/manage_pg.c

View check run for this annotation

Codecov / codecov/patch

src/manage_pg.c#L921

Added line #L921 was not covered by tests
" report_id integer,"
" compliance text)"
" RETURNS integer AS $$"
" DECLARE count integer := 0;"
" BEGIN"
Expand Down
21 changes: 11 additions & 10 deletions src/manage_sql.c
Original file line number Diff line number Diff line change
Expand Up @@ -2037,7 +2037,7 @@ filter_control_str (keyword_t **point, const char *column, gchar **string)
* @param[out] levels String describing threat levels (message types)
* to include in count (for example, "hmlg" for
* High, Medium, Low and loG). All levels if NULL.
* @param[out] comliance_levels String describing compliance levels
* @param[out] compliance_levels String describing compliance levels
* to include in count (for example, "yniu" for
* "yes" (compliant), "n" for "no" (not compliant),
* "i" for "incomplete" and "u" for "undefined"
Expand Down Expand Up @@ -21969,22 +21969,22 @@ report_add_results_array (report_t report, GArray *results)
KEYWORD_TYPE_INTEGER \
}, \
{ \
"compliance_count (id, 'YES')", \
"report_compliance_count (id, 'YES')", \
"compliance_yes", \
KEYWORD_TYPE_INTEGER \
}, \
{ \
"compliance_count (id, 'NO')", \
"report_compliance_count (id, 'NO')", \
"compliance_no", \
KEYWORD_TYPE_INTEGER \
}, \
{ \
"compliance_count (id, 'INCOMPLETE')", \
"report_compliance_count (id, 'INCOMPLETE')", \
"compliance_incomplete", \
KEYWORD_TYPE_INTEGER \
}, \
{ \
"compliance_status (id)", \
"report_compliance_status (id)", \
"compliant", \
KEYWORD_TYPE_STRING \
}, \
Expand Down Expand Up @@ -22032,7 +22032,8 @@ where_compliance_status (const char *compliance)
compliance_sql = g_string_new ("");
count = 0;

Check warning on line 22033 in src/manage_sql.c

View check run for this annotation

Codecov / codecov/patch

src/manage_sql.c#L22032-L22033

Added lines #L22032 - L22033 were not covered by tests

g_string_append_printf (compliance_sql, " AND compliance_status(reports.id) IN (");
g_string_append_printf (compliance_sql,

Check warning on line 22035 in src/manage_sql.c

View check run for this annotation

Codecov / codecov/patch

src/manage_sql.c#L22035

Added line #L22035 was not covered by tests
" AND report_compliance_status(reports.id) IN (");

if (strchr (compliance, 'y'))
{
Expand All @@ -22057,9 +22058,9 @@ where_compliance_status (const char *compliance)

g_string_append (compliance_sql, ")");

Check warning on line 22059 in src/manage_sql.c

View check run for this annotation

Codecov / codecov/patch

src/manage_sql.c#L22059

Added line #L22059 was not covered by tests

if (count == 4)
if ((count == 4) || (count == 0))
{
/* All compliance levels selected. */
/* All compliance levels or no valid ones selected. */
g_string_free (compliance_sql, TRUE);
return NULL;

Check warning on line 22065 in src/manage_sql.c

View check run for this annotation

Codecov / codecov/patch

src/manage_sql.c#L22064-L22065

Added lines #L22064 - L22065 were not covered by tests
}
Expand Down Expand Up @@ -22399,9 +22400,9 @@ where_compliance_levels (const char *levels)
}
g_string_append (levels_sql, ")");

if (count == 4)
if ((count == 4) || (count == 0))
{
/* All compliance levels selected, so no restriction is necessary. */
/* All compliance levels or none selected, so no restriction is necessary. */
g_string_free (levels_sql, TRUE);
return NULL;
}
Expand Down

0 comments on commit e3a9627

Please sign in to comment.