Commit e9481e4d authored by Rajendra Kadam's avatar Rajendra Kadam

Separate vulnerability and feature entities into own class files

parent 1c6e59fa
......@@ -832,89 +832,6 @@ module EE
expose :id, :project_id, :name
end
class Dependency < Grape::Entity
class Vulnerability < Grape::Entity
expose :name, :severity
end
expose :name, :version, :package_manager, :dependency_file_path
expose :dependency_file_path do |dependency|
dependency[:location][:path]
end
expose :vulnerabilities, using: Vulnerability, if: ->(_, opts) { can_read_vulnerabilities?(opts[:user], opts[:project]) }
private
def can_read_vulnerabilities?(user, project)
Ability.allowed?(user, :read_vulnerability, project)
end
end
class FeatureFlag < Grape::Entity
class Scope < Grape::Entity
expose :id
expose :active
expose :environment_scope
expose :strategies
expose :created_at
expose :updated_at
end
class DetailedScope < Scope
expose :name
end
expose :name
expose :description
expose :created_at
expose :updated_at
expose :scopes, using: Scope
end
class Vulnerability < Grape::Entity
expose :id
expose :title
expose :description
expose :state
expose :severity
expose :confidence
expose :report_type
expose :project, using: ::API::Entities::ProjectIdentity
expose :finding
expose :author_id
expose :updated_by_id
expose :last_edited_by_id
expose :resolved_by_id
expose :dismissed_by_id
expose :start_date
expose :due_date
expose :created_at
expose :updated_at
expose :last_edited_at
expose :resolved_at
expose :dismissed_at
end
class VulnerabilityRelatedIssue < ::API::Entities::IssueBasic
# vulnerability_link_* attributes come from joined Vulnerabilities::IssueLink record
expose :vulnerability_link_id
expose :vulnerability_link_type do |related_issue|
::Vulnerabilities::IssueLink.link_types.key(related_issue.vulnerability_link_type)
end
end
class VulnerabilityIssueLink < Grape::Entity
expose :vulnerability, using: ::EE::API::Entities::Vulnerability
expose :issue, using: ::API::Entities::IssueBasic
expose :link_type
end
module Analytics
module CodeReview
class MergeRequest < ::API::Entities::MergeRequestSimple
......
# frozen_string_literal: true
module EE
module API
module Entities
class Dependency < Grape::Entity
class Vulnerability < Grape::Entity
expose :name, :severity
end
expose :name, :version, :package_manager, :dependency_file_path
expose :dependency_file_path do |dependency|
dependency[:location][:path]
end
expose :vulnerabilities, using: Vulnerability, if: ->(_, opts) { can_read_vulnerabilities?(opts[:user], opts[:project]) }
private
def can_read_vulnerabilities?(user, project)
Ability.allowed?(user, :read_vulnerability, project)
end
end
end
end
end
# frozen_string_literal: true
module EE
module API
module Entities
class FeatureFlag < Grape::Entity
class Scope < Grape::Entity
expose :id
expose :active
expose :environment_scope
expose :strategies
expose :created_at
expose :updated_at
end
class DetailedScope < Scope
expose :name
end
expose :name
expose :description
expose :created_at
expose :updated_at
expose :scopes, using: Scope
end
end
end
end
# frozen_string_literal: true
module EE
module API
module Entities
class Vulnerability < Grape::Entity
expose :id
expose :title
expose :description
expose :state
expose :severity
expose :confidence
expose :report_type
expose :project, using: ::API::Entities::ProjectIdentity
expose :finding
expose :author_id
expose :updated_by_id
expose :last_edited_by_id
expose :resolved_by_id
expose :closed_by_id
expose :start_date
expose :due_date
expose :created_at
expose :updated_at
expose :last_edited_at
expose :resolved_at
expose :closed_at
end
end
end
end
# frozen_string_literal: true
module EE
module API
module Entities
class VulnerabilityIssueLink < Grape::Entity
expose :vulnerability, using: ::EE::API::Entities::Vulnerability
expose :issue, using: ::API::Entities::IssueBasic
expose :link_type
end
end
end
end
# frozen_string_literal: true
module EE
module API
module Entities
class VulnerabilityRelatedIssue < ::API::Entities::IssueBasic
# vulnerability_link_* attributes come from joined Vulnerabilities::IssueLink record
expose :vulnerability_link_id
expose :vulnerability_link_type do |related_issue|
::Vulnerabilities::IssueLink.link_types.key(related_issue.vulnerability_link_type)
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