Skip to contentSkip to conversation

cve-update: handle baseMetricV2 as optional

PATCH Konrad Weihmann 2 participants 4 messages Jul 27, 2020 – Sep 1, 2020 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Hi all,

please consider this patch to be backported to dunfell/zeus and warrior.
Master-rev: bbefe04a622e166d95093d5127c316de91b27d20

Thanks
Konrad

Quoted 42 lines · Konrad Weihmann

Currently in NVD DB an item popped up, which hasn't set baseMetricV2. Let the parser handle it as an optional item.
In case use baseMetricV2 before baseMetricV3

---
  meta/recipes-core/meta/cve-update-db-native.bb | 13 +++++++++----
  1 file changed, 9 insertions(+), 4 deletions(-)
meta/recipes-core/meta/cve-update-db-native.bb +9 -4
index f27ade40db..32d6dbdffc 100644
@@ -176,15 +176,20 @@ def update_db(c, jsondata):
          if not elt['impact']:
              continue
 
+        accessVector = None
          cveId = elt['cve']['CVE_data_meta']['ID']
          cveDesc = elt['cve']['description']['description_data'][0]['value']
          date = elt['lastModifiedDate']
-        accessVector = elt['impact']['baseMetricV2']['cvssV2']['accessVector']
-        cvssv2 = elt['impact']['baseMetricV2']['cvssV2']['baseScore']
-
          try:
+            accessVector = elt['impact']['baseMetricV2']['cvssV2']['accessVector']
+            cvssv2 = elt['impact']['baseMetricV2']['cvssV2']['baseScore']
+        except KeyError:
+            cvssv2 = 0.0
+        try:
+            accessVector = accessVector or elt['impact']['baseMetricV3']['cvssV3']['attackVector']
              cvssv3 = elt['impact']['baseMetricV3']['cvssV3']['baseScore']
