All of lore.kernel.org
 help / color / mirror / Atom feed
From: mariano.lopez@linux.intel.com
To: ross.burton@intel.com, openembedded-core@lists.openembedded.org
Subject: Re: [PATCHv4 1/2] cve-check-tool: Add recipe
Date: Thu, 25 Aug 2016 13:01:18 +0000	[thread overview]
Message-ID: <1472130078-43004-1-git-send-email-mariano.lopez@linux.intel.com> (raw)
In-Reply-To: <CAJTo0LZ6-mTh_bxQooreSNuZYtxZx6oupSqP6G5TM76h98YhmQ@mail.gmail.com>

From: Mariano Lopez <mariano.lopez@linux.intel.com>

cve-check-tool is a program for public CVEs checking.
This tool also seek to determine if a vulnerability has
been addressed by a patch.

The recipe also includes the do_populate_cve_db task
that will populate the database used by the tool.

[YOCTO #7515]

Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
---
 .../cve-check-tool/cve-check-tool_5.6.4.bb         | 59 ++++++++++++++++++++++
 .../check-for-malloc_trim-before-using-it.patch    | 51 +++++++++++++++++++
 2 files changed, 110 insertions(+)
 create mode 100644 meta/recipes-devtools/cve-check-tool/cve-check-tool_5.6.4.bb
 create mode 100644 meta/recipes-devtools/cve-check-tool/files/check-for-malloc_trim-before-using-it.patch

diff --git a/meta/recipes-devtools/cve-check-tool/cve-check-tool_5.6.4.bb b/meta/recipes-devtools/cve-check-tool/cve-check-tool_5.6.4.bb
new file mode 100644
index 0000000..1165559
--- /dev/null
+++ b/meta/recipes-devtools/cve-check-tool/cve-check-tool_5.6.4.bb
@@ -0,0 +1,59 @@
+SUMMARY = "cve-check-tool"
+DESCRIPTION = "cve-check-tool is a tool for checking known (public) CVEs.\
+The tool will identify potentially vunlnerable software packages within Linux distributions through version matching."
+HOMEPAGE = "https://github.com/ikeydoherty/cve-check-tool"
+SECTION = "Development/Tools"
+LICENSE = "GPL-2.0+"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=e8c1458438ead3c34974bc0be3a03ed6"
+
+SRC_URI = "https://github.com/ikeydoherty/${BPN}/releases/download/v${PV}/${BP}.tar.xz \
+           file://check-for-malloc_trim-before-using-it.patch \
+          "
+
+SRC_URI[md5sum] = "c5f4247140fc9be3bf41491d31a34155"
+SRC_URI[sha256sum] = "b8f283be718af8d31232ac1bfc10a0378fb958aaaa49af39168f8acf501e6a5b"
+
+DEPENDS = "libcheck glib-2.0 json-glib curl libxml2 sqlite3 openssl ca-certificates"
+
+RDEPENDS_${PN} = "ca-certificates"
+
+inherit pkgconfig autotools
+
+EXTRA_OECONF = "--disable-coverage"
+CFLAGS_append = " -Wno-error=pedantic"
+
+python do_populate_cve_db () {
+    import subprocess
+    import time
+
+    if d.getVar("BB_NO_NETWORK", True) == "1":
+        bb.error("BB_NO_NETWORK is set; Can't update cve-check-tool database, "
+                  "CVEs won't be checked")
+        return
+
+    bb.utils.export_proxies(d)
+    # In case we don't inherit cve-check class, use default values defined in the class.
+    cve_dir = d.getVar("CVE_CHECK_DB_DIR", True) or d.expand("${DL_DIR}/CVE_CHECK")
+    cve_file = d.getVar("CVE_CHECK_TMP_FILE", True) or d.expand("${TMPDIR}/cve_check")
+    cve_cmd = "cve-check-update"
+    cmd = [cve_cmd, "-d", cve_dir]
+    bb.debug(1, "Updating cve-check-tool database located in %s" % cve_dir)
+    try:
+        output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
+        bb.debug(2, "Command '%s' returned:\n%s" % ("\n".join(cmd), output))
+        time_utc = time.gmtime(time.time())
+        time_format = "%Y-%m-%d %H:%M:%S"
+        with open(cve_file, "w") as f:
+            f.write("CVE database was updated on %s UTC\n\n"
+                    % time.strftime(time_format, time_utc))
+
+    except subprocess.CalledProcessError as e:
+        bb.warn("Error in executing cve-check-update: %s (output %s)" % (e, e.output))
+        if bb.data.inherits_class('cve-check', d):
+            bb.warn("Failed to update cve-check-tool database, CVEs won't be checked")
+}
+
+addtask populate_cve_db after do_populate_sysroot
+do_populate_cve_db[nostamp] = "1"
+
+BBCLASSEXTEND = "native nativesdk"
diff --git a/meta/recipes-devtools/cve-check-tool/files/check-for-malloc_trim-before-using-it.patch b/meta/recipes-devtools/cve-check-tool/files/check-for-malloc_trim-before-using-it.patch
new file mode 100644
index 0000000..0774ad9
--- /dev/null
+++ b/meta/recipes-devtools/cve-check-tool/files/check-for-malloc_trim-before-using-it.patch
@@ -0,0 +1,51 @@
+From ce64633b9733e962b8d8482244301f614d8b5845 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Mon, 22 Aug 2016 22:54:24 -0700
+Subject: [PATCH] Check for malloc_trim before using it
+
+malloc_trim is gnu specific and not all libc
+implement it, threfore write a configure check
+to poke for it first and use the define to
+guard its use.
+
+Helps in compiling on musl based systems
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+Upstream-Status: Submitted [https://github.com/ikeydoherty/cve-check-tool/pull/48]
+ configure.ac | 2 ++
+ src/core.c   | 4 ++--
+ 2 files changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index d3b66ce..79c3542 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -19,6 +19,8 @@ m4_define([json_required_version], [0.16.0])
+ m4_define([openssl_required_version],[1.0.0])
+ # TODO: Set minimum sqlite
+ 
++AC_CHECK_FUNCS_ONCE(malloc_trim)
++
+ PKG_CHECK_MODULES(CVE_CHECK_TOOL,
+                  [
+                   glib-2.0 >= glib_required_version,
+diff --git a/src/core.c b/src/core.c
+index 6263031..0d5df29 100644
+--- a/src/core.c
++++ b/src/core.c
+@@ -498,9 +498,9 @@ bool cve_db_load(CveDB *self, const char *fname)
+         }
+ 
+         b = true;
+-
++#ifdef HAVE_MALLOC_TRIM
+         malloc_trim(0);
+-
++#endif
+         xmlFreeTextReader(r);
+         if (fd) {
+                 close(fd);
+-- 
+2.9.3
+
-- 
2.6.6



  reply	other threads:[~2016-08-25 21:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-24 18:58 [PATCHv4 0/2] Add initial capability to check CVEs for recipes mariano.lopez
2016-08-24 18:58 ` [PATCHv4 1/2] cve-check-tool: Add recipe mariano.lopez
2016-08-25 14:28   ` Burton, Ross
2016-08-25 16:57     ` Khem Raj
2016-08-25 17:12       ` Burton, Ross
2016-08-25 13:01         ` mariano.lopez [this message]
2016-08-24 18:58 ` [PATCHv4 2/2] cve-check.bbclass: Add class mariano.lopez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1472130078-43004-1-git-send-email-mariano.lopez@linux.intel.com \
    --to=mariano.lopez@linux.intel.com \
    --cc=openembedded-core@lists.openembedded.org \
    --cc=ross.burton@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.