Skip to contentSkip to conversation

cve-update-db-native: skip on empty cpe23Uri

PATCH New Alejandro Hernandez Samaniego 1 participant 1 message Apr 22, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cve-update-db-native: skip on empty cpe23Uri

From: Konrad Weihmann <[email protected]>

Recently an entry in the NVD DB appeared that looks like that {'vulnerable': True, 'cpe_name': []}.
As besides all the vulnerable flag no data is present we would get a KeyError exception on acccess.
Use get method on dictionary and return if no meta data is present Also quit if the length of the array after splitting is less than 6

---
 meta/recipes-core/meta/cve-update-db-native.bb | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
meta/recipes-core/meta/cve-update-db-native.bb +6 -1
index 0cd3a1c153..f37a0f69cd 100644
@@ -132,7 +132,12 @@ def parse_node_and_insert(c, node, cveId):
         for cpe in node.get('cpe_match', ()):
             if not cpe['vulnerable']:
                 return
-            cpe23 = cpe['cpe23Uri'].split(':')
+            cpe23 = cpe.get('cpe23Uri')
+            if not cpe23:
+                return
+            cpe23 = cpe23.split(':')
+            if len(cpe23) < 6:
+                return
             vendor = cpe23[3]
             product = cpe23[4]
             version = cpe23[5]
Signature · 1 line
2.25.1