feat: support sending notifications for all system-cve pairs#2311
Draft
jdobes wants to merge 1 commit into
Draft
feat: support sending notifications for all system-cve pairs#2311jdobes wants to merge 1 commit into
jdobes wants to merge 1 commit into
Conversation
Contributor
SC Environment Impact AssessmentOverall Impact: 🟢 LOW View full reportSummary
Detailed Findings🟢 LOW ImpactFeature flag change detected
Required Actions
This assessment was automatically generated. Please review carefully and consult with the ROSA Core team for critical/high impact changes. |
Reviewer's GuideAdds support for sending per-system notifications for all system-CVE pairs, introduces corresponding notification types, updates queue processing logic to handle them without deduplication, wires the behavior behind a feature flag, and extends tests and DB schema accordingly. Sequence diagram for processing system CVE notifications in queuesequenceDiagram
participant Producer as Notificator
participant Queue as NotificatorQueue
participant DB as NotificationStore
participant Kafka as KafkaNotifier
Producer->>Producer: make_events_for_cve(cve_id)
Producer->>FeatureFlag: is_enabled(NEW_NOTIFICATIONS_FEATURE)
alt feature_flag_enabled
Producer->>Producer: add ALL_SYSTEM_NOTIFICATION
Producer->>Producer: check is_high_cvss_cve(cve_id)
Producer->>Producer: check is_critical_severity_cve(cve_id)
Producer->>Producer: check is_rule_cve(cve_id)
Producer->>Producer: check is_exploitable_cve(cve_id)
end
Producer-->>Queue: enqueue item with notif_events (may include system types)
loop for_each_queue_item
Queue->>Queue: _process_normal_queue()
loop for_each_notif_event
Queue->>Queue: is_system_notif = notif_event in SYSTEM_NOTIFICATION_TYPES
alt is_system_notif
Queue->>Queue: events = _create_notif_events(cve_id)
Queue->>Kafka: _send_kafka_notif(org_id, inventory_id, display_name, notif_event.value, events, loop)
Kafka-->>Queue: ack
else is_account_level_notif
Queue->>DB: _is_already_notified(rh_account_id, cve_id, notif_event)
DB-->>Queue: already_notified_flag
alt not_already_notified
Queue->>Queue: events = _create_notif_events(cve_id)
Queue->>Kafka: _send_kafka_notif(org_id, inventory_id, display_name, notif_event.value, events, loop)
Kafka-->>Queue: ack
Queue->>Queue: new_notified.add(notif_event)
else already_notified
Queue->>Queue: skip_notification
end
end
end
alt new_notified_not_empty
Queue->>DB: _register_notified_acc(cve_id, new_notified, rh_account_id)
DB-->>Queue: ack
end
end
Entity relationship diagram for notification enum and notified accountserDiagram
notified_accounts {
bigint rh_account_id
bigint cve_id
notification notification_type
timestamp notified_at
}
notification_enum {
text value
}
notification_enum ||--o{ notified_accounts : has_values
%% logical contents of notification_enum
notification_enum {
text new_cve_cvss
text new_cve_severity
text new_cve_security_rule
text any_cve_known_exploit
text new_cve_all
text new_system_cve_cvss
text new_system_cve_severity
text new_system_cve_security_rule
text any_system_cve_known_exploit
text new_system_cve_all
}
Class diagram for updated notification types and queue processingclassDiagram
class NotificationType {
<<enum>>
CVSS_NOTIFICATION
SEVERITY_NOTIFICATION
RULE_NOTIFICATION
EXPLOITS_NOTIFICATION
ALL_NOTIFICATION
CVSS_SYSTEM_NOTIFICATION
SEVERITY_SYSTEM_NOTIFICATION
RULE_SYSTEM_NOTIFICATION
EXPLOITS_SYSTEM_NOTIFICATION
ALL_SYSTEM_NOTIFICATION
}
class SYSTEM_NOTIFICATION_TYPES {
<<set>>
+NotificationType CVSS_SYSTEM_NOTIFICATION
+NotificationType SEVERITY_SYSTEM_NOTIFICATION
+NotificationType RULE_SYSTEM_NOTIFICATION
+NotificationType EXPLOITS_SYSTEM_NOTIFICATION
+NotificationType ALL_SYSTEM_NOTIFICATION
}
class Notificator {
+make_events_for_cve(cve_id)
+is_exploitable_cve(cve_id)
+is_high_cvss_cve(cve_id)
+is_critical_severity_cve(cve_id)
+is_rule_cve(cve_id)
}
class NotificatorQueue {
+_process_normal_queue()
+_is_already_notified(rh_account_id, cve_id, notif_event)
+_create_notif_events(cve_id)
+_send_kafka_notif(org_id, inventory_id, display_name, notif_type_value, events, loop)
+_register_notified_acc(cve_id, new_notified, rh_account_id)
}
class FeatureFlagClient {
+is_enabled(feature_name)
}
class NEW_NOTIFICATIONS_FEATURE {
<<constant>>
}
SYSTEM_NOTIFICATION_TYPES ..> NotificationType : contains
Notificator --> NotificationType : produces_events
Notificator --> FeatureFlagClient : uses
FeatureFlagClient --> NEW_NOTIFICATIONS_FEATURE : checks
NotificatorQueue --> NotificationType : consumes_events
NotificatorQueue --> SYSTEM_NOTIFICATION_TYPES : checks_membership
NotificatorQueue --> Notificator : calls_create_notif_events
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RHINENG-24196
Secure Coding Practices Checklist GitHub Link
Secure Coding Checklist
Summary by Sourcery
Add per-system CVE notification types and ensure they are generated, queued, and dispatched alongside existing account-level notifications.
New Features:
Enhancements:
Tests: