Scan Execution Rule mode is not disabled for invalid cron syntax or cron syntax rule mode does not support

Summary

Scan Execution Rule mode is not disabled for invalid cron syntax

Steps to reproduce

  1. Upload a GitLab Ultimate license
  2. Navigate to a project => Security & Compliance => Policies => New policy => Scan Execution policy => yaml mode
  3. Copy/paste one of the below yaml into the text box
type: scan_execution_policy
name: ''
description: ''
enabled: true
rules:
  - type: schedule
    branches:
      - main
    cadence: 0 5 * * asdfasdf
actions:
  - scan: dast
    site_profile: ''
    scanner_profile: ''
type: scan_execution_policy
name: ''
description: ''
enabled: true
rules:
  - type: schedule
    branches:
      - main
    cadence: * 5 5 5 5
actions:
  - scan: dast
    site_profile: ''
    scanner_profile: ''
  1. Navigate to rule mode

Example Project

https://staging.gitlab.com/defend-team-test/cnp-alert-demo/-/security/policies/new?type=scan_execution_policy

What is the current bug behavior?

The rule mode is not disabled. So when a user changes a cron-related field in rule mode, the entire cron syntax is reset

What is the expected correct behavior?

The rule mode is disabled.

Relevant logs and/or screenshots

image

Possible fixes

Edited by Alexander Turinske