diff options
| -rw-r--r-- | meta/recipes-core/meta/cve-update-db-native.bb | 53 |
1 files changed, 33 insertions, 20 deletions
diff --git a/meta/recipes-core/meta/cve-update-db-native.bb b/meta/recipes-core/meta/cve-update-db-native.bb index 87e5a3edaa..0c7bc5f415 100644 --- a/meta/recipes-core/meta/cve-update-db-native.bb +++ b/meta/recipes-core/meta/cve-update-db-native.bb | |||
| @@ -322,6 +322,15 @@ def update_db_nvdjson(conn, jsondata): | |||
| 322 | for config in configurations: | 322 | for config in configurations: |
| 323 | parse_node_and_insert(conn, config, cveId, True) | 323 | parse_node_and_insert(conn, config, cveId, True) |
| 324 | 324 | ||
| 325 | def get_metric_entry(metric): | ||
| 326 | primaries = [c for c in metric if c['type'] == "Primary"] | ||
| 327 | secondaries = [c for c in metric if c['type'] == "Secondary"] | ||
| 328 | if len(primaries) > 0: | ||
| 329 | return primaries[0] | ||
| 330 | elif len(secondaries)>0: | ||
| 331 | return secondaries[0] | ||
| 332 | return None | ||
| 333 | |||
| 325 | def update_db_fkie(conn, jsondata): | 334 | def update_db_fkie(conn, jsondata): |
| 326 | import json | 335 | import json |
| 327 | root = json.loads(jsondata) | 336 | root = json.loads(jsondata) |
| @@ -342,37 +351,41 @@ def update_db_fkie(conn, jsondata): | |||
| 342 | cveDesc = elt['descriptions'][0]['value'] | 351 | cveDesc = elt['descriptions'][0]['value'] |
| 343 | date = elt['lastModified'] | 352 | date = elt['lastModified'] |
| 344 | try: | 353 | try: |
| 345 | for m in elt['metrics']['cvssMetricV2']: | 354 | if 'cvssMetricV2' in elt['metrics']: |
| 346 | if m['type'] == 'Primary': | 355 | entry = get_metric_entry(elt['metrics']['cvssMetricV2']) |
| 347 | accessVector = m['cvssData']['accessVector'] | 356 | if entry: |
| 348 | vectorString = m['cvssData']['vectorString'] | 357 | accessVector = entry['cvssData']['accessVector'] |
| 349 | cvssv2 = m['cvssData']['baseScore'] | 358 | vectorString = entry['cvssData']['vectorString'] |
| 359 | cvssv2 = entry['cvssData']['baseScore'] | ||
| 350 | except KeyError: | 360 | except KeyError: |
| 351 | cvssv2 = 0.0 | 361 | cvssv2 = 0.0 |
| 352 | try: | 362 | try: |
| 353 | for m in elt['metrics']['cvssMetricV30']: | 363 | if 'cvssMetricV30' in elt['metrics']: |
| 354 | if m['type'] == 'Primary': | 364 | entry = get_metric_entry(elt['metrics']['cvssMetricV30']) |
| 355 | accessVector = m['cvssData']['attackVector'] | 365 | if entry: |
| 356 | vectorString = m['cvssData']['vectorString'] | 366 | accessVector = entry['cvssData']['attackVector'] |
| 357 | cvssv3 = m['cvssData']['baseScore'] | 367 | vectorString = entry['cvssData']['vectorString'] |
| 368 | cvssv3 = entry['cvssData']['baseScore'] | ||
| 358 | except KeyError: | 369 | except KeyError: |
| 359 | accessVector = accessVector or "UNKNOWN" | 370 | accessVector = accessVector or "UNKNOWN" |
| 360 | cvssv3 = 0.0 | 371 | cvssv3 = 0.0 |
| 361 | try: | 372 | try: |
| 362 | for m in elt['metrics']['cvssMetricV31']: | 373 | if 'cvssMetricV31' in elt['metrics']: |
| 363 | if m['type'] == 'Primary': | 374 | entry = get_metric_entry(elt['metrics']['cvssMetricV31']) |
| 364 | accessVector = m['cvssData']['attackVector'] | 375 | if entry: |
| 365 | vectorString = m['cvssData']['vectorString'] | 376 | accessVector = entry['cvssData']['attackVector'] |
| 366 | cvssv3 = m['cvssData']['baseScore'] | 377 | vectorString = entry['cvssData']['vectorString'] |
| 378 | cvssv3 = entry['cvssData']['baseScore'] | ||
| 367 | except KeyError: | 379 | except KeyError: |
| 368 | accessVector = accessVector or "UNKNOWN" | 380 | accessVector = accessVector or "UNKNOWN" |
| 369 | cvssv3 = 0.0 | 381 | cvssv3 = 0.0 |
| 370 | try: | 382 | try: |
| 371 | for m in elt['metrics']['cvssMetricV40']: | 383 | if 'cvssMetricV40' in elt['metrics']: |
| 372 | if m['type'] == 'Primary': | 384 | entry = get_metric_entry(elt['metrics']['cvssMetricV40']) |
| 373 | accessVector = m['cvssData']['attackVector'] | 385 | if entry: |
| 374 | vectorString = m['cvssData']['vectorString'] | 386 | accessVector = entry['cvssData']['attackVector'] |
| 375 | cvssv4 = m['cvssData']['baseScore'] | 387 | vectorString = entry['cvssData']['vectorString'] |
| 388 | cvssv4 = entry['cvssData']['baseScore'] | ||
| 376 | except KeyError: | 389 | except KeyError: |
| 377 | accessVector = accessVector or "UNKNOWN" | 390 | accessVector = accessVector or "UNKNOWN" |
| 378 | cvssv4 = 0.0 | 391 | cvssv4 = 0.0 |
