Class: Package::Audit::RiskCalculator

Inherits:
Object
  • Object
show all
Defined in:
lib/package/audit/services/risk_calculator.rb

Instance Method Summary collapse

Constructor Details

#initialize(pkg) ⇒ RiskCalculator

Returns a new instance of RiskCalculator.



9
10
11
# File 'lib/package/audit/services/risk_calculator.rb', line 9

def initialize(pkg)
  @pkg = pkg
end

Instance Method Details

#findObject



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/package/audit/services/risk_calculator.rb', line 13

def find
  risks = assess_vulnerability_risks + assess_deprecation_risks + assess_version_risks

  unless production_dependency?
    risks.each_with_index do |risk, index|
      risks[index] =
        [risk, Risk.new(Enum::RiskType::LOW, risk.explanation)].min || Risk.new(Enum::RiskType::NONE)
    end
  end
  risks
end