Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion manager.spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,24 @@ paths:
- $ref: '#/components/parameters/mssql'

/feature/cves_without_errata:
get:
summary: Get a feature flag status for CVEs without errata
description: >
Use this endpoint to get an enablement status of reporting CVEs that do not have advisories
(errata) for your customer account. If the feature is disabled, CVEs without advisories
will be hidden in outputs of all endpoints.
operationId: manager.feature_handler.GetCvesWithoutErrata.get
x-methodName: getCvesWithoutErrata
security:
- ApiKeyAuth: []
- BasicAuth: []
responses:
200:
description: CVEs without Errata feature enablement status.
content:
application/vnd.api+json:
schema:
$ref: '#/components/schemas/CvesWithoutErrataOut'
patch:
summary: Set a feature flag for CVEs without errata
description: >
Expand All @@ -889,7 +907,7 @@ paths:
content:
application/vnd.api+json:
schema:
$ref: '#/components/schemas/CvesWithoutErrataOut'
$ref: '#/components/schemas/CvesWithoutErrataPatchOut'

/notifications:
delete:
Expand Down Expand Up @@ -3932,6 +3950,18 @@ components:
type: number

CvesWithoutErrataOut:
type: object
properties:
cves_without_errata:
type: object
properties:
enabled:
type: boolean
required:
- cves_without_errata
- org_id

Comment on lines 3952 to +3963

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick (bug_risk): The response schema requires org_id but does not declare it under properties, so the OpenAPI contract omits the type and description of a field that the handler always returns. Generated clients and schema consumers therefore cannot reliably model the complete response shape.

Suggested fix: Add an org_id property, with its actual string type, to CvesWithoutErrataOut and mark enabled as required inside cves_without_errata if both fields are guaranteed in every response.

CvesWithoutErrataPatchOut:
type: object
properties:
updated:
Expand Down
17 changes: 17 additions & 0 deletions manager/feature_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from common.peewee_model import RHAccount
from manager.base import ApplicationException
from manager.base import DeleteRequest
from manager.base import GetRequest
from manager.base import PatchRequest
from manager.base import get_account_data
from manager.rbac_manager import RbacManager as RBAC
Expand All @@ -28,6 +29,22 @@ def handle_patch(cls, **kwargs):
return {"updated": {"org_id": org_id, "cves_without_errata": {"enabled": enable}}}


class GetCvesWithoutErrata(GetRequest):
"""GET to /feature/cves_without_errata"""

_endpoint_name = r"/v1/feature/cves_without_errata"

@classmethod
def handle_get(cls, **kwargs):
"""Get cves_without_errata DB flag for account."""
org_id = context.context["user"]["org_id"]
result = RHAccount.get_or_none(RHAccount.org_id == org_id)
cves_without_errata = True
if result is not None:
cves_without_errata = result.cves_without_errata
return {"cves_without_errata": {"enabled": cves_without_errata}, "org_id": org_id}


class DeleteNotifications(DeleteRequest):
"""DELETE to /notifications"""

Expand Down
Loading