Commit 3b2e49e6 authored by Fernando's avatar Fernando

Make feature flag scoping consistent

* Scope to instance
parent 1a2d8f8b
......@@ -19,6 +19,6 @@
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.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
......@@ -82,7 +82,7 @@ module Security
end
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
def existing_vulnerabilities
......
......@@ -114,7 +114,7 @@ module Security
def calculate_false_positive?
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
def filter(findings)
......
......@@ -94,7 +94,7 @@ module Types
private
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
# rubocop: enable Graphql/AuthorizeTypes
......
......@@ -160,7 +160,7 @@ module Types
private
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
......@@ -210,7 +210,7 @@ module EE
end
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
def can_update_security_orchestration_policy_project?(project)
......
......@@ -28,7 +28,7 @@ module Groups::SecurityFeaturesHelper
scanners: VulnerabilityScanners::ListService.new(group).execute.to_json,
can_admin_vulnerability: can?(current_user, :admin_vulnerability, group).to_s,
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
......@@ -62,7 +62,7 @@ class Vulnerabilities::FindingEntity < Grape::Entity
def expose_false_positive?
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
......
......@@ -59,7 +59,7 @@ module Security
update_vulnerabilities_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
end
......
......@@ -24,7 +24,7 @@
commit_path_template: commit_path_template(project),
can_admin_vulnerability: can?(current_user, :admin_vulnerability, project).to_s,
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') } }
- if pipeline.expose_license_scanning_data?
......
......@@ -7,5 +7,5 @@
#js-vulnerability-main{ data: { vulnerability: vulnerability_details_json(@vulnerability, @pipeline),
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) } }
......@@ -163,7 +163,7 @@ RSpec.describe GitlabSchema.types['Vulnerability'] do
stub_feature_flags(vulnerability_flags: false)
end
it 'retunrs nil' do
it 'returns nil' do
vulnerabilities = subject.dig('data', 'project', 'vulnerabilities', 'nodes')
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