PidgeyL / cve-search

cve-search is a tool to import CVE (Common Vulnerabilities and Exposures) and CPE (Common Platform Enumeration) into a MongoDB to facilitate search and processing of CVEs.
http://adulau.github.com/cve-search/
Other
24 stars 4 forks source link

KeyError when updating #109

Closed lvets closed 9 years ago

lvets commented 9 years ago

Hello,

I get following traceback when updating my db:

user@machine:~/Source/cve-search/sbin$ python3 ./db_updater.py -c -i -v
Starting cves
Traceback (most recent call last):
  File "/home/user/Source/cve-search/sbin/db_mgmt.py", line 225, in <module>
    dbLayer.updateCVE(item)
  File "/home/user/Source/cve-search/sbin/../lib/DatabaseLayer.py", line 43, in updateCVE
    colCVE.update({"id": cve['id']}, {"$set": {"cvss": cve['cvss'], "summary": cve['summary'], "references": cve[' references'],
KeyError: ' references'
cves has 72182 elements (0 update)
Starting cpe
Preparing [##################################################] 106132/106132
cpe has 106056 elements (55 update)
Starting cpeother
Empty collections, import skipped
cpeother has 252442 elements (0 update)
Starting vfeed
Not modified
vfeed has 72949 elements (0 update)
Starting vendor
Preparing [##################################################] 1441/1441
vendor has 1406 elements (0 update)
Starting cwe
Not modified
cwe has 719 elements (0 update)
Starting capec
Not modified
capec has 463 elements (0 update)
Starting redis-cache-cpe
redis-cache-cpe updated
Starting d2sec
Not modified
d2sec has 246 elements (0 update)
Starting ms
Not modified
ms has 1333 elements (0 update)
Starting redis-nist-ref
Not modified
redis-nist-ref has 0 elements (0 update)
Starting ensureindex
[+]Success to create index id on cpe
[+]Success to create index id on cpeother
[+]Success to create index id on cves
[+]Success to create index vulnerable_configuration on cves
[+]Success to create index Modified on cves
[+]Success to create index [('summary', 'text')] on cves
[+]Success to create index id on vfeed
[+]Success to create index id on vendor
[+]Success to create index id on d2sec
[+]Success to create index id on mgmt_whitelist
[+]Success to create index id on mgmt_blacklist
[+]Success to create index related_weakness on capec
user@machine:~/Source/cve-search/sbin$

However, when I run the updater again, I don't get the error anymore... Any idea what might be going on?

PidgeyL commented 9 years ago

Thanks for finding (yet another) bug I fixed the typoes (a misplaced space). I fixed the bug. Now for the reason why it only happened the second time, the "last modified" variable was set in the database. Please do the following to fix this:

lvets commented 9 years ago

I don't think this issue is fixed :)

I did a git pull in the cve-search directory, Did the 5 steps:

user@machine:~/Source/cve-search$ mongo
MongoDB shell version: 2.4.9
connecting to: test
>
>
> use cvedb
switched to db cvedb
> db.info.update({db:"cve"},{"last-modified" : "Fri, 28 Aug 2015 18:07:38 GMT"})
> quit
function quit() { [native code] }
> quit()
user@machine:~/Source/cve-search$

When I try the update again, I still get the same message:

Starting cves
Traceback (most recent call last):
  File "/home/laurens/Source/cve-search/sbin/db_mgmt.py", line 225, in <module>
    dbLayer.updateCVE(item)
  File "/home/laurens/Source/cve-search/sbin/../lib/DatabaseLayer.py", line 43, in updateCVE
    colCVE.update({"id": cve['id']}, {"$set": {"cvss": cve['cvss'], "summary": cve['summary'], "references": cve[' references'],
KeyError: ' references'
cves has 72182 elements (0 update)
Starting cpe
PidgeyL commented 9 years ago

That's odd, seems like my push did not complete. I did fix the bug, and tested on my pc. It's the space before references. There is also another typo. I'll push again when I'm home

PidgeyL commented 9 years ago

try again please :)

lvets commented 9 years ago

That works, thanks! :)