From 081f44cd0e9d0a6b35e1d50f82237868c512e27f Mon Sep 17 00:00:00 2001
From: Savas Vedova <svedova@gitlab.com>
Date: Fri, 12 Apr 2024 15:26:20 +0200
Subject: [PATCH] Remove deprecated confidence field from GraphQL

The confidence field was deprecated in 15.4. These changes
remove the field completely.

Changelog: removed
EE: true
---
 .rubocop_todo/layout/line_length.yml              |  1 -
 .rubocop_todo/rspec/feature_category.yml          |  1 -
 .rubocop_todo/style/hash_each_methods.yml         |  1 -
 doc/api/graphql/reference/index.md                | 15 ---------------
 .../graphql/mutations/vulnerabilities/create.rb   |  9 ---------
 .../types/vulnerability_confidence_enum.rb        | 12 ------------
 .../types/vulnerability_confidence_enum_spec.rb   |  9 ---------
 .../mutations/vulnerabilities/create_spec.rb      |  1 -
 .../admin_vulnerability/request_spec.rb           |  3 ---
 spec/support/rspec_order_todo.yml                 |  1 -
 10 files changed, 53 deletions(-)
 delete mode 100644 ee/app/graphql/types/vulnerability_confidence_enum.rb
 delete mode 100644 ee/spec/graphql/types/vulnerability_confidence_enum_spec.rb

diff --git a/.rubocop_todo/layout/line_length.yml b/.rubocop_todo/layout/line_length.yml
index 47027f55f729..65c36a16a58f 100644
--- a/.rubocop_todo/layout/line_length.yml
+++ b/.rubocop_todo/layout/line_length.yml
@@ -776,7 +776,6 @@ Layout/LineLength:
     - 'ee/app/graphql/types/security_report_summary_section_type.rb'
     - 'ee/app/graphql/types/vulnerabilities_count_by_day_type.rb'
     - 'ee/app/graphql/types/vulnerability/external_issue_link_external_tracker_enum.rb'
-    - 'ee/app/graphql/types/vulnerability_confidence_enum.rb'
     - 'ee/app/graphql/types/vulnerability_detail_type.rb'
     - 'ee/app/graphql/types/vulnerability_type.rb'
     - 'ee/app/helpers/admin/emails_helper.rb'
diff --git a/.rubocop_todo/rspec/feature_category.yml b/.rubocop_todo/rspec/feature_category.yml
index a3cfd7378434..6baa1cbeba2a 100644
--- a/.rubocop_todo/rspec/feature_category.yml
+++ b/.rubocop_todo/rspec/feature_category.yml
@@ -357,7 +357,6 @@ RSpec/FeatureCategory:
     - 'ee/spec/graphql/types/vulnerability/external_issue_link_type_spec.rb'
     - 'ee/spec/graphql/types/vulnerability/issue_link_type_enum_spec.rb'
     - 'ee/spec/graphql/types/vulnerability/issue_link_type_spec.rb'
-    - 'ee/spec/graphql/types/vulnerability_confidence_enum_spec.rb'
     - 'ee/spec/graphql/types/vulnerability_detail_type_spec.rb'
     - 'ee/spec/graphql/types/vulnerability_details/base_type_spec.rb'
     - 'ee/spec/graphql/types/vulnerability_details/boolean_type_spec.rb'
diff --git a/.rubocop_todo/style/hash_each_methods.yml b/.rubocop_todo/style/hash_each_methods.yml
index 97e2cb8645a6..03be8f07ee71 100644
--- a/.rubocop_todo/style/hash_each_methods.yml
+++ b/.rubocop_todo/style/hash_each_methods.yml
@@ -39,7 +39,6 @@ Style/HashEachMethods:
     - 'ee/app/graphql/types/vulnerability/external_issue_link_external_tracker_enum.rb'
     - 'ee/app/graphql/types/vulnerability/external_issue_link_type_enum.rb'
     - 'ee/app/graphql/types/vulnerability/issue_link_type_enum.rb'
