Class: Fastlane::Helper::ConfigurationHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/fastlane/plugin/dependency_check_ios_analyzer/helper/configuration_helper.rb

Class Method Summary collapse

Class Method Details

.clean_up(params) ⇒ Object



46
47
48
49
50
# File 'lib/fastlane/plugin/dependency_check_ios_analyzer/helper/configuration_helper.rb', line 46

def self.clean_up(params)
  return if params[:keep_binary_on_exit]

  FileUtils.rm_rf("#{params[:output_directory]}/dependency-check")
end

.install(params) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/fastlane/plugin/dependency_check_ios_analyzer/helper/configuration_helper.rb', line 10

def self.install(params)
  repo = 'https://github.com/jeremylong/DependencyCheck'
  name = 'dependency-check'
  version = params[:cli_version] ? params[:cli_version] : '6.2.2'
  base_url = "#{repo}/releases/download/v#{version}/#{name}-#{version}-release"
  bin_path = "#{params[:output_directory]}/#{name}/bin/#{name}.sh"
  zip_path = "#{params[:output_directory]}/#{name}.zip"

  unless File.exist?(bin_path)
    FileUtils.mkdir_p(params[:output_directory])

    unless File.exist?(zip_path)
      zip_url = "#{base_url}.zip"
      UI.message("🚀 Downloading DependencyCheck: #{zip_url}")
      curl = Curl.get(zip_url) { |curl| curl.follow_location = true }
      File.open(zip_path, 'w+') { |f| f.write(curl.body_str) }
    end

    unzip(file: zip_path, params: params)

    FileUtils.rm_rf(zip_path)
  end

  bin_path
end

.parse_output_types(output_types) ⇒ Object



36
37
38
39
40
41
42
43
44
# File 'lib/fastlane/plugin/dependency_check_ios_analyzer/helper/configuration_helper.rb', line 36

def self.parse_output_types(output_types)
  list = output_types.delete(' ').split(',')
  list << 'sarif' unless output_types =~ (/(sarif|all)/)
  report_types = ''
  list.each { |output_type| report_types += " --format #{output_type.upcase}" }

  UI.message("🎥 Output types: #{list}")
  report_types
end