Class: Pipeline::BundleAudit

Inherits:
BaseTask show all
Includes:
Util
Defined in:
lib/pipeline/tasks/bundle-audit.rb

Instance Attribute Summary

Attributes inherited from BaseTask

#appname, #description, #findings, #labels, #name, #stage, #trigger, #warnings

Instance Method Summary collapse

Methods included from Util

#fingerprint, #relative_path, #runsystem, #strip_archive_path

Methods inherited from BaseTask

#directories_with?, #report, #severity, #warn

Constructor Details

#initialize(trigger, tracker) ⇒ BundleAudit

Returns a new instance of BundleAudit.



10
11
12
13
14
15
16
17
# File 'lib/pipeline/tasks/bundle-audit.rb', line 10

def initialize(trigger, tracker)
  super(trigger, tracker)
  @name = "BundleAudit"
  @description = "Dependency Checker analysis for Ruby"
  @stage = :code
  @labels << "code" << "ruby"
  @results = {}
end

Instance Method Details

#analyzeObject



28
29
30
31
32
33
34
35
36
# File 'lib/pipeline/tasks/bundle-audit.rb', line 28

def analyze
  # puts @result
  begin
    get_warnings
  rescue Exception => e
    Pipeline.warn e.message
    Pipeline.notify "Appears not to be a project with Gemfile.lock or there was another problem ... bundle-audit skipped."
  end
end

#runObject



19
20
21
22
23
24
25
26
# File 'lib/pipeline/tasks/bundle-audit.rb', line 19

def run
  directories_with?('Gemfile.lock').each do |dir|
    Pipeline.notify "#{@name} scanning: #{dir}"
    Dir.chdir(dir) do
      @results[dir] = runsystem(true, "bundle-audit", "check")
    end
  end
end

#supported?Boolean

Returns:

  • (Boolean)


38
39
40
41
42
43
44
45
46
# File 'lib/pipeline/tasks/bundle-audit.rb', line 38

def supported?
  supported=runsystem(false, "bundle-audit", "update")
  if supported =~ /command not found/
    Pipeline.notify "Run: gem install bundler-audit"
    return false
  else
    return true
  end
end