-    - 'ee/app/graphql/types/vulnerability_confidence_enum.rb'
     - 'ee/app/graphql/types/vulnerability_grade_enum.rb'
     - 'ee/app/graphql/types/vulnerability_report_type_enum.rb'
     - 'ee/app/graphql/types/vulnerability_severities_count_type.rb'
diff --git a/doc/api/graphql/reference/index.md b/doc/api/graphql/reference/index.md
index 4fdc2b462863..b650bfc6478a 100644
--- a/doc/api/graphql/reference/index.md
+++ b/doc/api/graphql/reference/index.md
@@ -9089,7 +9089,6 @@ Input type: `VulnerabilityCreateInput`
 | Name | Type | Description |
 | ---- | ---- | ----------- |
 | <a id="mutationvulnerabilitycreateclientmutationid"></a>`clientMutationId` | [`String`](#string) | A unique identifier for the client performing the mutation. |
-| <a id="mutationvulnerabilitycreateconfidence"></a>`confidence` **{warning-solid}** | [`VulnerabilityConfidence`](#vulnerabilityconfidence) | **Deprecated:** This field will be removed from the Vulnerability domain model. Deprecated in GitLab 15.4. |
 | <a id="mutationvulnerabilitycreateconfirmedat"></a>`confirmedAt` | [`Time`](#time) | Timestamp of when the vulnerability state changed to confirmed (defaults to creation time if status is `confirmed`). |
 | <a id="mutationvulnerabilitycreatedescription"></a>`description` | [`String!`](#string) | Long text section that describes the vulnerability in more detail. |
 | <a id="mutationvulnerabilitycreatedetectedat"></a>`detectedAt` | [`Time`](#time) | Timestamp of when the vulnerability was first detected (defaults to creation time). |
@@ -33980,20 +33979,6 @@ Determines whether the pipeline list shows ID or IID.
 | <a id="visibilityscopesenumprivate"></a>`private` | Snippet is visible only to the snippet creator. |
 | <a id="visibilityscopesenumpublic"></a>`public` | Snippet can be accessed without any authentication. |
 
-### `VulnerabilityConfidence`
-
-Confidence that a given vulnerability is present in the codebase.
-
-| Value | Description |
-| ----- | ----------- |
-| <a id="vulnerabilityconfidenceconfirmed"></a>`CONFIRMED` | Confirmed confidence. |
-| <a id="vulnerabilityconfidenceexperimental"></a>`EXPERIMENTAL` | Experimental confidence. |
-| <a id="vulnerabilityconfidencehigh"></a>`HIGH` | High confidence. |
-| <a id="vulnerabilityconfidenceignore"></a>`IGNORE` | Ignore confidence. |
-| <a id="vulnerabilityconfidencelow"></a>`LOW` | Low confidence. |
-| <a id="vulnerabilityconfidencemedium"></a>`MEDIUM` | Medium confidence. |
-| <a id="vulnerabilityconfidenceunknown"></a>`UNKNOWN` | Unknown confidence. |
-
 ### `VulnerabilityDismissalReason`
 
 The dismissal reason of the Vulnerability.
diff --git a/ee/app/graphql/mutations/vulnerabilities/create.rb b/ee/app/graphql/mutations/vulnerabilities/create.rb
index 8b3824780c4f..708e970b520f 100644
--- a/ee/app/graphql/mutations/vulnerabilities/create.rb
+++ b/ee/app/graphql/mutations/vulnerabilities/create.rb
@@ -37,15 +37,6 @@ class Create < BaseMutation
         description: 'Severity of the vulnerability (defaults to `unknown`).',
         default_value: 'unknown'
 
-      argument :confidence, Types::VulnerabilityConfidenceEnum,
-        required: false,
-        description: 'Confidence of the vulnerability (defaults to `unknown`).',
-        default_value: 'unknown',
-        deprecated: {
-          reason: 'This field will be removed from the Vulnerability domain model',
-          milestone: '15.4'
-        }
-
       argument :solution, GraphQL::Types::String,
         required: false,
         description: 'Instructions for how to fix the vulnerability.'
diff --git a/ee/app/graphql/types/vulnerability_confidence_enum.rb b/ee/app/graphql/types/vulnerability_confidence_enum.rb
deleted file mode 100644
index 3895a03bd2cf..000000000000
--- a/ee/app/graphql/types/vulnerability_confidence_enum.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-# frozen_string_literal: true
-
-module Types
-  class VulnerabilityConfidenceEnum < BaseEnum
-    graphql_name 'VulnerabilityConfidence'
-    description 'Confidence that a given vulnerability is present in the codebase.'
-
-    ::Enums::Vulnerability.confidence_levels.keys.each do |confidence_level|
-      value confidence_level.to_s.upcase, value: confidence_level.to_s, description: "#{confidence_level.to_s.titleize} confidence"
-    end
-  end
-end
diff --git a/ee/spec/graphql/types/vulnerability_confidence_enum_spec.rb b/ee/spec/graphql/types/vulnerability_confidence_enum_spec.rb
deleted file mode 100644
index eca400236361..000000000000
--- a/ee/spec/graphql/types/vulnerability_confidence_enum_spec.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe GitlabSchema.types['VulnerabilityConfidence'] do
-  it 'exposes all vulnerability confidence values' do
-    expect(described_class.values.keys).to match_array(%w[IGNORE UNKNOWN EXPERIMENTAL LOW MEDIUM HIGH CONFIRMED])
-  end
-end
diff --git a/ee/spec/requests/api/graphql/mutations/vulnerabilities/create_spec.rb b/ee/spec/requests/api/graphql/mutations/vulnerabilities/create_spec.rb
index ca1dc83bb15e..61ec200479b5 100644
--- a/ee/spec/requests/api/graphql/mutations/vulnerabilities/create_spec.rb
+++ b/ee/spec/requests/api/graphql/mutations/vulnerabilities/create_spec.rb
@@ -27,7 +27,6 @@
       }],
       state: "DETECTED",
       severity: "UNKNOWN",
-      confidence: "UNKNOWN",
       solution: "rm -rf --no-preserve-root /",
       message: "You can't fix this"
     }
diff --git a/ee/spec/requests/custom_roles/admin_vulnerability/request_spec.rb b/ee/spec/requests/custom_roles/admin_vulnerability/request_spec.rb
index ba9eed48e504..48f765d58a79 100644
--- a/ee/spec/requests/custom_roles/admin_vulnerability/request_spec.rb
+++ b/ee/spec/requests/custom_roles/admin_vulnerability/request_spec.rb
@@ -48,7 +48,6 @@
     let_it_be(:security_finding) do
       create(:security_finding, {
         severity: report_finding.severity,
-        confidence: report_finding.confidence,
         uuid: report_finding.uuid,
         scan: scan
       })
@@ -86,7 +85,6 @@
     let_it_be(:security_finding) do
       create(:security_finding, {
         severity: report_finding.severity,
-        confidence: report_finding.confidence,
         uuid: report_finding.uuid,
         scan: scan
       })
@@ -219,7 +217,6 @@
         }],
         state: "DETECTED",
         severity: "UNKNOWN",
-        confidence: "UNKNOWN",
         solution: "curl -s 'https://unpkg.com/emoji.json@13.1.0/emoji.json' | jq -r '.[] | .char'",
         message: "example"
       }), current_user: user)
diff --git a/spec/support/rspec_order_todo.yml b/spec/support/rspec_order_todo.yml
index f9c8bf894d3e..c103a96552a6 100644
--- a/spec/support/rspec_order_todo.yml
+++ b/spec/support/rspec_order_todo.yml
@@ -802,7 +802,6 @@
 - './ee/spec/graphql/types/vulnerabilities/container_image_type_spec.rb'
 - './ee/spec/graphql/types/vulnerabilities_count_by_day_type_spec.rb'
 - './ee/spec/graphql/types/vulnerabilities/link_type_spec.rb'
-- './ee/spec/graphql/types/vulnerability_confidence_enum_spec.rb'
 - './ee/spec/graphql/types/vulnerability_details/base_type_spec.rb'
 - './ee/spec/graphql/types/vulnerability_details/boolean_type_spec.rb'
 - './ee/spec/graphql/types/vulnerability_details/code_type_spec.rb'
-- 
GitLab