Draft: feat: security archival group compatibility
Relates to issue #578803
Changes
This MR implements compatibility between security-related features and group archival functionality. The implementation ensures that when a group is archived, all security data (vulnerabilities, SBOM occurrences, security statistics) from projects within that group are properly filtered and hidden.
Model Scope Updates
-
Vulnerabilities::Read.unarchived: Updated to check both denormalized
archivedcolumn AND group archival status using ancestor-aware implementation - Vulnerabilities::Statistic.unarchived: Enhanced with ancestor-aware implementation to respect group hierarchy
- Sbom::Occurrence.unarchived: Modified to join with projects and check group archival status
- Security::AnalyzerProjectStatus.unarchived: Updated to use ancestor-aware archival checks
Model Method Updates
-
Security::ProjectStatistics: Updated
sum_vulnerability_count_for_groupto use the enhanced unarchived scope -
EE::Group: Added documentation to
vulnerabilities,vulnerability_scanners, andsbom_occurrencesmethods noting ancestor-aware behavior -
Vulnerabilities::Identifier: Updated
for_groupwith ancestor-aware documentation -
Vulnerabilities::ProjectsGrade: Modified
unarchived_projects_forto useself_and_ancestors_non_archivedand documentedaggregated_vulnerability_stats_for
Finder Updates
- Security::VulnerabilityReadsFinder: Enhanced documentation to clarify ancestor-aware filtering behavior
-
Security::SecurityPolicyProjectsFinder: Updated
base_relationto useself_and_ancestors_non_archived
Service Updates
-
Inventory Filter Services: Updated
VulnerabilityStatisticsUpdateServiceandAnalyzerStatusUpdateServiceto useproject.self_or_ancestors_archived? -
Vulnerability Services: Modified
Vulnerabilities::Statistics::UpdateServiceandVulnerabilities::Reads::UpsertServiceto check ancestor archival status -
Ingestion Tasks: Updated all ingestion tasks (
IngestVulnerabilityReads,IngestVulnerabilityStatistics,IngestOccurrences) to use ancestor-aware archival checks -
Schedule Services: Enhanced
ScheduleMarkDroppedAsResolvedServiceto useself_and_ancestors_non_archived
Implementation Pattern
All changes follow a consistent, backward-compatible pattern:
-
Scopes: Replace
where(archived: false)with ancestor-aware implementation usingGroup.self_or_ancestors_archived_setting_subquery -
Service Methods: Replace
project.archivedwithproject.self_or_ancestors_archived? -
Project Scopes: Replace
Project.non_archivedwithProject.self_and_ancestors_non_archived
Key Benefits
-
Backward Compatible: Denormalized
archivedcolumns are still updated, providing a safety net - Ancestor-Aware: Queries now properly check both project-level AND group-level archival status across the entire hierarchy
- Performance: Uses existing indexes and subqueries efficiently
- Consistent: All security features now handle group archival uniformly
Status
This MR completes tasks 1-33 of the implementation plan. The remaining tasks (34-47) follow the same established pattern and include updates to archival/restoration tasks, background migrations, and additional workers.
Edited by Matt Andrews