Skip to content

Commit

Permalink
fix(manager): make cves_without_errata nullable to indicate global di…
Browse files Browse the repository at this point in the history
…sable

null - don't display any UI elements
false - display UI elements to enable FF, hide advisory_available filter
true - display UI elements to disable FF, show advisory_available filter
  • Loading branch information
jdobes committed Aug 1, 2023
1 parent 30807ba commit d26ead5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
5 changes: 3 additions & 2 deletions common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from datetime import timedelta
from datetime import timezone
from time import sleep
from typing import Optional

import asyncpg
import requests
Expand Down Expand Up @@ -400,6 +401,6 @@ async def executemany_fetchall(cur) -> []:
return res


def show_cves_without_errata(db_flag: bool) -> bool:
def show_cves_without_errata(db_flag: bool) -> Optional[bool]:
"""Show whether CVEs without Errata feature is enabled"""
return CFG.cves_without_errata and db_flag
return db_flag if CFG.cves_without_errata else None
6 changes: 3 additions & 3 deletions manager.spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1415,7 +1415,7 @@ components:
cves_without_errata:
type: boolean
description: CVEs without Errata feature flag
nullable: false
nullable: true
advisory_available:
type: string
description: Shows whether a CVE has available advisory or not
Expand Down Expand Up @@ -1478,7 +1478,7 @@ components:
cves_without_errata:
type: boolean
description: CVEs without Errata feature flag
nullable: false
nullable: true
group_name:
type: string
description: Name of the inventory group.
Expand Down Expand Up @@ -1591,7 +1591,7 @@ components:
cves_without_errata:
type: boolean
description: CVEs without Errata feature flag
nullable: false
nullable: true
required:
- business_risk_id
- cvss_from
Expand Down
2 changes: 1 addition & 1 deletion manager/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ def get_account_data(account):
result = list(result)
result[3] = show_cves_without_errata(result[3])
return result
return None, None, None, False
return None, None, None, None


def update_cve_cache_keepalive(account_id, last_timestamp):
Expand Down
6 changes: 3 additions & 3 deletions tests/manager_tests/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@
"rhel_version": Or(None, str),
"ansible": Or(None, bool),
"mssql": Or(None, bool),
"cves_without_errata": bool,
"cves_without_errata": Or(None, bool),
"advisory_available": Or(None, bool),
"group_id": Or(None, str),
"group_name": Or(None, str),
Expand Down Expand Up @@ -316,7 +316,7 @@
"first_reported_to": Or(None, str),
"advisory_available": Or(None, bool),
"remediation": Or(None, int),
"cves_without_errata": bool,
"cves_without_errata": Or(None, bool),
}
_system_cves_meta.update(_meta)

Expand Down Expand Up @@ -353,7 +353,7 @@
"remediation": Or(None, int),
"ansible": Or(None, bool),
"mssql": Or(None, bool),
"cves_without_errata": bool,
"cves_without_errata": Or(None, bool),
"group_id": Or(None, str),
"group_name": Or(None, str),
"ungrouped_hosts": Or(None, bool),
Expand Down

0 comments on commit d26ead5

Please sign in to comment.