Class: Pipeline::Checkmarx
- Includes:
- Util
- Defined in:
- lib/pipeline/tasks/checkmarx.rb
Instance Attribute Summary
Attributes inherited from BaseTask
#appname, #description, #findings, #labels, #name, #stage, #trigger, #warnings
Instance Method Summary collapse
- #analyze ⇒ Object
-
#initialize(trigger, tracker) ⇒ Checkmarx
constructor
A new instance of Checkmarx.
- #run ⇒ Object
- #supported? ⇒ Boolean
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) ⇒ Checkmarx
Returns a new instance of Checkmarx.
10 11 12 13 14 15 16 |
# File 'lib/pipeline/tasks/checkmarx.rb', line 10 def initialize(trigger, tracker) super(trigger, tracker) @name = "Checkmarx" @description = "CxSAST" @stage = :code @labels << "code" end |
Instance Method Details
#analyze ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/pipeline/tasks/checkmarx.rb', line 33 def analyze begin @results.each do |result| description = result.parent.attributes['name'].value.gsub('_', ' ') detail = result.attributes['DeepLink'].value source = { :scanner => @name, :file => result.attributes['FileName'].value, :line => result.attributes['Line'].value.to_i, :code => result.at_xpath('Path/PathNode/Snippet/Line/Code').text } sev = severity(result.parent.attributes['Severity'].value) fprint = fingerprint("#{description}#{source}#{sev}") report description, detail, source, sev, fprint end rescue Exception => e Pipeline.warn e. Pipeline.warn e.backtrace end end |
#run ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/pipeline/tasks/checkmarx.rb', line 18 def run rootpath = @trigger.path runsystem(true, "runCxConsole.sh", "scan", "-v", "-CxUser", "#{@tracker.[:checkmarx_user]}", "-CxPassword", "#{@tracker.[:checkmarx_password]}", "-CxServer", "#{@tracker.[:checkmarx_server]}", "-LocationType", "folder", "-LocationPath", "#{rootpath}", "-ProjectName", "#{@tracker.[:checkmarx_project]}", "-ReportXML", "#{rootpath}checkmarx_results.xml", "-Log", "#{@tracker.[:checkmarx_log]}" ) @results = Nokogiri::XML(File.read("#{rootpath}checkmarx_results.xml")).xpath '//Result' end |