Commit 3b2e49e6 authored by Fernando's avatar Fernando

Make feature flag scoping consistent

* Scope to instance
parent 1a2d8f8b
...@@ -19,6 +19,6 @@ ...@@ -19,6 +19,6 @@
window.gl.mrWidgetData.pipelines_empty_svg_path = '#{image_path('illustrations/pipelines_empty.svg')}'; window.gl.mrWidgetData.pipelines_empty_svg_path = '#{image_path('illustrations/pipelines_empty.svg')}';
window.gl.mrWidgetData.codequality_help_path = '#{help_page_path("user/project/merge_requests/code_quality", anchor: "code-quality-reports")}'; window.gl.mrWidgetData.codequality_help_path = '#{help_page_path("user/project/merge_requests/code_quality", anchor: "code-quality-reports")}';
window.gl.mrWidgetData.false_positive_doc_url = '#{help_page_path('user/application_security/vulnerabilities/index')}'; window.gl.mrWidgetData.false_positive_doc_url = '#{help_page_path('user/application_security/vulnerabilities/index')}';
window.gl.mrWidgetData.can_view_false_positive = '#{(Feature.enabled?(:vulnerability_flags, @merge_request.project, default_enabled: :yaml) && @merge_request.project.licensed_feature_available?(:sast_fp_reduction)).to_s}'; window.gl.mrWidgetData.can_view_false_positive = '#{(Feature.enabled?(:vulnerability_flags, default_enabled: :yaml) && @merge_request.project.licensed_feature_available?(:sast_fp_reduction)).to_s}';
#js-vue-mr-widget.mr-widget #js-vue-mr-widget.mr-widget
...@@ -82,7 +82,7 @@ module Security ...@@ -82,7 +82,7 @@ module Security
end end
def calculate_false_positive? def calculate_false_positive?
::Feature.enabled?(:vulnerability_flags, project, default_enabled: :yaml) && project.licensed_feature_available?(:sast_fp_reduction) ::Feature.enabled?(:vulnerability_flags, default_enabled: :yaml) && project.licensed_feature_available?(:sast_fp_reduction)
end end
def existing_vulnerabilities def existing_vulnerabilities
......
...@@ -114,7 +114,7 @@ module Security ...@@ -114,7 +114,7 @@ module Security
def calculate_false_positive? def calculate_false_positive?
project = pipeline.project project = pipeline.project
::Feature.enabled?(:vulnerability_flags, project, default_enabled: :yaml) && project.licensed_feature_available?(:sast_fp_reduction) ::Feature.enabled?(:vulnerability_flags, default_enabled: :yaml) && project.licensed_feature_available?(:sast_fp_reduction)
end end
def filter(findings) def filter(findings)
......
...@@ -94,7 +94,7 @@ module Types ...@@ -94,7 +94,7 @@ module Types
private private
def expose_false_positive? def expose_false_positive?
Feature.enabled?(:vulnerability_flags, object.project, default_enabled: :yaml) && object.project.licensed_feature_available?(:sast_fp_reduction) Feature.enabled?(:vulnerability_flags, default_enabled: :yaml) && object.project.licensed_feature_available?(:sast_fp_reduction)
end end
end end
# rubocop: enable Graphql/AuthorizeTypes # rubocop: enable Graphql/AuthorizeTypes
......
...@@ -160,7 +160,7 @@ module Types ...@@ -160,7 +160,7 @@ module Types
private private
def expose_false_positive? def expose_false_positive?
Feature.enabled?(:vulnerability_flags, object.project, default_enabled: :yaml) && object.project.licensed_feature_available?(:sast_fp_reduction) Feature.enabled?(:vulnerability_flags, default_enabled: :yaml) && object.project.licensed_feature_available?(:sast_fp_reduction)
end end
end end
end end
...@@ -210,7 +210,7 @@ module EE ...@@ -210,7 +210,7 @@ module EE
end end
def can_view_false_positive? def can_view_false_positive?
(::Feature.enabled?(:vulnerability_flags, project, default_enabled: :yaml) && project.licensed_feature_available?(:sast_fp_reduction)).to_s (::Feature.enabled?(:vulnerability_flags, default_enabled: :yaml) && project.licensed_feature_available?(:sast_fp_reduction)).to_s
end end
def can_update_security_orchestration_policy_project?(project) def can_update_security_orchestration_policy_project?(project)
......
...@@ -28,7 +28,7 @@ module Groups::SecurityFeaturesHelper ...@@ -28,7 +28,7 @@ module Groups::SecurityFeaturesHelper
scanners: VulnerabilityScanners::ListService.new(group).execute.to_json, scanners: VulnerabilityScanners::ListService.new(group).execute.to_json,
can_admin_vulnerability: can?(current_user, :admin_vulnerability, group).to_s, can_admin_vulnerability: can?(current_user, :admin_vulnerability, group).to_s,
false_positive_doc_url: help_page_path('user/application_security/vulnerabilities/index'), false_positive_doc_url: help_page_path('user/application_security/vulnerabilities/index'),
can_view_false_positive: (::Feature.enabled?(:vulnerability_flags, group, default_enabled: :yaml) && group.licensed_feature_available?(:sast_fp_reduction)).to_s can_view_false_positive: (::Feature.enabled?(:vulnerability_flags, default_enabled: :yaml) && group.licensed_feature_available?(:sast_fp_reduction)).to_s
} }
end end
end end
...@@ -62,7 +62,7 @@ class Vulnerabilities::FindingEntity < Grape::Entity ...@@ -62,7 +62,7 @@ class Vulnerabilities::FindingEntity < Grape::Entity
def expose_false_positive? def expose_false_positive?
project = occurrence.project project = occurrence.project
::Feature.enabled?(:vulnerability_flags, project, default_enabled: :yaml) && project.licensed_feature_available?(:sast_fp_reduction) ::Feature.enabled?(:vulnerability_flags, default_enabled: :yaml) && project.licensed_feature_available?(:sast_fp_reduction)
end end
end end
......
...@@ -59,7 +59,7 @@ module Security ...@@ -59,7 +59,7 @@ module Security
update_vulnerabilities_identifiers update_vulnerabilities_identifiers
update_vulnerabilities_finding_identifiers update_vulnerabilities_finding_identifiers
if ::Feature.enabled?(:vulnerability_flags, project, default_enabled: :yaml) && project.licensed_feature_available?(:sast_fp_reduction) if ::Feature.enabled?(:vulnerability_flags, default_enabled: :yaml) && project.licensed_feature_available?(:sast_fp_reduction)
create_vulnerability_flags_info create_vulnerability_flags_info
end end
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
commit_path_template: commit_path_template(project), commit_path_template: commit_path_template(project),
can_admin_vulnerability: can?(current_user, :admin_vulnerability, project).to_s, can_admin_vulnerability: can?(current_user, :admin_vulnerability, project).to_s,
false_positive_doc_url: help_page_path('user/application_security/vulnerabilities/index'), false_positive_doc_url: help_page_path('user/application_security/vulnerabilities/index'),
can_view_false_positive: (::Feature.enabled?(:vulnerability_flags, project, default_enabled: :yaml) && project.licensed_feature_available?(:sast_fp_reduction)).to_s, can_view_false_positive: (::Feature.enabled?(:vulnerability_flags, default_enabled: :yaml) && project.licensed_feature_available?(:sast_fp_reduction)).to_s,
security_report_help_page_link: help_page_path('user/application_security/index', anchor: 'security-report-validation') } } security_report_help_page_link: help_page_path('user/application_security/index', anchor: 'security-report-validation') } }
- if pipeline.expose_license_scanning_data? - if pipeline.expose_license_scanning_data?
......
...@@ -7,5 +7,5 @@ ...@@ -7,5 +7,5 @@
#js-vulnerability-main{ data: { vulnerability: vulnerability_details_json(@vulnerability, @pipeline), #js-vulnerability-main{ data: { vulnerability: vulnerability_details_json(@vulnerability, @pipeline),
false_positive_doc_url: help_page_path('user/application_security/vulnerabilities/index'), false_positive_doc_url: help_page_path('user/application_security/vulnerabilities/index'),
can_view_false_positive: (::Feature.enabled?(:vulnerability_flags, @project, default_enabled: :yaml) && @project.licensed_feature_available?(:sast_fp_reduction)).to_s, can_view_false_positive: (::Feature.enabled?(:vulnerability_flags, default_enabled: :yaml) && @project.licensed_feature_available?(:sast_fp_reduction)).to_s,
commit_path_template: commit_path_template(@project) } } commit_path_template: commit_path_template(@project) } }
...@@ -163,7 +163,7 @@ RSpec.describe GitlabSchema.types['Vulnerability'] do ...@@ -163,7 +163,7 @@ RSpec.describe GitlabSchema.types['Vulnerability'] do
stub_feature_flags(vulnerability_flags: false) stub_feature_flags(vulnerability_flags: false)
end end
it 'retunrs nil' do it 'returns nil' do
vulnerabilities = subject.dig('data', 'project', 'vulnerabilities', 'nodes') vulnerabilities = subject.dig('data', 'project', 'vulnerabilities', 'nodes')
expect(vulnerabilities.first['falsePositive']).to be_nil expect(vulnerabilities.first['falsePositive']).to be_nil
......
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