Commit 0342efb5 authored by Jonathan Schafer's avatar Jonathan Schafer

Move feature check to API code

The check needs to be after the vulnerability is retrieved and before
the response is rendered.
parent 986beb89
...@@ -6,9 +6,7 @@ module API ...@@ -6,9 +6,7 @@ module API
extend ActiveSupport::Concern extend ActiveSupport::Concern
included do included do
after do before do
not_found! unless Feature.enabled?(:first_class_vulnerabilities, @project)
authenticate! authenticate!
end end
end end
......
...@@ -33,9 +33,8 @@ module API ...@@ -33,9 +33,8 @@ module API
success EE::API::Entities::Vulnerability success EE::API::Entities::Vulnerability
end end
get ':id' do get ':id' do
vulnerability = Vulnerability.find(params[:id]) vulnerability = find_and_authorize_vulnerability!(:read_vulnerability)
@project = vulnerability.project break not_found! unless Feature.enabled?(:first_class_vulnerabilities, vulnerability.project)
authorize_vulnerability!(vulnerability, :read_vulnerability)
render_vulnerability(vulnerability) render_vulnerability(vulnerability)
end end
...@@ -44,7 +43,7 @@ module API ...@@ -44,7 +43,7 @@ module API
end end
post ':id/resolve' do post ':id/resolve' do
vulnerability = find_and_authorize_vulnerability!(:admin_vulnerability) vulnerability = find_and_authorize_vulnerability!(:admin_vulnerability)
@project = vulnerability.project break not_found! unless Feature.enabled?(:first_class_vulnerabilities, vulnerability.project)
break not_modified! if vulnerability.resolved? break not_modified! if vulnerability.resolved?
vulnerability = ::Vulnerabilities::ResolveService.new(current_user, vulnerability).execute vulnerability = ::Vulnerabilities::ResolveService.new(current_user, vulnerability).execute
...@@ -56,7 +55,7 @@ module API ...@@ -56,7 +55,7 @@ module API
end end
post ':id/dismiss' do post ':id/dismiss' do
vulnerability = find_and_authorize_vulnerability!(:admin_vulnerability) vulnerability = find_and_authorize_vulnerability!(:admin_vulnerability)
@project = vulnerability.project break not_found! unless Feature.enabled?(:first_class_vulnerabilities, vulnerability.project)
break not_modified! if vulnerability.dismissed? break not_modified! if vulnerability.dismissed?
vulnerability = ::Vulnerabilities::DismissService.new(current_user, vulnerability).execute vulnerability = ::Vulnerabilities::DismissService.new(current_user, vulnerability).execute
...@@ -68,7 +67,7 @@ module API ...@@ -68,7 +67,7 @@ module API
end end
post ':id/confirm' do post ':id/confirm' do
vulnerability = find_and_authorize_vulnerability!(:admin_vulnerability) vulnerability = find_and_authorize_vulnerability!(:admin_vulnerability)
@project = vulnerability.project break not_found! unless Feature.enabled?(:first_class_vulnerabilities, vulnerability.project)
break not_modified! if vulnerability.confirmed? break not_modified! if vulnerability.confirmed?
vulnerability = ::Vulnerabilities::ConfirmService.new(current_user, vulnerability).execute vulnerability = ::Vulnerabilities::ConfirmService.new(current_user, vulnerability).execute
......
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