Class: Pipeline::Test

Inherits:
BaseTask show all
Includes:
Util
Defined in:
lib/pipeline/tasks/test.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) ⇒ Test

Returns a new instance of Test.



8
9
10
11
12
13
14
# File 'lib/pipeline/tasks/test.rb', line 8

def initialize(trigger, tracker)
  super(trigger, tracker)
  @name = "Test"
  @description = "Test"
  @stage = :code
  @labels << "code" << "ruby"
end

Instance Method Details

#analyzeObject



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/pipeline/tasks/test.rb', line 25

def analyze
  begin
    list = @result.split(/\n/)
    list.each do |match|
        report "Match", match, @name, :low, "fingerprint"
    end
rescue Exception => e
    Pipeline.warn e.message
    Pipeline.notify "Error grepping ... "
  end
end

#runObject



16
17
18
19
20
21
22
23
# File 'lib/pipeline/tasks/test.rb', line 16

def run
  # Pipeline.notify "#{@name}"
  rootpath = @trigger.path
  Pipeline.debug "Rootpath: #{rootpath}"
  Dir.chdir("#{rootpath}") do
    @result= runsystem(true, "grep", "-R", "secret")
  end
end

#supported?Boolean

Returns:

  • (Boolean)


37
38
39
40
41
42
43
44
45
# File 'lib/pipeline/tasks/test.rb', line 37

def supported?
  supported=runsystem(true, "grep", "-h")
  if supported =~ /usage/
    Pipeline.notify "Install grep."
    return false
  else
    return true
  end
end