-        except:
+        except KeyError:
+            accessVector = accessVector or "UNKNOWN"
              cvssv3 = 0.0
 
          c.execute("insert or replace into NVD values (?, ?, ?, ?, ?, ?)",
#2 lore raw
Quoted 4 lines · Konrad Weihmann

Hi all,

please consider this patch to be backported to dunfell/zeus and warrior.

I'll second that request. My Warrior and Dunfell builds broke last week because of this.

Quoted 2 lines

Master-rev: bbefe04a622e166d95093d5127c316de91b27d20

Thanks for the fix, Konrad.

Quoted 57 lines

Thanks
Konrad

Review

Quoted 10 lines · Konrad Weihmann

Currently in NVD DB an item popped up, which hasn't set baseMetricV2. Let the parser handle it as an optional item.
In case use baseMetricV2 before baseMetricV3

---
  meta/recipes-core/meta/cve-update-db-native.bb | 13 +++++++++----
  1 file changed, 9 insertions(+), 4 deletions(-)
(quoted diff) +0 -0

b/meta/recipes-core/meta/cve-update-db-native.bb

meta/recipes-core/meta/cve-update-db-native.bb def update_db(c, jsondata): · line 181

Quoted 10 lines

index f27ade40db..32d6dbdffc 100644

meta/recipes-core/meta/cve-update-db-native.bb +1 -0
@@ -176,15 +176,20 @@ def update_db(c, jsondata):
          if not elt['impact']:
              continue
 
+        accessVector = None
          cveId = elt['cve']['CVE_data_meta']['ID']
          cveDesc =

elt['cve']['description']['description_data'][0]['value']

meta/recipes-core/meta/cve-update-db-native.bb def update_db(c, jsondata): · line 182

Quoted 2 lines
meta/recipes-core/meta/cve-update-db-native.bb +0 -1
          date = elt['lastModifiedDate']
-        accessVector =

elt['impact']['baseMetricV2']['cvssV2']['accessVector']

meta/recipes-core/meta/cve-update-db-native.bb def update_db(c, jsondata): · line 184

Quoted 4 lines
meta/recipes-core/meta/cve-update-db-native.bb +1 -2
-        cvssv2 = elt['impact']['baseMetricV2']['cvssV2']['baseScore']
-
          try:
+            accessVector =

elt['impact']['baseMetricV2']['cvssV2']['accessVector']

meta/recipes-core/meta/cve-update-db-native.bb def update_db(c, jsondata): · line 185

Quoted 1 line
meta/recipes-core/meta/cve-update-db-native.bb +1 -0
+            cvssv2 =

elt['impact']['baseMetricV2']['cvssV2']['baseScore']

meta/recipes-core/meta/cve-update-db-native.bb def update_db(c, jsondata): · line 189

Quoted 4 lines
meta/recipes-core/meta/cve-update-db-native.bb +4 -0
+        except KeyError:
+            cvssv2 = 0.0
+        try:
+            accessVector = accessVector or

elt['impact']['baseMetricV3']['cvssV3']['attackVector']

meta/recipes-core/meta/cve-update-db-native.bb def update_db(c, jsondata): · line 190

Quoted 1 line
meta/recipes-core/meta/cve-update-db-native.bb +0 -0
              cvssv3 =

elt['impact']['baseMetricV3']['cvssV3']['baseScore']

meta/recipes-core/meta/cve-update-db-native.bb def update_db(c, jsondata): · line 195

Quoted 6 lines
meta/recipes-core/meta/cve-update-db-native.bb +2 -1
-        except:
+        except KeyError:
+            accessVector = accessVector or "UNKNOWN"
              cvssv3 = 0.0
 
          c.execute("insert or replace into NVD values (?, ?, ?, ?, ?,

?)",

Quoted 4 lines
#3 lore raw

Again this breaks builds for me - please backport the patch to warrior - or ping me, then I do the backporting

Cheers
Konrad

Quoted 80 lines · Ryan Harkin

On Mon, 27 Jul 2020 at 19:26, Konrad Weihmann <[email protected] <mailto:[email protected]>> wrote:

Hi all,

please consider this patch to be backported to dunfell/zeus and warrior.

I'll second that request. My Warrior and Dunfell builds broke last week because of this.

    Master-rev: bbefe04a622e166d95093d5127c316de91b27d20

Thanks for the fix, Konrad.

    Thanks
    Konrad

    On 26.07.20 16:10, Konrad Weihmann wrote:
     > Currently in NVD DB an item popped up, which hasn't set baseMetricV2.
     > Let the parser handle it as an optional item.
     > In case use baseMetricV2 before baseMetricV3
     >
     > Signed-off-by: Konrad Weihmann <[email protected]
    <mailto:[email protected]>>
     > ---
     >   meta/recipes-core/meta/cve-update-db-native.bb
    <http://cve-update-db-native.bb> | 13 +++++++++----
     >   1 file changed, 9 insertions(+), 4 deletions(-)
     >
     > diff --git a/meta/recipes-core/meta/cve-update-db-native.bb
    <http://cve-update-db-native.bb>
    b/meta/recipes-core/meta/cve-update-db-native.bb
    <http://cve-update-db-native.bb>
     > index f27ade40db..32d6dbdffc 100644
     > --- a/meta/recipes-core/meta/cve-update-db-native.bb
    <http://cve-update-db-native.bb>
     > +++ b/meta/recipes-core/meta/cve-update-db-native.bb
    <http://cve-update-db-native.bb>
     > @@ -176,15 +176,20 @@ def update_db(c, jsondata):
     >           if not elt['impact']:
     >               continue
     >
     > +        accessVector = None
     >           cveId = elt['cve']['CVE_data_meta']['ID']
     >           cveDesc =
    elt['cve']['description']['description_data'][0]['value']
     >           date = elt['lastModifiedDate']
     > -        accessVector =
    elt['impact']['baseMetricV2']['cvssV2']['accessVector']
     > -        cvssv2 =
    elt['impact']['baseMetricV2']['cvssV2']['baseScore']
     > -
     >           try:
     > +            accessVector =
    elt['impact']['baseMetricV2']['cvssV2']['accessVector']
     > +            cvssv2 =
    elt['impact']['baseMetricV2']['cvssV2']['baseScore']
     > +        except KeyError:
     > +            cvssv2 = 0.0
     > +        try:
     > +            accessVector = accessVector or
    elt['impact']['baseMetricV3']['cvssV3']['attackVector']
     >               cvssv3 =
    elt['impact']['baseMetricV3']['cvssV3']['baseScore']
     > -        except:
     > +        except KeyError:
     > +            accessVector = accessVector or "UNKNOWN"
     >               cvssv3 = 0.0
     >
     >           c.execute("insert or replace into NVD values (?, ?, ?,
    ?, ?, ?)",
     >
     >
     >
     >
#4 lore raw
Quoted 2 lines · Konrad Weihmann

Again this breaks builds for me - please backport the patch to warrior -

Pretty please? ;-)
My Warrior builds are broken again. They only started working again because someone fixed the database, rather than the patch being backported.

