Class: Gitlab::Ci::Reports::Security::Reports

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/ci/reports/security/reports.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pipeline) ⇒ Reports

Returns a new instance of Reports.


12
13
14
15
# File 'lib/gitlab/ci/reports/security/reports.rb', line 12

def initialize(pipeline)
  @reports = {}
  @pipeline = pipeline
end

Instance Attribute Details

#pipelineObject (readonly)

Returns the value of attribute pipeline.


8
9
10
# File 'lib/gitlab/ci/reports/security/reports.rb', line 8

def pipeline
  @pipeline
end

#reportsObject (readonly)

Returns the value of attribute reports.


8
9
10
# File 'lib/gitlab/ci/reports/security/reports.rb', line 8

def reports
  @reports
end

Instance Method Details

#findingsObject


21
22
23
# File 'lib/gitlab/ci/reports/security/reports.rb', line 21

def findings
  reports.values.flat_map(&:findings)
end

#get_report(report_type, report_artifact) ⇒ Object


17
18
19
# File 'lib/gitlab/ci/reports/security/reports.rb', line 17

def get_report(report_type, report_artifact)
  reports[report_type] ||= Report.new(report_type, pipeline, report_artifact.created_at)
end

#unsafe_findings_uuids(severity_levels, report_types) ⇒ Object


29
30
31
# File 'lib/gitlab/ci/reports/security/reports.rb', line 29

def unsafe_findings_uuids(severity_levels, report_types)
  findings.select { |finding| finding.unsafe?(severity_levels, report_types) }.map(&:uuid)
end

#violates_default_policy_against?(target_reports, vulnerabilities_allowed, severity_levels, vulnerability_states, report_types = []) ⇒ Boolean

Returns:

  • (Boolean)

25
26
27
# File 'lib/gitlab/ci/reports/security/reports.rb', line 25

def violates_default_policy_against?(target_reports, vulnerabilities_allowed, severity_levels, vulnerability_states, report_types = [])
  unsafe_findings_count(target_reports, severity_levels, vulnerability_states, report_types) > vulnerabilities_allowed
end