fidius/cvedb — Issue #7: cvedb does not parse XMLs with PostgreSQL
Author: tomekr
Created: 2012-01-04 22:54:11+00:00
State: open

Hi there,

I tried using fidius-cvedb with a postgresql database in rails and when I try and parse an xml I get the following:

```
rake RAILS_ENV=cve_db nvd:parse["nvdcve-2.0-modified.xml"]
...
rails runner /usr/local/ruby/lib/ruby/gems/1.9.1/gems/fidius-cvedb-0.0.7/lib/cveparser/main.rb -p /home/tomek/cve/cveparser/xml/nvdcve-2.0-modified.xml
You did not specify how you would like Rails to report deprecation notices for your cve_db environment, please set config.active_support.deprecation to :log, :notify or :stderr at config/environments/cve_db.rb
[*] Start parsing "/home/tomek/cve/cveparser/xml/nvdcve-2.0-modified.xml"
Parsed 100 CVE Entries.
[*] Finished parsing, parsed 116 entries in 1 seconds.
[*] Storing the CVE-Entries in DB
Store: CVE-2003-0497 [1/116]
Store: CVE-2003-0498 [2/116]
Store: CVE-2007-6750 [3/116]
Store: CVE-2009-0052 [4/116]
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:980:in `get_last_result': PGError: ERROR: value too long for type character varying(255) (ActiveRecord::StatementInvalid)
: INSERT INTO "nvd_entries" ("created_at", "cve", "cwe", "last_modified", "published", "summary", "updated_at") VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING "id"

```

I believe its because in your migrations your using strings for the database datatypes and i believe the postgresql adapter in rails maps that to a varying(255) datatype. I believe its the summaries that are that long and causing this error so maybe the solution would be to change the summary column in nvd_entries from string to text?

I am running rails 3.1.0 with ruby 1.9.3

Thanks,
Tomek