Quoted 91 lines

or ping me, then I do the backporting

Cheers
Konrad

Quoted 8 lines · Ryan Harkin

On Mon, 27 Jul 2020 at 19:26, Konrad Weihmann <[email protected] <mailto:[email protected]>> wrote:

Hi all,

please consider this patch to be backported to dunfell/zeus and

warrior.

Quoted 8 lines

I'll second that request. My Warrior and Dunfell builds broke last week because of this.

    Master-rev: bbefe04a622e166d95093d5127c316de91b27d20
Quoted 8 lines

Thanks for the fix, Konrad.

Thanks
Konrad

On 26.07.20 16:10, Konrad Weihmann wrote:
> Currently in NVD DB an item popped up, which hasn't set

baseMetricV2.

Quoted 58 lines
     > Let the parser handle it as an optional item.
     > In case use baseMetricV2 before baseMetricV3
     >
     > Signed-off-by: Konrad Weihmann <[email protected]
    <mailto:[email protected]>>
     > ---
     >   meta/recipes-core/meta/cve-update-db-native.bb
    <http://cve-update-db-native.bb> | 13 +++++++++----
     >   1 file changed, 9 insertions(+), 4 deletions(-)
     >
     > diff --git a/meta/recipes-core/meta/cve-update-db-native.bb
    <http://cve-update-db-native.bb>
    b/meta/recipes-core/meta/cve-update-db-native.bb
    <http://cve-update-db-native.bb>
     > index f27ade40db..32d6dbdffc 100644
     > --- a/meta/recipes-core/meta/cve-update-db-native.bb
    <http://cve-update-db-native.bb>
     > +++ b/meta/recipes-core/meta/cve-update-db-native.bb
    <http://cve-update-db-native.bb>
     > @@ -176,15 +176,20 @@ def update_db(c, jsondata):
     >           if not elt['impact']:
     >               continue
     >
     > +        accessVector = None
     >           cveId = elt['cve']['CVE_data_meta']['ID']
     >           cveDesc =
    elt['cve']['description']['description_data'][0]['value']
     >           date = elt['lastModifiedDate']
     > -        accessVector =
    elt['impact']['baseMetricV2']['cvssV2']['accessVector']
     > -        cvssv2 =
    elt['impact']['baseMetricV2']['cvssV2']['baseScore']
     > -
     >           try:
     > +            accessVector =
    elt['impact']['baseMetricV2']['cvssV2']['accessVector']
     > +            cvssv2 =
    elt['impact']['baseMetricV2']['cvssV2']['baseScore']
     > +        except KeyError:
     > +            cvssv2 = 0.0
     > +        try:
     > +            accessVector = accessVector or
    elt['impact']['baseMetricV3']['cvssV3']['attackVector']
     >               cvssv3 =
    elt['impact']['baseMetricV3']['cvssV3']['baseScore']
     > -        except:
     > +        except KeyError:
     > +            accessVector = accessVector or "UNKNOWN"
     >               cvssv3 = 0.0
     >
     >           c.execute("insert or replace into NVD values (?, ?, ?,
    ?, ?, ?)",
     >
     >
     >
     >