Class: Pipeline::BaseTask
- Inherits:
-
Object
- Object
- Pipeline::BaseTask
- Defined in:
- lib/pipeline/tasks/base_task.rb
Direct Known Subclasses
AV, Brakeman, BundleAudit, Checkmarx, DawnScanner, ESLint, FIM, FindSecurityBugs, NodeSecurityProject, Npm, OWASPDependencyCheck, PMD, RetireJS, SFL, ScanJS, Snyk, Test, Zap
Instance Attribute Summary collapse
-
#appname ⇒ Object
Returns the value of attribute appname.
-
#description ⇒ Object
Returns the value of attribute description.
-
#findings ⇒ Object
readonly
Returns the value of attribute findings.
-
#labels ⇒ Object
readonly
Returns the value of attribute labels.
-
#name ⇒ Object
Returns the value of attribute name.
-
#stage ⇒ Object
Returns the value of attribute stage.
-
#trigger ⇒ Object
readonly
Returns the value of attribute trigger.
-
#warnings ⇒ Object
readonly
Returns the value of attribute warnings.
Instance Method Summary collapse
- #analyze ⇒ Object
- #directories_with?(file, exclude_dirs = []) ⇒ Boolean
-
#initialize(trigger, tracker) ⇒ BaseTask
constructor
A new instance of BaseTask.
- #report(description, detail, source, severity, fingerprint) ⇒ Object
- #run ⇒ Object
- #severity(sev) ⇒ Object
- #supported? ⇒ Boolean
- #warn(warning) ⇒ Object
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
#appname ⇒ Object
Returns the value of attribute appname.
10 11 12 |
# File 'lib/pipeline/tasks/base_task.rb', line 10 def appname @appname end |
#description ⇒ Object
Returns the value of attribute description.
8 9 10 |
# File 'lib/pipeline/tasks/base_task.rb', line 8 def description @description end |
#findings ⇒ Object (readonly)
Returns the value of attribute findings.
6 7 8 |
# File 'lib/pipeline/tasks/base_task.rb', line 6 def findings @findings end |
#labels ⇒ Object (readonly)
Returns the value of attribute labels.
6 7 8 |
# File 'lib/pipeline/tasks/base_task.rb', line 6 def labels @labels end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/pipeline/tasks/base_task.rb', line 7 def name @name end |
#stage ⇒ Object
Returns the value of attribute stage.
9 10 11 |
# File 'lib/pipeline/tasks/base_task.rb', line 9 def stage @stage end |
#trigger ⇒ Object (readonly)
Returns the value of attribute trigger.
6 7 8 |
# File 'lib/pipeline/tasks/base_task.rb', line 6 def trigger @trigger end |
#warnings ⇒ Object (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
#analyze ⇒ Object
66 67 |
# File 'lib/pipeline/tasks/base_task.rb', line 66 def analyze end |
#directories_with?(file, exclude_dirs = []) ⇒ 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.[:exclude_dirs] if exclude_dirs == [] and @tracker.[: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 |
#run ⇒ Object
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
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 |