Skip to contentSkip to conversation

cve-check: allow comparison of Vendor as well as Product

PATCH New Ross Burton 1 participant 3 messages Jul 17, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 cve-check: allow comparison of Vendor as well as Product

Some product names are too vague to be searched without also matching the vendor, for example Flex could be the parser compiler we ship, or Adobe Flex, or Apache Flex, or IBM Flex.

If entries in CVE_PRODUCT contain a colon then split it as vendor:product to improve the search.

Also don't use .format() to construct SQL as that can lead to security issues. Instead, use ? placeholders and lets sqlite3 handle the escaping.

---
 meta/classes/cve-check.bbclass | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
meta/classes/cve-check.bbclass +8 -4
index 2a1381604ad..e8668b25663 100644
@@ -190,12 +190,16 @@ def check_cves(d, patched_cves):
     import sqlite3
     db_file = d.getVar("CVE_CHECK_DB_FILE")
     conn = sqlite3.connect(db_file)
-    c = conn.cursor()
-
-    query = "SELECT * FROM PRODUCTS WHERE PRODUCT IS '{0}';"
 
     for product in products:
-        for row in c.execute(query.format(product, pv)):
+        c = conn.cursor()
+        if ":" in product:
+            vendor, product = product.split(":", 1)
+            c.execute("SELECT * FROM PRODUCTS WHERE PRODUCT IS ? AND VENDOR IS ?", (product, vendor))
+        else:
+            c.execute("SELECT * FROM PRODUCTS WHERE PRODUCT IS ?", (product,))
+
+        for row in c:
             cve = row[1]
             version_start = row[4]
             operator_start = row[5]
Signature · 1 line
2.20.1
#1 lore raw

PATCH 2/3 flex: set CVE_PRODUCT to include vendor

There are many projects called Flex and they have CVEs, so also set the vendor to remove these false positives.

---
 meta/recipes-devtools/flex/flex_2.6.0.bb | 3 +++
 1 file changed, 3 insertions(+)
meta/recipes-devtools/flex/flex_2.6.0.bb +3 -0
index b477cd8c7f2..12ce0cb461e 100644
@@ -68,3 +68,6 @@ do_install_ptest() {
 	    -e 's/^builddir = \(.*\)/builddir = ./' -e 's/^top_builddir = \(.*\)/top_builddir = ./' \
 	    -i ${D}${PTEST_PATH}/Makefile
 }
+
+# Not Apache Flex, or Adobe Flex, or IBM Flex.
+CVE_PRODUCT = "flex_project:flex"
Signature · 1 line
2.20.1
#2 lore raw

PATCH 3/3 cve-update-db-native: use SQL placeholders instead of format strings

In reply to Ross Burton
---
 meta/recipes-core/meta/cve-update-db-native.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-core/meta/cve-update-db-native.bb +1 -1
index e16c41a72fd..72d1f48835b 100644
@@ -62,7 +62,7 @@ python do_populate_cve_db() {
             break
 
         # Compare with current db last modified date
-        c.execute("select DATE from META where YEAR = '%d'" % year)
+        c.execute("select DATE from META where YEAR = ?", (year,))
         meta = c.fetchone()
         if not meta or meta[0] != last_modified:
             # Update db with current year json file
Signature · 1 line
2.20.1