Class: Pipeline::BaseTask

Inherits:
Object
  • Object
show all
Defined in:
lib/pipeline/tasks/base_task.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(trigger, tracker) ⇒ BaseTask

Returns a new instance of BaseTask.



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/pipeline/tasks/base_task.rb', line 12

def initialize(trigger, tracker)
  @findings = []
  @warnings = []
  @labels = Set.new
  @trigger = trigger
  @tracker = tracker
  @severity_filter = {
    :low => ['low','weak'],
    :medium => ['medium','med','average'],
    :high => ['high','severe','critical']
  }
end

Instance Attribute Details

#appnameObject

Returns the value of attribute appname.



10
11
12
# File 'lib/pipeline/tasks/base_task.rb', line 10

def appname
  @appname
end

#descriptionObject

Returns the value of attribute description.



8
9
10
# File 'lib/pipeline/tasks/base_task.rb', line 8

def description
  @description
end

#findingsObject (readonly)

Returns the value of attribute findings.



6
7
8
# File 'lib/pipeline/tasks/base_task.rb', line 6

def findings
  @findings
end

#labelsObject (readonly)

Returns the value of attribute labels.



6
7
8
# File 'lib/pipeline/tasks/base_task.rb', line 6

def labels
  @labels
end

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/pipeline/tasks/base_task.rb', line 7

def name
  @name
end

#stageObject

Returns the value of attribute stage.



9
10
11
# File 'lib/pipeline/tasks/base_task.rb', line 9

def stage
  @stage
end

#triggerObject (readonly)

Returns the value of attribute trigger.



6
7
8
# File 'lib/pipeline/tasks/base_task.rb', line 6

def trigger
  @trigger
end

#warningsObject (readonly)

Returns the value of attribute warnings.



6
7
8
# File 'lib/pipeline/tasks/base_task.rb', line 6

def warnings
  @warnings
end

Instance Method Details

#analyzeObject



66
67
# File 'lib/pipeline/tasks/base_task.rb', line 66

def analyze
end

#directories_with?(file, exclude_dirs = []) ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/pipeline/tasks/base_task.rb', line 46

def directories_with? file, exclude_dirs = []
  exclude_dirs = @tracker.options[:exclude_dirs] if exclude_dirs == [] and @tracker.options[:exclude_dirs]
  results = []

  Find.find(@trigger.path) do |path|
    if FileTest.directory? path
      Find.prune if exclude_dirs.include? File.basename(path) or exclude_dirs.include? File.basename(path) + '/'
      next
    end

    Find.prune unless File.basename(path) == file

    results << File.dirname(path)
  end
  return results
end

#report(description, detail, source, severity, fingerprint) ⇒ Object



25
26
27
28
# File 'lib/pipeline/tasks/base_task.rb', line 25

def report description, detail, source, severity, fingerprint
  finding = Pipeline::Finding.new( @trigger.appname, description, detail, source, severity, fingerprint )
  @findings << finding
end

#runObject



63
64
# File 'lib/pipeline/tasks/base_task.rb', line 63

def run
end

#severity(sev) ⇒ Object



72
73
74
75
76
77
78
# File 'lib/pipeline/tasks/base_task.rb', line 72

def severity sev
  sev = '' if sev.nil?
  return 1 if @severity_filter[:low].include?(sev.strip.chomp.downcase)
  return 2 if @severity_filter[:medium].include?(sev.strip.chomp.downcase)
  return 3 if @severity_filter[:high].include?(sev.strip.chomp.downcase)
  return 0
end

#supported?Boolean

Returns:

  • (Boolean)


69
70
# File 'lib/pipeline/tasks/base_task.rb', line 69

def supported?
end

#warn(warning) ⇒ Object



30
31
32
# File 'lib/pipeline/tasks/base_task.rb', line 30

def warn warning
  @warnings << warning
end