Class: Pipeline::Checkmarx
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
#report, #severity, #warn
Constructor Details
#initialize(trigger, tracker) ⇒ 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/pipeline/tasks/checkmarx.rb', line 34
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.message
Pipeline.warn e.backtrace
end
end
|
#run ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/pipeline/tasks/checkmarx.rb', line 18
def run
Pipeline.notify "#{@name}"
rootpath = @trigger.path
runsystem(true, "runCxConsole.sh", "scan", "-v",
"-CxUser", "#{@tracker.options[:checkmarx_user]}",
"-CxPassword", "#{@tracker.options[:checkmarx_password]}",
"-CxServer", "#{@tracker.options[:checkmarx_server]}",
"-LocationType", "folder",
"-LocationPath", "#{rootpath}",
"-ProjectName", "#{@tracker.options[:checkmarx_project]}",
"-ReportXML", "#{rootpath}checkmarx_results.xml",
"-Log", "#{@tracker.options[:checkmarx_log]}"
)
@results = Nokogiri::XML(File.read("#{rootpath}checkmarx_results.xml")).xpath '//Result'
end
|
#supported? ⇒ Boolean
51
52
53
54
55
56
57
58
59
|
# File 'lib/pipeline/tasks/checkmarx.rb', line 51
def supported?
supported=runsystem(true, "runCxConsole.sh", "--help")
if supported =~ /command not found/
Pipeline.notify "Install CxConsolePlugin"
return false
else
return true
end
end
|