Skip to content

DAST scans site profile: Fix inprogress transition

What does this MR do?

It fixes an issue that can occur in two different scenarios:

  1. Editing a DAST on-demand scans site profile, which is currently being validated
  2. Creating a new profile, which shares the URL of a profile that is currently being validated

Both cases will end up in an error state (without a token) if the validation fails:

edit_in_progress_to_failed

How to test this?

  1. Enable the feature flag.
echo "Feature.enable(:security_on_demand_scans_site_validation)" | rails c
  1. Install and setup graphql-vue-apollo-playground locally. Checkout the mock-dast-site-profiles branch and run the mock server.

  2. Use the local mock server in the Apollo provider.

diff --git a/ee/app/assets/javascripts/dast_site_profiles_form/graphql/provider.js b/ee/app/assets/javascripts/dast_site_profiles_form/graphql/provider.js
index ef96b443da8..993a7cefb5c 100644
--- a/ee/app/assets/javascripts/dast_site_profiles_form/graphql/provider.js
+++ b/ee/app/assets/javascripts/dast_site_profiles_form/graphql/provider.js
@@ -5,5 +5,10 @@ import createDefaultClient from '~/lib/graphql';
 Vue.use(VueApollo);
 
 export default new VueApollo({
-  defaultClient: createDefaultClient(),
+  defaultClient: createDefaultClient(
+    {},
+    {
+      baseUrl: 'http://localhost:4000',
+    },
+  ),
 });
  1. Set the status to states.INPROGRESS_VALIDATION within dast_site_validation.js (mock apollo server)

  2. Navigate to the DAST Site profile form in your GDK: /:namespace/:project/-/on_demand_scans/profiles/dast_site_profiles/new

  3. Fill out the form and enable validation

  4. Set the status to states.FAILED_VALIDATION within dast_site_validation.js (mock apollo server) note: if the change happens at the same time as the request hits the mock server there might be an error. Please try again. Increasing DAST_SITE_VALIDATION_POLL_INTERVAL within ee/app/assets/javascripts/security_configuration/dast_site_profiles_form/constants.js can help to reduce the chance of this.

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Edited by David Pisek

Merge request reports