Skip to content

Fix yaml schema validation for scan result policy

Alexander Turinske requested to merge 457789-fix-yaml-validation into master

What does this MR do and why?

Fix yaml schema validation for scan result policy

  • the name of the scan result policy was updated to approval policy
  • to allow for both names to work, the properties were moved into a shared reference (Add support for approval_settings and any_merge... (!130189 - merged))
  • update frontend to find properties in that shared reference
  • update frontend to fail gracefully for policies that are not in the schema
  • update tests to be more robust

Changelog: fixed

EE: true

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

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

Before After
Screenshot_2024-05-10_at_11.06.37 image

How to set up and validate locally

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

  1. Upload a GitLab Ultimate license
  2. Apply the following patch
Patch
diff --git a/app/assets/javascripts/editor/extensions/source_editor_security_policy_schema_ext.js b/app/assets/javascripts/editor/extensions/source_editor_security_policy_schema_ext.js
index 1647b0ec457c..684f9ef07dd9 100644
--- a/app/assets/javascripts/editor/extensions/source_editor_security_policy_schema_ext.js
+++ b/app/assets/javascripts/editor/extensions/source_editor_security_policy_schema_ext.js
@@ -63,6 +63,7 @@ export class SecurityPolicySchemaExtension {
         });
         const modelFileName = instance.getModel().uri.path.split('/').pop();
 
+        console.log(singlePolicySchema);
         registerSchema({
           uri: getSecurityPolicySchemaUrl({ namespacePath, namespaceType }),
           schema: singlePolicySchema,
  1. Navigate to a project => Secure => Policies => New policy
  2. Select Scan Execution policy => Open the developer console ( CMD + OPTION + k )
  3. Navigate to yaml mode
  4. Ignore the errors; they will be addressed in Security Policy yaml validation does not work w... (#461252 - closed).
  5. Verify the console log has the properties value
  6. Navigate back to the selector page => Select Merge request approval policy => Open the developer console ( CMD + OPTION + k )
  7. Navigate to yaml mode
  8. Ignore the errors; they will be addressed in Security Policy yaml validation does not work w... (#461252 - closed).
  9. Verify the console log has the properties value

Related to #457789 (closed)

Edited by Alexander Turinske

Merge request reports

Loading