vulnerability_feedback.rb 837 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
class VulnerabilityFeedback < ActiveRecord::Base
  belongs_to :project
  belongs_to :author, class_name: "User"
  belongs_to :issue
  belongs_to :pipeline, class_name: 'Ci::Pipeline', foreign_key: :pipeline_id

  attr_accessor :vulnerability_data

  enum feedback_type: { dismissal: 0, issue: 1 }
  enum category: { sast: 0, dependency_scanning: 1, container_scanning: 2, dast: 3 }

  validates :project, presence: true
  validates :author, presence: true
  validates :issue, presence: true, if: :issue?
15
  validates :vulnerability_data, presence: true, if: :issue?
16 17 18 19
  validates :feedback_type, presence: true
  validates :category, presence: true
  validates :project_fingerprint, presence: true, uniqueness: { scope: [:project_id, :category, :feedback_type] }

20
  scope :with_associations, -> { includes(:pipeline, :issue, :author) }
21
end