[BE] - Add project toggle for continuous vulnerability scans
Proposal
In order to implement [FE] - Add a setting to toggle CVS feature in the Security configuration page we need to do the following:
- Add a project attribute to toggle cvs on an doff
- Add a graphQL mutation to change this attribute
- Expose the enabled/disabled status of this attribute to frontend via a presenter
Implementation plan
- add new attribute to project security settings
Add setting for enabling Continuous Vulnerabili... (!131305 - merged)- add
continuous_vulnerability_scans_enabled
attribute to ProjectSecuritySetting- add
#toggle
to flip the value of this attribute
- add
- add migration to add
continuous_vulnerability_scans_enabled
column- bool type, defaults to
false
- bool type, defaults to
- add
- update presenter to show value of setting above
Add cvs toggle to security settings configurati... (!131315 - merged)- add
#continuous_vulnerability_scans_enabled
method calling the model above
- add
- create graphql mutation to allow toggle of this feature
Add a graphql mutation for toggling cvs (!131450 - merged)-
create mutation under security_configuration mutations
mutation ToggleContinuousVulnerabilityScans($input: ToggleContinuousVulnerabilityScans!) { toggleContinuousVulnerabilityScans(input: $input) { continuousVulnerabilityScanningEnabled errors } }
- with input
project_path:
andenable: [true|false]
- with input
-
add
set_continuous_vulnerability_scans
to https://gitlab.com/gitlab-org/gitlab/-/tree/e4a855925c08d3eaedf368db80769f4d8d74244d/ee/app/graphql/mutations/security/ci_configuration- authorize with
toggle_continuous_vulnerability_scans
(see authorization below) -
#resolve
- calls
ProjectSetting#toggle_continuous_vulnerability_scans
- returns project, user, and value of
ProjectSetting#continuous_vulnerability_scans_enabled
- calls
- authorize with
-
add
toggle_continuous_vulnerability_scans
authorization in https://gitlab.com/gitlab-org/gitlab/-/blob/e4a855925c08d3eaedf368db80769f4d8d74244d/ee/app/policies/ee/project_policy.rb- condition
rule { Feature.enabled?(:dependency_scanning_on_advisory_ingestion) & can?(:develeoper_access) }.enable :enable_continuous_vulnerability_scans
- condition
-
mount mutation in https://gitlab.com/gitlab-org/gitlab/-/blob/e4a855925c08d3eaedf368db80769f4d8d74244d/ee/app/graphql/ee/types/mutation_type.rb
-