Skip to content

Add security policy yml validation

Alexander Turinske requested to merge 369006-add-policy-yaml-validation into master

What does this MR do and why?

Add security policy yml validation for .gitlab/security-policies/policy.yml file

  • for single file editor
  • conditionally register security policy schema for single file editor
  • do not toggle security policy schema on/off dynamically for if a user changes a filepath because it is an unlikely scenario
  • rename security policy schema for the policy editor to SecurityPolicyEditorSchema to prevent namespace collisions
  • pass up project.full_path from the backend
  • move shared util methods from ee/... to ~/editor/utils and update their names
  • condense security policy extension for CE and EE into one CE file

- use fileMatch field to apply a schema to a file at a particular path (e.g. /.gitlab/security-policies/policy.yml) and nowhere else (examples in monaco-yaml and the description of fileMatch in the docs)

Changelog: added

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

File Screenshots
.gitlab/security-policies/policy.yml file Screenshot_2023-09-07_at_15.10.20
other yml file Screenshot_2023-09-13_at_22.52.49

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Navigate to a project/group => Security => Policies => New policy => Create a new policy of any type => Merge the MR
  2. Navigate to the project created by creating the new policy => .gitlab/security-policies/policy.yml
  3. Verify the schema has been applied (e.g. hover over some properties, modify others)
  4. Navigate to another yml file
  5. Verify the schema has not been applied
  6. Navigate to another non-yml file
  7. Verify the schema has not been applied

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #369006 (closed)

Edited by Alexander Turinske

Merge request reports

Loading