Openembedded Core Discussions
 help / color / mirror / Atom feed
From: akuster808 <akuster808@gmail.com>
To: Ross Burton <ross.burton@intel.com>,
	openembedded-core@lists.openembedded.org
Subject: Re: [PATCH 3/3] cve-update-db: refresh once every 24 hours
Date: Thu, 18 Jul 2019 15:31:36 -0700	[thread overview]
Message-ID: <2df077fa-fbfe-15f6-d690-ff3f611a2128@gmail.com> (raw)
In-Reply-To: <20190718200400.19750-3-ross.burton@intel.com>



On 7/18/19 1:04 PM, Ross Burton wrote:
> Check the mtime of the database before updating, and if it's less than 24 hours
> ago don't refresh.  This saves the HTTP fetches to determine if the data has
> been updated.
>
> Signed-off-by: Ross Burton <ross.burton@intel.com>
> ---
>  meta/recipes-core/meta/cve-update-db-native.bb | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/meta/recipes-core/meta/cve-update-db-native.bb b/meta/recipes-core/meta/cve-update-db-native.bb
> index cabbde5066c..2afca94fc6b 100644
> --- a/meta/recipes-core/meta/cve-update-db-native.bb
> +++ b/meta/recipes-core/meta/cve-update-db-native.bb
> @@ -22,7 +22,7 @@ python do_populate_cve_db() {
>      Update NVD database with json data feed
>      """
>  
> -    import sqlite3, urllib, shutil, gzip, re
> +    import sqlite3, urllib, shutil, gzip, re, time
>      from datetime import date
>  
>      BASE_URL = "https://nvd.nist.gov/feeds/json/cve/1.0/nvdcve-1.0-"
> @@ -37,6 +37,11 @@ python do_populate_cve_db() {
>      if not os.path.isdir(db_dir):
>          os.mkdir(db_dir)
>  
> +    expiry = time.time() - (60*60*24) # This time yesterday
> +    if os.path.exists(db_file) and expiry < os.path.getmtime(db_file):
> +        bb.note("CVE data updated less than 24 hours ago, not refreshing. Delete %s to force update." % db_file)
> +        return

Any reason this can't be configurable?

- armin
> +
>      # Connect to database
>      conn = sqlite3.connect(db_file)
>      c = conn.cursor()



  reply	other threads:[~2019-07-18 22:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-18 20:03 [PATCH 1/3] cve-update-db-native: use os.path.join instead of + Ross Burton
2019-07-18 20:03 ` [PATCH 2/3] cve-update-db: actually inherit native Ross Burton
2019-07-18 20:04 ` [PATCH 3/3] cve-update-db: refresh once every 24 hours Ross Burton
2019-07-18 22:31   ` akuster808 [this message]
2019-07-18 22:37     ` Burton, Ross
2019-07-18 20:31 ` ✗ patchtest: failure for "cve-update-db-native: use os.p..." and 2 more Patchwork

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=2df077fa-fbfe-15f6-d690-ff3f611a2128@gmail.com \
    --to=akuster808@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox