Commit 18c61c80 authored by Jonathan Schafer's avatar Jonathan Schafer

Remove `break` from `not_found` call, use `before`

parent 0002114e
...@@ -34,7 +34,7 @@ module API ...@@ -34,7 +34,7 @@ module API
end end
get ':id' do get ':id' do
vulnerability = find_and_authorize_vulnerability!(:read_vulnerability) vulnerability = find_and_authorize_vulnerability!(:read_vulnerability)
break not_found! unless Feature.enabled?(:first_class_vulnerabilities, vulnerability.project) not_found! unless Feature.enabled?(:first_class_vulnerabilities, vulnerability.project)
render_vulnerability(vulnerability) render_vulnerability(vulnerability)
end end
...@@ -44,9 +44,9 @@ module API ...@@ -44,9 +44,9 @@ 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)
break not_found! unless Feature.enabled?(:first_class_vulnerabilities, vulnerability.project) not_found! unless Feature.enabled?(:first_class_vulnerabilities, vulnerability.project)
break not_modified! if vulnerability.resolved? not_modified! if vulnerability.resolved?
vulnerability = ::Vulnerabilities::ResolveService.new(current_user, vulnerability).execute vulnerability = ::Vulnerabilities::ResolveService.new(current_user, vulnerability).execute
render_vulnerability(vulnerability) render_vulnerability(vulnerability)
...@@ -57,9 +57,9 @@ module API ...@@ -57,9 +57,9 @@ 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)
break not_found! unless Feature.enabled?(:first_class_vulnerabilities, vulnerability.project) not_found! unless Feature.enabled?(:first_class_vulnerabilities, vulnerability.project)
break not_modified! if vulnerability.dismissed? not_modified! if vulnerability.dismissed?
vulnerability = ::Vulnerabilities::DismissService.new(current_user, vulnerability).execute vulnerability = ::Vulnerabilities::DismissService.new(current_user, vulnerability).execute
render_vulnerability(vulnerability) render_vulnerability(vulnerability)
...@@ -70,9 +70,9 @@ module API ...@@ -70,9 +70,9 @@ 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)
break not_found! unless Feature.enabled?(:first_class_vulnerabilities, vulnerability.project) not_found! unless Feature.enabled?(:first_class_vulnerabilities, vulnerability.project)
break not_modified! if vulnerability.confirmed? not_modified! if vulnerability.confirmed?
vulnerability = ::Vulnerabilities::ConfirmService.new(current_user, vulnerability).execute vulnerability = ::Vulnerabilities::ConfirmService.new(current_user, vulnerability).execute
render_vulnerability(vulnerability) render_vulnerability(vulnerability)
...@@ -86,12 +86,13 @@ module API ...@@ -86,12 +86,13 @@ module API
desc 'Get a list of project vulnerabilities' do desc 'Get a list of project vulnerabilities' do
success EE::API::Entities::Vulnerability success EE::API::Entities::Vulnerability
end end
before do
not_found! unless Feature.enabled?(:first_class_vulnerabilities, user_project)
end
params do params do
use :pagination use :pagination
end end
get ':id/vulnerabilities' do get ':id/vulnerabilities' do
break not_found! unless Feature.enabled?(:first_class_vulnerabilities, user_project)
authorize! :read_vulnerability, user_project authorize! :read_vulnerability, user_project
vulnerabilities = paginate( vulnerabilities = paginate(
...@@ -108,8 +109,6 @@ module API ...@@ -108,8 +109,6 @@ module API
requires :finding_id, type: Integer, desc: 'The id of confirmed vulnerability finding' requires :finding_id, type: Integer, desc: 'The id of confirmed vulnerability finding'
end end
post ':id/vulnerabilities' do post ':id/vulnerabilities' do
break not_found! unless Feature.enabled?(:first_class_vulnerabilities, user_project)
authorize! :create_vulnerability, user_project authorize! :create_vulnerability, user_project
vulnerability = ::Vulnerabilities::CreateService.new( vulnerability = ::Vulnerabilities::CreateService.new(
......
...@@ -33,7 +33,7 @@ module API ...@@ -33,7 +33,7 @@ module API
end end
get ':id/issue_links' do get ':id/issue_links' do
vulnerability = find_and_authorize_vulnerability!(:read_vulnerability) vulnerability = find_and_authorize_vulnerability!(:read_vulnerability)
break not_found! unless Feature.enabled?(:first_class_vulnerabilities, vulnerability.project) not_found! unless Feature.enabled?(:first_class_vulnerabilities, vulnerability.project)
present vulnerability present vulnerability
.related_issues .related_issues
...@@ -51,7 +51,7 @@ module API ...@@ -51,7 +51,7 @@ module API
end end
post ':id/issue_links' do post ':id/issue_links' do
vulnerability = find_and_authorize_vulnerability!(:admin_vulnerability_issue_link) vulnerability = find_and_authorize_vulnerability!(:admin_vulnerability_issue_link)
break not_found! unless Feature.enabled?(:first_class_vulnerabilities, vulnerability.project) not_found! unless Feature.enabled?(:first_class_vulnerabilities, vulnerability.project)
issue = find_project_issue(params[:target_issue_iid], vulnerability.project_id) issue = find_project_issue(params[:target_issue_iid], vulnerability.project_id)
...@@ -69,7 +69,7 @@ module API ...@@ -69,7 +69,7 @@ module API
end end
delete ':id/issue_links/:issue_link_id' do delete ':id/issue_links/:issue_link_id' do
vulnerability = find_and_authorize_vulnerability!(:admin_vulnerability_issue_link) vulnerability = find_and_authorize_vulnerability!(:admin_vulnerability_issue_link)
break not_found! unless Feature.enabled?(:first_class_vulnerabilities, vulnerability.project) not_found! unless Feature.enabled?(:first_class_vulnerabilities, vulnerability.project)
issue_link = find_issue_link! issue_link = find_issue_link!
......
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