Permalink
Browse files

Merge pull request #74 from jlk/master

Small patch to parse updated ZAP proxy's XML format
  • Loading branch information...
2 parents ff1b23b + 51ee3cd commit 34f7276c5106ff527fa4fd03b24b130040ad85ee @etdsoft etdsoft committed Jun 28, 2012
Showing with 9 additions and 2 deletions.
  1. +9 −2 vendor/plugins/zap_upload/lib/zap_upload/filters.rb
@@ -29,8 +29,15 @@ def self.import(params={})
:category => category,
:text => "#[Title]#\nZAP upload: #{file_name}\n\n#[Report_date]##{report_date}")
- # Process the report contents
- doc.xpath('/report/alertitem').each do |alert|
+ # Depending on Zap version, XML structure is different.
+ # Detect version and then use appropriate xpath:
+ if( doc.xpath( '/OWASPZAPReport' ).count > 0 )
+ report_path = '/OWASPZAPReport/site/alerts/alertitem'
+ else
+ report_path = '/report/alertitem'
+ end
+
+ doc.xpath(report_path).each do |alert|
alert_name = alert.xpath('alert').text
alert_text = alert.elements.collect{ |attribute|
"#[#{attribute.name.capitalize}]#\n#{attribute.text}\n\n"

0 comments on commit 34f7276

Please sign in to comment.