Class: Dradis::Plugins::Nexpose::FieldProcessor
- Inherits:
-
Upload::FieldProcessor
- Object
- Upload::FieldProcessor
- Dradis::Plugins::Nexpose::FieldProcessor
- Defined in:
- lib/dradis/plugins/nexpose/field_processor.rb
Overview
This processor defers to ::Acunetix::Scan for the scan template and to ::Acunetix::ReportItem for the report_item and evidence templates.
Instance Method Summary collapse
Instance Method Details
#post_initialize(args = {}) ⇒ Object
[View source]
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/dradis/plugins/nexpose/field_processor.rb', line 7 def post_initialize(args={}) if data.kind_of?(Hash) || data.kind_of?(Nexpose::Node) || data.kind_of?(Nexpose::Service) || data.kind_of?(Nexpose::Scan) || data.kind_of?(Nexpose::Vulnerability) @nexpose_object = data else # XML from Plugin Manager if (data.name == 'node') # Full - node @nexpose_object = Nexpose::Node.new(data) elsif (data.name == 'service') # Full - service @nexpose_object = Nexpose::Service.new(data) elsif (data.name == 'scan') @nexpose_object = Nexpose::Scan.new(data) elsif (data.name == 'test') @nexpose_object = Nexpose::Test.new(data) else if data['added'] # Full - vulnerability @nexpose_object = Nexpose::Vulnerability.new(data) else # Simple - port @nexpose_object = { id: data['id'], finding: data.xpath('//id').collect{ |id_node| "#{id_node['type']} : #{id_node.text}" }.join("\n") } end end end end |
#value(args = {}) ⇒ Object
[View source]
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/dradis/plugins/nexpose/field_processor.rb', line 41 def value(args={}) field = args[:field] # fields in the template are of the form <foo>.<field>, where <foo> # is common across all fields for a given template (and meaningless). _, name = field.split('.') # Simple - port if @nexpose_object.kind_of?(Hash) @nexpose_object[name.to_sym] else # Full - scan / node / service vulnerability result = @nexpose_object.try(name, nil) if result.kind_of?(Array) result << 'n/a' if result.empty? if result.first.is_a?(String) result.join("\n") else # we have an array of hashes format_array_as_table(result) end else result || 'n/a' end end end |