Add advanced configuration to profile drawer

What does this MR do and why?

Add advanced configuration to profile drawer

Show the profile's configured settings in AdvancedConfigurationTable
under the Advanced configuration heading in the scan profile drawer's
read-only view. Show "None of this profile's triggers use analyzer
settings, so there is nothing to configure." when no enabled trigger
takes settings, and "No advanced configuration is set for this
profile." when triggers could take settings but none are set. Hide the
section for GitLab-recommended profiles and for profiles with no
enabled triggers.

Build the rows with classifyConfigurationVariables and reuse the table,
caption and nothing-to-configure text from ScanProfileDetailsModal, so
both views describe settings the same way. Check gitlabRecommended
directly rather than through canManage, which decides edit and delete
access.

Related to https://gitlab.com/gitlab-org/gitlab/-/issues/624191

References

Screenshots or screen recordings

Profile Before After
custom, with settings drawer-advanced-configuration-with-settings-before drawer-advanced-configuration-with-settings
custom, no settings drawer-advanced-configuration-no-settings-before drawer-advanced-configuration-no-settings
custom, no trigger takes settings heading and subtext only, as in the row above drawer-advanced-configuration-nothing-to-configure
GitLab-recommended drawer-advanced-configuration-recommended-profile-before drawer-advanced-configuration-recommended-profile

How to set up and validate locally

  1. git checkout 624191-add-empty-state-to-scan-profile-drawer-advanced-configuration
    echo "Feature.enable(:custom_scan_profiles_ui, Group.find(ID))" | gdk rails c
  2. have a GitLab Ultimate licence

  3. in the GraphQL explorer at /-/graphql-explorer, run this with <group id> set to a top-level group's ID. Variables cannot be added in the UI yet, so it creates one profile with variables, one without, and one whose only trigger takes no variables:

    expand for mutation
    mutation {
      withVariables: securityScanProfileCreate(input: {
        namespaceId: "gid://gitlab/Group/<group id>"
        scanType: SECRET_DETECTION
        name: "Secret detection with variables"
        description: "Sets analyzer variables"
        triggers: [
          { triggerType: GIT_PUSH_EVENT }
          { triggerType: DEFAULT_BRANCH_PIPELINE, configuration: { secretDetection: { imageSuffix: FIPS, excludedPaths: ["spec/fixtures/**"] } } }
          { triggerType: MERGE_REQUEST_PIPELINE, configuration: { secretDetection: { imageSuffix: FIPS, excludedPaths: ["spec/fixtures/**"] } } }
        ]
      }) {
        scanProfile { id name }
        errors
      }
      withoutVariables: securityScanProfileCreate(input: {
        namespaceId: "gid://gitlab/Group/<group id>"
        scanType: SECRET_DETECTION
        name: "Secret detection without variables"
        description: "Sets no analyzer variables"
        triggers: [{ triggerType: GIT_PUSH_EVENT }, { triggerType: DEFAULT_BRANCH_PIPELINE }]
      }) {
        scanProfile { id name }
        errors
      }
      pushTriggerOnly: securityScanProfileCreate(input: {
        namespaceId: "gid://gitlab/Group/<group id>"
        scanType: SECRET_DETECTION
        name: "Secret detection push trigger only"
        description: "Only the push trigger, which takes no analyzer variables"
        triggers: [{ triggerType: GIT_PUSH_EVENT }]
      }) {
        scanProfile { id name }
        errors
      }
    }
  4. go to that group => Secure => Security configuration

  5. next to Secret detection, select Manage profiles

to check each profile state

  1. select Secret Detection (default), and check that there is no Advanced configuration section under Scan triggers
  2. select Secret detection with variables, and check that Advanced configuration shows:
    • a table with Variable and Value columns
    • rows for imageSuffix and excludedPaths
  3. select Secret detection without variables, and check that Advanced configuration shows No advanced configuration is set for this profile.
  4. select Secret detection push trigger only, and check that Advanced configuration shows None of this profile's triggers use analyzer settings, so there is nothing to configure.

to run tests

yarn jest ee/spec/frontend/security_configuration/components/scan_profiles/scan_profile_detail_spec.js

MR acceptance checklist

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

Edited by Miranda Fluharty

Merge request reports

Loading
Loading