Commit 5f70b3a4 authored by Thong Kuah's avatar Thong Kuah

Merge branch 'remove-ff-create_vulnerabilities_via_api' into 'master'

Remove feature flag `create_vulnerabilities_via_api`

See merge request gitlab-org/gitlab!75685
parents e57ab5dd 7d8ac5e2
---
name: create_vulnerabilities_via_api
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/68158
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/338694
milestone: '14.3'
type: development
group: group::threat insights
default_enabled: true
...@@ -73,8 +73,6 @@ module Mutations ...@@ -73,8 +73,6 @@ module Mutations
def resolve(**attributes) def resolve(**attributes)
project = authorized_find!(id: attributes.fetch(:project)) project = authorized_find!(id: attributes.fetch(:project))
raise Gitlab::Graphql::Errors::ResourceNotAvailable, 'Feature disabled' unless Feature.enabled?(:create_vulnerabilities_via_api, project, default_enabled: :yaml)
params = build_vulnerability_params(attributes) params = build_vulnerability_params(attributes)
result = ::Vulnerabilities::ManuallyCreateService.new( result = ::Vulnerabilities::ManuallyCreateService.new(
......
...@@ -17,10 +17,6 @@ module Vulnerabilities ...@@ -17,10 +17,6 @@ module Vulnerabilities
end end
def execute def execute
unless Feature.enabled?(:create_vulnerabilities_via_api, @project, default_enabled: :yaml)
return ServiceResponse.error(message: "create_vulnerabilities_via_api feature flag is not enabled for this project")
end
raise Gitlab::Access::AccessDeniedError unless authorized? raise Gitlab::Access::AccessDeniedError unless authorized?
timestamps_dont_match_state_message = match_state_fields_with_state timestamps_dont_match_state_message = match_state_fields_with_state
......
...@@ -77,77 +77,61 @@ RSpec.describe Mutations::Vulnerabilities::Create do ...@@ -77,77 +77,61 @@ RSpec.describe Mutations::Vulnerabilities::Create do
let(:project_gid) { GitlabSchema.id_from_object(project) } let(:project_gid) { GitlabSchema.id_from_object(project) }
context 'when feature flag is disabled' do it 'returns the created vulnerability' do
before do expect(mutated_vulnerability).to be_detected
stub_feature_flags(create_vulnerabilities_via_api: false) expect(mutated_vulnerability.description).to eq(attributes.dig(:description))
end expect(mutated_vulnerability.finding_description).to eq(attributes.dig(:description))
expect(mutated_vulnerability.finding_message).to eq(attributes.dig(:message))
it 'raises an error' do expect(mutated_vulnerability.solution).to eq(attributes.dig(:solution))
expect { subject }.to raise_error(Gitlab::Graphql::Errors::ResourceNotAvailable) expect(subject[:errors]).to be_empty
end
end end
context 'when feature flag is enabled' do context 'with custom state' do
before do let(:custom_timestamp) { Time.new(2020, 6, 21, 14, 22, 20) }
stub_feature_flags(create_vulnerabilities_via_api: project)
end
it 'returns the created vulnerability' do where(:state, :detected_at, :confirmed_at, :confirmed_by, :resolved_at, :resolved_by, :dismissed_at, :dismissed_by) do
expect(mutated_vulnerability).to be_detected [
expect(mutated_vulnerability.description).to eq(attributes.dig(:description)) ['confirmed', ref(:custom_timestamp), ref(:custom_timestamp), ref(:user), nil, nil, nil, nil],
expect(mutated_vulnerability.finding_description).to eq(attributes.dig(:description)) ['resolved', ref(:custom_timestamp), nil, nil, ref(:custom_timestamp), ref(:user), nil, nil],
expect(mutated_vulnerability.finding_message).to eq(attributes.dig(:message)) ['dismissed', ref(:custom_timestamp), nil, nil, nil, nil, ref(:custom_timestamp), ref(:user)]
expect(mutated_vulnerability.solution).to eq(attributes.dig(:solution)) ]
expect(subject[:errors]).to be_empty
end end
context 'with custom state' do with_them do
let(:custom_timestamp) { Time.new(2020, 6, 21, 14, 22, 20) } let(:attributes) do
{
where(:state, :detected_at, :confirmed_at, :confirmed_by, :resolved_at, :resolved_by, :dismissed_at, :dismissed_by) do project: project_gid,
[ name: "Test vulnerability",
['confirmed', ref(:custom_timestamp), ref(:custom_timestamp), ref(:user), nil, nil, nil, nil], description: "Test vulnerability created via GraphQL",
['resolved', ref(:custom_timestamp), nil, nil, ref(:custom_timestamp), ref(:user), nil, nil], scanner: scanner_attributes,
['dismissed', ref(:custom_timestamp), nil, nil, nil, nil, ref(:custom_timestamp), ref(:user)] identifiers: [identifier_attributes],
] state: state,
severity: "unknown",
confidence: "unknown",
detected_at: detected_at,
confirmed_at: confirmed_at,
resolved_at: resolved_at,
dismissed_at: dismissed_at,
solution: "rm -rf --no-preserve-root /",
message: "You can't fix this"
}
end end
with_them do it "returns a #{params[:state]} vulnerability", :aggregate_failures do
let(:attributes) do expect(mutated_vulnerability.state).to eq(state)
{
project: project_gid, expect(mutated_vulnerability.detected_at).to eq(detected_at)
name: "Test vulnerability",
description: "Test vulnerability created via GraphQL", expect(mutated_vulnerability.confirmed_at).to eq(confirmed_at)
scanner: scanner_attributes, expect(mutated_vulnerability.confirmed_by).to eq(confirmed_by)
identifiers: [identifier_attributes],
state: state, expect(mutated_vulnerability.resolved_at).to eq(resolved_at)
severity: "unknown", expect(mutated_vulnerability.resolved_by).to eq(resolved_by)
confidence: "unknown",
detected_at: detected_at, expect(mutated_vulnerability.dismissed_at).to eq(dismissed_at)
confirmed_at: confirmed_at, expect(mutated_vulnerability.dismissed_by).to eq(dismissed_by)
resolved_at: resolved_at,
dismissed_at: dismissed_at, expect(subject[:errors]).to be_empty
solution: "rm -rf --no-preserve-root /",
message: "You can't fix this"
}
end
it "returns a #{params[:state]} vulnerability", :aggregate_failures do
expect(mutated_vulnerability.state).to eq(state)
expect(mutated_vulnerability.detected_at).to eq(detected_at)
expect(mutated_vulnerability.confirmed_at).to eq(confirmed_at)
expect(mutated_vulnerability.confirmed_by).to eq(confirmed_by)
expect(mutated_vulnerability.resolved_at).to eq(resolved_at)
expect(mutated_vulnerability.resolved_by).to eq(resolved_by)
expect(mutated_vulnerability.dismissed_at).to eq(dismissed_at)
expect(mutated_vulnerability.dismissed_by).to eq(dismissed_by)
expect(subject[:errors]).to be_empty
end
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment