Class: Veracode::Evidence
- Inherits:
-
Object
- Object
- Veracode::Evidence
- Defined in:
- lib/veracode/evidence.rb
Instance Method Summary collapse
-
#initialize(xml_flaw) ⇒ Evidence
constructor
Accepts an XML node from Nokogiri::XML.
-
#method_missing(method, *args) ⇒ Object
This method is invoked by Ruby when a method that is not defined in this instance is called.
-
#respond_to?(method, include_private = false) ⇒ Boolean
This allows external callers (and specs) to check for implemented properties.
-
#supported_tags ⇒ Object
List of supported tags.
Constructor Details
#initialize(xml_flaw) ⇒ Evidence
Accepts an XML node from Nokogiri::XML.
4 5 6 |
# File 'lib/veracode/evidence.rb', line 4 def initialize(xml_flaw) @xml = xml_flaw end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
This method is invoked by Ruby when a method that is not defined in this instance is called.
In our case we inspect the @method@ parameter and try to find the attribute, simple descendent or collection that it maps to in the XML tree.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/veracode/evidence.rb', line 31 def method_missing(method, *args) # We could remove this check and return nil for any non-recognized tag. # The problem would be that it would make tricky to debug problems with # typos. For instance: <>.potr would return nil instead of raising an # exception unless .include?(method) super return end # First we try the attributes method_name = method.to_s return @xml.attributes[method_name].value if @xml.attributes.key?(method_name) end |
Instance Method Details
#respond_to?(method, include_private = false) ⇒ Boolean
This allows external callers (and specs) to check for implemented properties
20 21 22 23 |
# File 'lib/veracode/evidence.rb', line 20 def respond_to?(method, include_private = false) return true if .include?(method.to_sym) super end |
#supported_tags ⇒ Object
List of supported tags. They can be attributes, simple descendans or collections (e.g. <references/>, <tags/>)
10 11 12 13 14 15 16 |
# File 'lib/veracode/evidence.rb', line 10 def [ :description, :exploitlevel, :issueid, :line, :mitigation_status, :mitigation_status_desc, :module, :remediation_status, :remediationeffort, :sourcefile, :sourcefilepath ] end |