Add profile_based_update_service for analyzer statuses updates
What does this MR do and why?
Fix profile-based analyzer status updates not taking effect for SAST and DS.
Previously, attaching or detaching new type of security scan profile (SAST, dependency scanning) had no effect on Security::AnalyzerProjectStatus, causing the statuses not to update.
This MR introduces ProfileBasedUpdateService to handle the profile-based types. It sets changes status only if no existing pipeline result exists (build_id: nil) to preserve existing result.
Shared basic logic is extracted into BaseUpdateService to eliminate duplication between ProfileBasedUpdateService and SettingsBasedUpdateService.
Changelog: added
EE: true
How to set up and validate locally
- Create a root group
rootand subgroupgwith projectp. - Ensure no SAST scan profile is attached to project
p. - Verify their analyzer status is absent or
:not_configuredvia:project.analyzer_statuses.sast - In the UI, go to
rootsecurity inventory and make sure the SAST status is alsonot_configured. - Enable SAST scan profile FF:
::Feature.disable(:security_scan_profiles_sast) - Attach default SAST scan profile to one of the projects from the UI.
- Verify the project's SAST analyzer status is now
:successwith nobuild_idin the UI or using:project.analyzer_statuses.sast.first - Detach the profile and make sure the status changes back to
not_configured. - To verify pipeline results are not overridden, manually set to
successwithbuild_idon an analyzer status:project.analyzer_statuses.sast.first.update(status: "success", build: Ci::Build.last) - Attach and detach the profile to make sure the status doesn't change.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Related to #591256 (closed)