Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing National Vulnerability XML file fails #14

Open
frosenberg opened this issue Jul 11, 2014 · 1 comment
Open

Parsing National Vulnerability XML file fails #14

frosenberg opened this issue Jul 11, 2014 · 1 comment

Comments

@frosenberg
Copy link

I have the following sample program:

require 'rxsd'

xsd_uri = "http://nvd.nist.gov/schema/nvd-cve-feed_2.0.xsd"
xml_uri = "http://static.nvd.nist.gov/feeds/xml/cve/nvdcve-2.0-modified.xml"

schema = RXSD::Parser.parse_xsd :uri => xsd_uri

puts "=======Objects======="
data = RXSD::Parser.parse_xml :uri => xml_uri
objs = data.to :ruby_objects, :schema => schema
objs.each {  |obj|
    puts "#{obj}"
}

As a result I get this:

=======Objects=======
/Library/Ruby/Gems/2.0.0/gems/rxsd-0.5.2/lib/rxsd/builders/ruby_object.rb:24:in `build': undefined method `new' for nil:NilClass (NoMethodError)
    from /Library/Ruby/Gems/2.0.0/gems/rxsd-0.5.2/lib/rxsd/translator.rb:118:in `block in to'
    from /Library/Ruby/Gems/2.0.0/gems/rxsd-0.5.2/lib/rxsd/translator.rb:114:in `each'
    from /Library/Ruby/Gems/2.0.0/gems/rxsd-0.5.2/lib/rxsd/translator.rb:114:in `to'
    from cert-input.rb:23:in `<main>'
@movitto
Copy link
Owner

movitto commented Aug 3, 2014

Hey @frosenberg sorry for the belated response. It's been a little while since I worked on RXSD and my memory is a bit fuzzy but I recall you needing to explicitly convert the schema to classes before converting the instance to objects.

I ran your script and was able to reproduce the error. Adding the following after the schema init but before the xml parsing got me furthur:

schema = RXSD::Parser.parse_xsd :uri => xsd_uri
classes = schema.to :ruby_classes # ADDED

puts "=======Objects======="
data = RXSD::Parser.parse_xml :uri => xml_uri

Unfortunately I ran into another error, this time around the "nvd:pub_date" attribute and didn't dive into it further. Note as mentioned it's been a while since I've put any cycles into rxsd and my memory is a bit fuzzy w/ the specifics of the internals. Prolly won't be able to put too much time into improving it myself but if you had anymore questions about it or wanted to add any furthur enhancements I'd be glad to help.

-Mo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants