2018-04-04 22:05:33 +02:00
|
|
|
#!/usr/bin/env python
|
2009-10-28 00:28:40 +01:00
|
|
|
|
|
|
|
# Copyright (C) 2009 by Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
2018-04-04 22:05:33 +02:00
|
|
|
import argparse
|
|
|
|
import datetime
|
|
|
|
import fnmatch
|
|
|
|
import os
|
|
|
|
from collections import defaultdict
|
|
|
|
import re
|
|
|
|
import subprocess
|
2018-10-02 04:37:28 +02:00
|
|
|
import requests # URL checking
|
support/scripts/pkg-stats: add latest upstream version information
This commit adds fetching the latest upstream version of each package
from release-monitoring.org.
The fetching process first tries to use the package mappings of the
"Buildroot" distribution [1]. This mapping mechanism allows to tell
release-monitoring.org what is the name of a package in a given
distribution/build-system. For example, the package xutil_util-macros
in Buildroot is named xorg-util-macros on release-monitoring.org. This
mapping can be seen in the section "Mappings" of
https://release-monitoring.org/project/15037/.
If there is no mapping, then it does a regular search, and within the
search results, looks for a package whose name matches the Buildroot
name.
Even though fetching from release-monitoring.org is a bit slow, using
multiprocessing.Pool has proven to not be reliable, with some requests
ending up with an exception. So we keep a serialized approach, but
with a single HTTPSConnectionPool() for all queries. Long term, we
hope to be able to use a database dump of release-monitoring.org
instead.
From an output point of view, the latest version column:
- Is green when the version in Buildroot matches the latest upstream
version
- Is orange when the latest upstream version is unknown because the
package was not found on release-monitoring.org
- Is red when the version in Buildroot doesn't match the latest
upstream version. Note that we are not doing anything smart here:
we are just testing if the strings are equal or not.
- The cell contains the link to the project on release-monitoring.org
if found.
- The cell indicates if the match was done using a distro mapping, or
through a regular search.
[1] https://release-monitoring.org/distro/Buildroot/
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Tested-by: Matthew Weber <matthew.weber@rockwellcollins.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-02-05 16:19:59 +01:00
|
|
|
import json
|
2020-02-20 19:27:23 +01:00
|
|
|
import ijson
|
support/scripts/pkg-stats: add latest upstream version information
This commit adds fetching the latest upstream version of each package
from release-monitoring.org.
The fetching process first tries to use the package mappings of the
"Buildroot" distribution [1]. This mapping mechanism allows to tell
release-monitoring.org what is the name of a package in a given
distribution/build-system. For example, the package xutil_util-macros
in Buildroot is named xorg-util-macros on release-monitoring.org. This
mapping can be seen in the section "Mappings" of
https://release-monitoring.org/project/15037/.
If there is no mapping, then it does a regular search, and within the
search results, looks for a package whose name matches the Buildroot
name.
Even though fetching from release-monitoring.org is a bit slow, using
multiprocessing.Pool has proven to not be reliable, with some requests
ending up with an exception. So we keep a serialized approach, but
with a single HTTPSConnectionPool() for all queries. Long term, we
hope to be able to use a database dump of release-monitoring.org
instead.
From an output point of view, the latest version column:
- Is green when the version in Buildroot matches the latest upstream
version
- Is orange when the latest upstream version is unknown because the
package was not found on release-monitoring.org
- Is red when the version in Buildroot doesn't match the latest
upstream version. Note that we are not doing anything smart here:
we are just testing if the strings are equal or not.
- The cell contains the link to the project on release-monitoring.org
if found.
- The cell indicates if the match was done using a distro mapping, or
through a regular search.
[1] https://release-monitoring.org/distro/Buildroot/
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Tested-by: Matthew Weber <matthew.weber@rockwellcollins.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-02-05 16:19:59 +01:00
|
|
|
import certifi
|
2020-02-15 13:44:16 +01:00
|
|
|
import distutils.version
|
|
|
|
import time
|
|
|
|
import gzip
|
2020-03-07 08:56:24 +01:00
|
|
|
import sys
|
support/scripts/pkg-stats: add latest upstream version information
This commit adds fetching the latest upstream version of each package
from release-monitoring.org.
The fetching process first tries to use the package mappings of the
"Buildroot" distribution [1]. This mapping mechanism allows to tell
release-monitoring.org what is the name of a package in a given
distribution/build-system. For example, the package xutil_util-macros
in Buildroot is named xorg-util-macros on release-monitoring.org. This
mapping can be seen in the section "Mappings" of
https://release-monitoring.org/project/15037/.
If there is no mapping, then it does a regular search, and within the
search results, looks for a package whose name matches the Buildroot
name.
Even though fetching from release-monitoring.org is a bit slow, using
multiprocessing.Pool has proven to not be reliable, with some requests
ending up with an exception. So we keep a serialized approach, but
with a single HTTPSConnectionPool() for all queries. Long term, we
hope to be able to use a database dump of release-monitoring.org
instead.
From an output point of view, the latest version column:
- Is green when the version in Buildroot matches the latest upstream
version
- Is orange when the latest upstream version is unknown because the
package was not found on release-monitoring.org
- Is red when the version in Buildroot doesn't match the latest
upstream version. Note that we are not doing anything smart here:
we are just testing if the strings are equal or not.
- The cell contains the link to the project on release-monitoring.org
if found.
- The cell indicates if the match was done using a distro mapping, or
through a regular search.
[1] https://release-monitoring.org/distro/Buildroot/
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Tested-by: Matthew Weber <matthew.weber@rockwellcollins.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-02-05 16:19:59 +01:00
|
|
|
from urllib3 import HTTPSConnectionPool
|
|
|
|
from urllib3.exceptions import HTTPError
|
2018-10-02 04:37:29 +02:00
|
|
|
from multiprocessing import Pool
|
2018-04-04 22:05:33 +02:00
|
|
|
|
2020-03-07 08:56:24 +01:00
|
|
|
sys.path.append('utils/')
|
|
|
|
from getdeveloperlib import parse_developers
|
|
|
|
|
2020-02-15 13:44:16 +01:00
|
|
|
NVD_START_YEAR = 2002
|
|
|
|
NVD_JSON_VERSION = "1.0"
|
|
|
|
NVD_BASE_URL = "https://nvd.nist.gov/feeds/json/cve/" + NVD_JSON_VERSION
|
|
|
|
|
2019-02-07 22:04:26 +01:00
|
|
|
INFRA_RE = re.compile(r"\$\(eval \$\(([a-z-]*)-package\)\)")
|
|
|
|
URL_RE = re.compile(r"\s*https?://\S*\s*$")
|
2018-04-04 22:05:33 +02:00
|
|
|
|
support/scripts/pkg-stats: add latest upstream version information
This commit adds fetching the latest upstream version of each package
from release-monitoring.org.
The fetching process first tries to use the package mappings of the
"Buildroot" distribution [1]. This mapping mechanism allows to tell
release-monitoring.org what is the name of a package in a given
distribution/build-system. For example, the package xutil_util-macros
in Buildroot is named xorg-util-macros on release-monitoring.org. This
mapping can be seen in the section "Mappings" of
https://release-monitoring.org/project/15037/.
If there is no mapping, then it does a regular search, and within the
search results, looks for a package whose name matches the Buildroot
name.
Even though fetching from release-monitoring.org is a bit slow, using
multiprocessing.Pool has proven to not be reliable, with some requests
ending up with an exception. So we keep a serialized approach, but
with a single HTTPSConnectionPool() for all queries. Long term, we
hope to be able to use a database dump of release-monitoring.org
instead.
From an output point of view, the latest version column:
- Is green when the version in Buildroot matches the latest upstream
version
- Is orange when the latest upstream version is unknown because the
package was not found on release-monitoring.org
- Is red when the version in Buildroot doesn't match the latest
upstream version. Note that we are not doing anything smart here:
we are just testing if the strings are equal or not.
- The cell contains the link to the project on release-monitoring.org
if found.
- The cell indicates if the match was done using a distro mapping, or
through a regular search.
[1] https://release-monitoring.org/distro/Buildroot/
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Tested-by: Matthew Weber <matthew.weber@rockwellcollins.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-02-05 16:19:59 +01:00
|
|
|
RM_API_STATUS_ERROR = 1
|
|
|
|
RM_API_STATUS_FOUND_BY_DISTRO = 2
|
|
|
|
RM_API_STATUS_FOUND_BY_PATTERN = 3
|
|
|
|
RM_API_STATUS_NOT_FOUND = 4
|
2018-04-04 22:05:33 +02:00
|
|
|
|
2019-08-01 17:12:44 +02:00
|
|
|
# Used to make multiple requests to the same host. It is global
|
|
|
|
# because it's used by sub-processes.
|
|
|
|
http_pool = None
|
|
|
|
|
2020-03-07 08:56:29 +01:00
|
|
|
class Defconfig:
|
|
|
|
def __init__(self, name, path):
|
|
|
|
self.name = name
|
|
|
|
self.path = path
|
|
|
|
self.developers = None
|
|
|
|
|
|
|
|
def set_developers(self, developers):
|
|
|
|
"""
|
|
|
|
Fills in the .developers field
|
|
|
|
"""
|
|
|
|
self.developers = [
|
|
|
|
developer.name
|
|
|
|
for developer in developers
|
|
|
|
if developer.hasfile(self.path)
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
def get_defconfig_list():
|
|
|
|
"""
|
|
|
|
Builds the list of Buildroot defconfigs, returning a list of Defconfig
|
|
|
|
objects.
|
|
|
|
"""
|
|
|
|
return [
|
|
|
|
Defconfig(name[:-len('_defconfig')], os.path.join('configs', name))
|
|
|
|
for name in os.listdir('configs')
|
|
|
|
if name.endswith('_defconfig')
|
|
|
|
]
|
|
|
|
|
2019-02-07 22:04:26 +01:00
|
|
|
|
2018-04-04 22:05:33 +02:00
|
|
|
class Package:
|
2020-03-07 08:56:25 +01:00
|
|
|
all_licenses = dict()
|
2018-04-04 22:05:33 +02:00
|
|
|
all_license_files = list()
|
|
|
|
all_versions = dict()
|
2020-02-15 13:44:16 +01:00
|
|
|
all_ignored_cves = dict()
|
2020-03-07 08:56:32 +01:00
|
|
|
# This is the list of all possible checks. Add new checks to this list so
|
|
|
|
# a tool that post-processeds the json output knows the checks before
|
|
|
|
# iterating over the packages.
|
|
|
|
status_checks = ['cve', 'developers', 'hash', 'license',
|
|
|
|
'license-files', 'patches', 'pkg-check', 'url', 'version']
|
2018-04-04 22:05:33 +02:00
|
|
|
|
|
|
|
def __init__(self, name, path):
|
|
|
|
self.name = name
|
|
|
|
self.path = path
|
2020-03-07 08:56:28 +01:00
|
|
|
self.pkg_path = os.path.dirname(path)
|
2018-04-04 22:05:33 +02:00
|
|
|
self.infras = None
|
2020-03-07 08:56:25 +01:00
|
|
|
self.license = None
|
2018-04-04 22:05:33 +02:00
|
|
|
self.has_license = False
|
|
|
|
self.has_license_files = False
|
|
|
|
self.has_hash = False
|
2020-03-07 08:56:23 +01:00
|
|
|
self.patch_files = []
|
2018-04-04 22:05:33 +02:00
|
|
|
self.warnings = 0
|
|
|
|
self.current_version = None
|
2018-10-02 04:37:28 +02:00
|
|
|
self.url = None
|
2018-10-02 04:37:29 +02:00
|
|
|
self.url_worker = None
|
2020-02-15 13:44:16 +01:00
|
|
|
self.cves = list()
|
2020-03-07 08:56:22 +01:00
|
|
|
self.latest_version = {'status': RM_API_STATUS_ERROR, 'version': None, 'id': None}
|
2020-03-07 08:56:26 +01:00
|
|
|
self.status = {}
|
2018-04-04 22:05:33 +02:00
|
|
|
|
|
|
|
def pkgvar(self):
|
|
|
|
return self.name.upper().replace("-", "_")
|
|
|
|
|
2018-10-02 04:37:28 +02:00
|
|
|
def set_url(self):
|
|
|
|
"""
|
|
|
|
Fills in the .url field
|
|
|
|
"""
|
2020-03-07 08:56:26 +01:00
|
|
|
self.status['url'] = ("warning", "no Config.in")
|
2018-10-02 04:37:28 +02:00
|
|
|
for filename in os.listdir(os.path.dirname(self.path)):
|
|
|
|
if fnmatch.fnmatch(filename, 'Config.*'):
|
|
|
|
fp = open(os.path.join(os.path.dirname(self.path), filename), "r")
|
|
|
|
for config_line in fp:
|
|
|
|
if URL_RE.match(config_line):
|
|
|
|
self.url = config_line.strip()
|
2020-03-07 08:56:26 +01:00
|
|
|
self.status['url'] = ("ok", "found")
|
2018-10-02 04:37:28 +02:00
|
|
|
fp.close()
|
|
|
|
return
|
2020-03-07 08:56:26 +01:00
|
|
|
self.status['url'] = ("error", "missing")
|
2018-10-02 04:37:28 +02:00
|
|
|
fp.close()
|
|
|
|
|
2020-03-07 08:56:23 +01:00
|
|
|
@property
|
|
|
|
def patch_count(self):
|
|
|
|
return len(self.patch_files)
|
|
|
|
|
2020-03-07 08:56:31 +01:00
|
|
|
@property
|
|
|
|
def has_valid_infra(self):
|
|
|
|
try:
|
|
|
|
if self.infras[0][1] == 'virtual':
|
|
|
|
return False
|
|
|
|
except IndexError:
|
|
|
|
return False
|
|
|
|
return True
|
|
|
|
|
2018-04-04 22:05:33 +02:00
|
|
|
def set_infra(self):
|
|
|
|
"""
|
|
|
|
Fills in the .infras field
|
|
|
|
"""
|
|
|
|
self.infras = list()
|
|
|
|
with open(self.path, 'r') as f:
|
|
|
|
lines = f.readlines()
|
|
|
|
for l in lines:
|
|
|
|
match = INFRA_RE.match(l)
|
|
|
|
if not match:
|
|
|
|
continue
|
|
|
|
infra = match.group(1)
|
|
|
|
if infra.startswith("host-"):
|
|
|
|
self.infras.append(("host", infra[5:]))
|
|
|
|
else:
|
|
|
|
self.infras.append(("target", infra))
|
|
|
|
|
|
|
|
def set_license(self):
|
|
|
|
"""
|
2020-03-07 08:56:26 +01:00
|
|
|
Fills in the .status['license'] and .status['license-files'] fields
|
2018-04-04 22:05:33 +02:00
|
|
|
"""
|
2020-03-07 08:56:31 +01:00
|
|
|
if not self.has_valid_infra:
|
|
|
|
self.status['license'] = ("na", "no valid package infra")
|
|
|
|
self.status['license-files'] = ("na", "no valid package infra")
|
|
|
|
return
|
|
|
|
|
2018-04-04 22:05:33 +02:00
|
|
|
var = self.pkgvar()
|
2020-03-07 08:56:26 +01:00
|
|
|
self.status['license'] = ("error", "missing")
|
|
|
|
self.status['license-files'] = ("error", "missing")
|
2018-04-04 22:05:33 +02:00
|
|
|
if var in self.all_licenses:
|
2020-03-07 08:56:25 +01:00
|
|
|
self.license = self.all_licenses[var]
|
2020-03-07 08:56:26 +01:00
|
|
|
self.status['license'] = ("ok", "found")
|
2018-04-04 22:05:33 +02:00
|
|
|
if var in self.all_license_files:
|
2020-03-07 08:56:26 +01:00
|
|
|
self.status['license-files'] = ("ok", "found")
|
2018-04-04 22:05:33 +02:00
|
|
|
|
|
|
|
def set_hash_info(self):
|
|
|
|
"""
|
2020-03-07 08:56:26 +01:00
|
|
|
Fills in the .status['hash'] field
|
2018-04-04 22:05:33 +02:00
|
|
|
"""
|
2020-03-07 08:56:31 +01:00
|
|
|
if not self.has_valid_infra:
|
|
|
|
self.status['hash'] = ("na", "no valid package infra")
|
|
|
|
self.status['hash-license'] = ("na", "no valid package infra")
|
|
|
|
return
|
|
|
|
|
2018-04-04 22:05:33 +02:00
|
|
|
hashpath = self.path.replace(".mk", ".hash")
|
2020-03-07 08:56:26 +01:00
|
|
|
if os.path.exists(hashpath):
|
|
|
|
self.status['hash'] = ("ok", "found")
|
|
|
|
else:
|
|
|
|
self.status['hash'] = ("error", "missing")
|
2018-04-04 22:05:33 +02:00
|
|
|
|
|
|
|
def set_patch_count(self):
|
|
|
|
"""
|
2020-03-07 08:56:26 +01:00
|
|
|
Fills in the .patch_count, .patch_files and .status['patches'] fields
|
2018-04-04 22:05:33 +02:00
|
|
|
"""
|
2020-03-07 08:56:31 +01:00
|
|
|
if not self.has_valid_infra:
|
|
|
|
self.status['patches'] = ("na", "no valid package infra")
|
|
|
|
return
|
|
|
|
|
2018-04-04 22:05:33 +02:00
|
|
|
pkgdir = os.path.dirname(self.path)
|
|
|
|
for subdir, _, _ in os.walk(pkgdir):
|
2020-03-07 08:56:23 +01:00
|
|
|
self.patch_files = fnmatch.filter(os.listdir(subdir), '*.patch')
|
2018-04-04 22:05:33 +02:00
|
|
|
|
2020-03-07 08:56:26 +01:00
|
|
|
if self.patch_count == 0:
|
|
|
|
self.status['patches'] = ("ok", "no patches")
|
|
|
|
elif self.patch_count < 5:
|
|
|
|
self.status['patches'] = ("warning", "some patches")
|
|
|
|
else:
|
|
|
|
self.status['patches'] = ("error", "lots of patches")
|
|
|
|
|
2018-04-04 22:05:33 +02:00
|
|
|
def set_current_version(self):
|
|
|
|
"""
|
|
|
|
Fills in the .current_version field
|
|
|
|
"""
|
|
|
|
var = self.pkgvar()
|
|
|
|
if var in self.all_versions:
|
|
|
|
self.current_version = self.all_versions[var]
|
|
|
|
|
|
|
|
def set_check_package_warnings(self):
|
|
|
|
"""
|
2020-03-07 08:56:26 +01:00
|
|
|
Fills in the .warnings and .status['pkg-check'] fields
|
2018-04-04 22:05:33 +02:00
|
|
|
"""
|
|
|
|
cmd = ["./utils/check-package"]
|
|
|
|
pkgdir = os.path.dirname(self.path)
|
2020-03-07 08:56:26 +01:00
|
|
|
self.status['pkg-check'] = ("error", "Missing")
|
2018-04-04 22:05:33 +02:00
|
|
|
for root, dirs, files in os.walk(pkgdir):
|
|
|
|
for f in files:
|
|
|
|
if f.endswith(".mk") or f.endswith(".hash") or f == "Config.in" or f == "Config.in.host":
|
|
|
|
cmd.append(os.path.join(root, f))
|
|
|
|
o = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[1]
|
|
|
|
lines = o.splitlines()
|
|
|
|
for line in lines:
|
2020-03-01 22:18:48 +01:00
|
|
|
m = re.match("^([0-9]*) warnings generated", line.decode())
|
2018-04-04 22:05:33 +02:00
|
|
|
if m:
|
|
|
|
self.warnings = int(m.group(1))
|
2020-03-07 08:56:26 +01:00
|
|
|
if self.warnings == 0:
|
|
|
|
self.status['pkg-check'] = ("ok", "no warnings")
|
|
|
|
else:
|
|
|
|
self.status['pkg-check'] = ("error", "{} warnings".format(self.warnings))
|
2018-04-04 22:05:33 +02:00
|
|
|
return
|
|
|
|
|
2020-02-15 13:44:16 +01:00
|
|
|
def is_cve_ignored(self, cve):
|
|
|
|
"""
|
|
|
|
Tells if the CVE is ignored by the package
|
|
|
|
"""
|
|
|
|
return cve in self.all_ignored_cves.get(self.pkgvar(), [])
|
|
|
|
|
2020-03-07 08:56:24 +01:00
|
|
|
def set_developers(self, developers):
|
|
|
|
"""
|
2020-03-07 08:56:26 +01:00
|
|
|
Fills in the .developers and .status['developers'] field
|
2020-03-07 08:56:24 +01:00
|
|
|
"""
|
|
|
|
self.developers = [
|
|
|
|
dev.name
|
|
|
|
for dev in developers
|
|
|
|
if dev.hasfile(self.path)
|
|
|
|
]
|
|
|
|
|
2020-03-07 08:56:26 +01:00
|
|
|
if self.developers:
|
|
|
|
self.status['developers'] = ("ok", "{} developers".format(len(self.developers)))
|
|
|
|
else:
|
|
|
|
self.status['developers'] = ("warning", "no developers")
|
|
|
|
|
|
|
|
def is_status_ok(self, name):
|
|
|
|
return self.status[name][0] == 'ok'
|
|
|
|
|
2018-04-04 22:05:33 +02:00
|
|
|
def __eq__(self, other):
|
|
|
|
return self.path == other.path
|
|
|
|
|
|
|
|
def __lt__(self, other):
|
|
|
|
return self.path < other.path
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return "%s (path='%s', license='%s', license_files='%s', hash='%s', patches=%d)" % \
|
2020-03-07 08:56:26 +01:00
|
|
|
(self.name, self.path, self.is_status_ok('license'), self.is_status_ok('license-files'), self.status['hash'], self.patch_count)
|
2018-04-04 22:05:33 +02:00
|
|
|
|
|
|
|
|
2020-02-15 13:44:16 +01:00
|
|
|
class CVE:
|
|
|
|
"""An accessor class for CVE Items in NVD files"""
|
|
|
|
def __init__(self, nvd_cve):
|
|
|
|
"""Initialize a CVE from its NVD JSON representation"""
|
|
|
|
self.nvd_cve = nvd_cve
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def download_nvd_year(nvd_path, year):
|
|
|
|
metaf = "nvdcve-%s-%s.meta" % (NVD_JSON_VERSION, year)
|
|
|
|
path_metaf = os.path.join(nvd_path, metaf)
|
|
|
|
jsonf_gz = "nvdcve-%s-%s.json.gz" % (NVD_JSON_VERSION, year)
|
|
|
|
path_jsonf_gz = os.path.join(nvd_path, jsonf_gz)
|
|
|
|
|
|
|
|
# If the database file is less than a day old, we assume the NVD data
|
|
|
|
# locally available is recent enough.
|
|
|
|
if os.path.exists(path_jsonf_gz) and os.stat(path_jsonf_gz).st_mtime >= time.time() - 86400:
|
|
|
|
return path_jsonf_gz
|
|
|
|
|
|
|
|
# If not, we download the meta file
|
|
|
|
url = "%s/%s" % (NVD_BASE_URL, metaf)
|
|
|
|
print("Getting %s" % url)
|
|
|
|
page_meta = requests.get(url)
|
|
|
|
page_meta.raise_for_status()
|
|
|
|
|
|
|
|
# If the meta file already existed, we compare the existing
|
|
|
|
# one with the data newly downloaded. If they are different,
|
|
|
|
# we need to re-download the database.
|
|
|
|
# If the database does not exist locally, we need to redownload it in
|
|
|
|
# any case.
|
|
|
|
if os.path.exists(path_metaf) and os.path.exists(path_jsonf_gz):
|
|
|
|
meta_known = open(path_metaf, "r").read()
|
|
|
|
if page_meta.text == meta_known:
|
|
|
|
return path_jsonf_gz
|
|
|
|
|
|
|
|
# Grab the compressed JSON NVD, and write files to disk
|
|
|
|
url = "%s/%s" % (NVD_BASE_URL, jsonf_gz)
|
|
|
|
print("Getting %s" % url)
|
|
|
|
page_json = requests.get(url)
|
|
|
|
page_json.raise_for_status()
|
|
|
|
open(path_jsonf_gz, "wb").write(page_json.content)
|
|
|
|
open(path_metaf, "w").write(page_meta.text)
|
|
|
|
return path_jsonf_gz
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def read_nvd_dir(cls, nvd_dir):
|
|
|
|
"""
|
|
|
|
Iterate over all the CVEs contained in NIST Vulnerability Database
|
|
|
|
feeds since NVD_START_YEAR. If the files are missing or outdated in
|
|
|
|
nvd_dir, a fresh copy will be downloaded, and kept in .json.gz
|
|
|
|
"""
|
|
|
|
for year in range(NVD_START_YEAR, datetime.datetime.now().year + 1):
|
|
|
|
filename = CVE.download_nvd_year(nvd_dir, year)
|
|
|
|
try:
|
2020-02-20 19:27:23 +01:00
|
|
|
content = ijson.items(gzip.GzipFile(filename), 'CVE_Items.item')
|
2020-02-15 13:44:16 +01:00
|
|
|
except:
|
|
|
|
print("ERROR: cannot read %s. Please remove the file then rerun this script" % filename)
|
|
|
|
raise
|
2020-02-20 19:27:23 +01:00
|
|
|
for cve in content:
|
2020-02-15 13:44:16 +01:00
|
|
|
yield cls(cve['cve'])
|
|
|
|
|
|
|
|
def each_product(self):
|
|
|
|
"""Iterate over each product section of this cve"""
|
|
|
|
for vendor in self.nvd_cve['affects']['vendor']['vendor_data']:
|
|
|
|
for product in vendor['product']['product_data']:
|
|
|
|
yield product
|
|
|
|
|
|
|
|
@property
|
|
|
|
def identifier(self):
|
|
|
|
"""The CVE unique identifier"""
|
|
|
|
return self.nvd_cve['CVE_data_meta']['ID']
|
|
|
|
|
|
|
|
@property
|
|
|
|
def pkg_names(self):
|
|
|
|
"""The set of package names referred by this CVE definition"""
|
|
|
|
return set(p['product_name'] for p in self.each_product())
|
|
|
|
|
|
|
|
def affects(self, br_pkg):
|
|
|
|
"""
|
|
|
|
True if the Buildroot Package object passed as argument is affected
|
|
|
|
by this CVE.
|
|
|
|
"""
|
2020-02-19 00:35:26 +01:00
|
|
|
if br_pkg.is_cve_ignored(self.identifier):
|
|
|
|
return False
|
|
|
|
|
2020-02-15 13:44:16 +01:00
|
|
|
for product in self.each_product():
|
|
|
|
if product['product_name'] != br_pkg.name:
|
|
|
|
continue
|
|
|
|
|
|
|
|
for v in product['version']['version_data']:
|
|
|
|
if v["version_affected"] == "=":
|
|
|
|
if br_pkg.current_version == v["version_value"]:
|
|
|
|
return True
|
|
|
|
elif v["version_affected"] == "<=":
|
|
|
|
pkg_version = distutils.version.LooseVersion(br_pkg.current_version)
|
|
|
|
if not hasattr(pkg_version, "version"):
|
|
|
|
print("Cannot parse package '%s' version '%s'" % (br_pkg.name, br_pkg.current_version))
|
|
|
|
continue
|
|
|
|
cve_affected_version = distutils.version.LooseVersion(v["version_value"])
|
|
|
|
if not hasattr(cve_affected_version, "version"):
|
|
|
|
print("Cannot parse CVE affected version '%s'" % v["version_value"])
|
|
|
|
continue
|
|
|
|
return pkg_version <= cve_affected_version
|
|
|
|
else:
|
|
|
|
print("version_affected: %s" % v['version_affected'])
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
2018-04-04 22:05:33 +02:00
|
|
|
def get_pkglist(npackages, package_list):
|
|
|
|
"""
|
|
|
|
Builds the list of Buildroot packages, returning a list of Package
|
|
|
|
objects. Only the .name and .path fields of the Package object are
|
|
|
|
initialized.
|
|
|
|
|
|
|
|
npackages: limit to N packages
|
|
|
|
package_list: limit to those packages in this list
|
|
|
|
"""
|
|
|
|
WALK_USEFUL_SUBDIRS = ["boot", "linux", "package", "toolchain"]
|
|
|
|
WALK_EXCLUDES = ["boot/common.mk",
|
|
|
|
"linux/linux-ext-.*.mk",
|
|
|
|
"package/freescale-imx/freescale-imx.mk",
|
|
|
|
"package/gcc/gcc.mk",
|
|
|
|
"package/gstreamer/gstreamer.mk",
|
|
|
|
"package/gstreamer1/gstreamer1.mk",
|
|
|
|
"package/gtk2-themes/gtk2-themes.mk",
|
|
|
|
"package/matchbox/matchbox.mk",
|
|
|
|
"package/opengl/opengl.mk",
|
|
|
|
"package/qt5/qt5.mk",
|
|
|
|
"package/x11r7/x11r7.mk",
|
|
|
|
"package/doc-asciidoc.mk",
|
|
|
|
"package/pkg-.*.mk",
|
|
|
|
"package/nvidia-tegra23/nvidia-tegra23.mk",
|
|
|
|
"toolchain/toolchain-external/pkg-toolchain-external.mk",
|
|
|
|
"toolchain/toolchain-external/toolchain-external.mk",
|
|
|
|
"toolchain/toolchain.mk",
|
|
|
|
"toolchain/helpers.mk",
|
|
|
|
"toolchain/toolchain-wrapper.mk"]
|
|
|
|
packages = list()
|
|
|
|
count = 0
|
|
|
|
for root, dirs, files in os.walk("."):
|
|
|
|
rootdir = root.split("/")
|
|
|
|
if len(rootdir) < 2:
|
|
|
|
continue
|
|
|
|
if rootdir[1] not in WALK_USEFUL_SUBDIRS:
|
|
|
|
continue
|
|
|
|
for f in files:
|
|
|
|
if not f.endswith(".mk"):
|
|
|
|
continue
|
|
|
|
# Strip ending ".mk"
|
|
|
|
pkgname = f[:-3]
|
|
|
|
if package_list and pkgname not in package_list:
|
|
|
|
continue
|
|
|
|
pkgpath = os.path.join(root, f)
|
|
|
|
skip = False
|
|
|
|
for exclude in WALK_EXCLUDES:
|
|
|
|
# pkgpath[2:] strips the initial './'
|
|
|
|
if re.match(exclude, pkgpath[2:]):
|
|
|
|
skip = True
|
|
|
|
continue
|
|
|
|
if skip:
|
|
|
|
continue
|
|
|
|
p = Package(pkgname, pkgpath)
|
|
|
|
packages.append(p)
|
|
|
|
count += 1
|
|
|
|
if npackages and count == npackages:
|
|
|
|
return packages
|
|
|
|
return packages
|
|
|
|
|
|
|
|
|
|
|
|
def package_init_make_info():
|
2019-07-19 16:35:55 +02:00
|
|
|
# Fetch all variables at once
|
|
|
|
variables = subprocess.check_output(["make", "BR2_HAVE_DOT_CONFIG=y", "-s", "printvars",
|
2020-02-15 13:44:16 +01:00
|
|
|
"VARS=%_LICENSE %_LICENSE_FILES %_VERSION %_IGNORE_CVES"])
|
2020-03-01 22:18:48 +01:00
|
|
|
variable_list = variables.decode().splitlines()
|
2018-04-04 22:05:33 +02:00
|
|
|
|
|
|
|
# We process first the host package VERSION, and then the target
|
|
|
|
# package VERSION. This means that if a package exists in both
|
2019-07-19 16:35:55 +02:00
|
|
|
# target and host variants, with different values (eg. version
|
|
|
|
# numbers (unlikely)), we'll report the target one.
|
|
|
|
variable_list = [x[5:] for x in variable_list if x.startswith("HOST_")] + \
|
|
|
|
[x for x in variable_list if not x.startswith("HOST_")]
|
|
|
|
|
|
|
|
for l in variable_list:
|
2018-04-04 22:05:33 +02:00
|
|
|
# Get variable name and value
|
|
|
|
pkgvar, value = l.split("=")
|
|
|
|
|
2019-07-19 16:35:55 +02:00
|
|
|
# Strip the suffix according to the variable
|
|
|
|
if pkgvar.endswith("_LICENSE"):
|
|
|
|
# If value is "unknown", no license details available
|
|
|
|
if value == "unknown":
|
|
|
|
continue
|
|
|
|
pkgvar = pkgvar[:-8]
|
2020-03-07 08:56:25 +01:00
|
|
|
Package.all_licenses[pkgvar] = value
|
2018-04-04 22:05:33 +02:00
|
|
|
|
2019-08-01 17:12:43 +02:00
|
|
|
elif pkgvar.endswith("_LICENSE_FILES"):
|
2019-07-19 16:35:55 +02:00
|
|
|
if pkgvar.endswith("_MANIFEST_LICENSE_FILES"):
|
|
|
|
continue
|
|
|
|
pkgvar = pkgvar[:-14]
|
|
|
|
Package.all_license_files.append(pkgvar)
|
2018-04-04 22:05:33 +02:00
|
|
|
|
2019-07-19 16:35:55 +02:00
|
|
|
elif pkgvar.endswith("_VERSION"):
|
|
|
|
if pkgvar.endswith("_DL_VERSION"):
|
|
|
|
continue
|
|
|
|
pkgvar = pkgvar[:-8]
|
|
|
|
Package.all_versions[pkgvar] = value
|
2018-04-04 22:05:33 +02:00
|
|
|
|
2020-02-15 13:44:16 +01:00
|
|
|
elif pkgvar.endswith("_IGNORE_CVES"):
|
|
|
|
pkgvar = pkgvar[:-12]
|
|
|
|
Package.all_ignored_cves[pkgvar] = value.split()
|
|
|
|
|
2018-04-04 22:05:33 +02:00
|
|
|
|
2018-10-02 04:37:29 +02:00
|
|
|
def check_url_status_worker(url, url_status):
|
2020-03-07 08:56:26 +01:00
|
|
|
if url_status[0] == 'ok':
|
2018-10-02 04:37:28 +02:00
|
|
|
try:
|
2018-10-02 04:37:29 +02:00
|
|
|
url_status_code = requests.head(url, timeout=30).status_code
|
2018-10-02 04:37:28 +02:00
|
|
|
if url_status_code >= 400:
|
2020-03-07 08:56:26 +01:00
|
|
|
return ("error", "invalid {}".format(url_status_code))
|
2018-10-02 04:37:28 +02:00
|
|
|
except requests.exceptions.RequestException:
|
2020-03-07 08:56:26 +01:00
|
|
|
return ("error", "invalid (err)")
|
|
|
|
return ("ok", "valid")
|
2018-10-02 04:37:29 +02:00
|
|
|
return url_status
|
|
|
|
|
|
|
|
|
|
|
|
def check_package_urls(packages):
|
2020-03-01 22:25:28 +01:00
|
|
|
pool = Pool(processes=64)
|
2018-10-02 04:37:29 +02:00
|
|
|
for pkg in packages:
|
2020-03-07 08:56:26 +01:00
|
|
|
pkg.url_worker = pool.apply_async(check_url_status_worker, (pkg.url, pkg.status['url']))
|
2018-10-02 04:37:29 +02:00
|
|
|
for pkg in packages:
|
2020-03-07 08:56:26 +01:00
|
|
|
pkg.status['url'] = pkg.url_worker.get(timeout=3600)
|
2020-03-01 22:25:28 +01:00
|
|
|
del pkg.url_worker
|
|
|
|
pool.terminate()
|
2018-10-02 04:37:28 +02:00
|
|
|
|
|
|
|
|
support/scripts/pkg-stats: add latest upstream version information
This commit adds fetching the latest upstream version of each package
from release-monitoring.org.
The fetching process first tries to use the package mappings of the
"Buildroot" distribution [1]. This mapping mechanism allows to tell
release-monitoring.org what is the name of a package in a given
distribution/build-system. For example, the package xutil_util-macros
in Buildroot is named xorg-util-macros on release-monitoring.org. This
mapping can be seen in the section "Mappings" of
https://release-monitoring.org/project/15037/.
If there is no mapping, then it does a regular search, and within the
search results, looks for a package whose name matches the Buildroot
name.
Even though fetching from release-monitoring.org is a bit slow, using
multiprocessing.Pool has proven to not be reliable, with some requests
ending up with an exception. So we keep a serialized approach, but
with a single HTTPSConnectionPool() for all queries. Long term, we
hope to be able to use a database dump of release-monitoring.org
instead.
From an output point of view, the latest version column:
- Is green when the version in Buildroot matches the latest upstream
version
- Is orange when the latest upstream version is unknown because the
package was not found on release-monitoring.org
- Is red when the version in Buildroot doesn't match the latest
upstream version. Note that we are not doing anything smart here:
we are just testing if the strings are equal or not.
- The cell contains the link to the project on release-monitoring.org
if found.
- The cell indicates if the match was done using a distro mapping, or
through a regular search.
[1] https://release-monitoring.org/distro/Buildroot/
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Tested-by: Matthew Weber <matthew.weber@rockwellcollins.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-02-05 16:19:59 +01:00
|
|
|
def release_monitoring_get_latest_version_by_distro(pool, name):
|
|
|
|
try:
|
|
|
|
req = pool.request('GET', "/api/project/Buildroot/%s" % name)
|
|
|
|
except HTTPError:
|
|
|
|
return (RM_API_STATUS_ERROR, None, None)
|
|
|
|
|
|
|
|
if req.status != 200:
|
|
|
|
return (RM_API_STATUS_NOT_FOUND, None, None)
|
|
|
|
|
|
|
|
data = json.loads(req.data)
|
|
|
|
|
|
|
|
if 'version' in data:
|
|
|
|
return (RM_API_STATUS_FOUND_BY_DISTRO, data['version'], data['id'])
|
|
|
|
else:
|
|
|
|
return (RM_API_STATUS_FOUND_BY_DISTRO, None, data['id'])
|
|
|
|
|
|
|
|
|
|
|
|
def release_monitoring_get_latest_version_by_guess(pool, name):
|
|
|
|
try:
|
|
|
|
req = pool.request('GET', "/api/projects/?pattern=%s" % name)
|
|
|
|
except HTTPError:
|
|
|
|
return (RM_API_STATUS_ERROR, None, None)
|
|
|
|
|
|
|
|
if req.status != 200:
|
|
|
|
return (RM_API_STATUS_NOT_FOUND, None, None)
|
|
|
|
|
|
|
|
data = json.loads(req.data)
|
|
|
|
|
|
|
|
projects = data['projects']
|
|
|
|
projects.sort(key=lambda x: x['id'])
|
|
|
|
|
|
|
|
for p in projects:
|
|
|
|
if p['name'] == name and 'version' in p:
|
|
|
|
return (RM_API_STATUS_FOUND_BY_PATTERN, p['version'], p['id'])
|
|
|
|
|
|
|
|
return (RM_API_STATUS_NOT_FOUND, None, None)
|
|
|
|
|
|
|
|
|
2019-08-01 17:12:44 +02:00
|
|
|
def check_package_latest_version_worker(name):
|
|
|
|
"""Wrapper to try both by name then by guess"""
|
|
|
|
print(name)
|
|
|
|
res = release_monitoring_get_latest_version_by_distro(http_pool, name)
|
|
|
|
if res[0] == RM_API_STATUS_NOT_FOUND:
|
|
|
|
res = release_monitoring_get_latest_version_by_guess(http_pool, name)
|
|
|
|
return res
|
|
|
|
|
|
|
|
|
support/scripts/pkg-stats: add latest upstream version information
This commit adds fetching the latest upstream version of each package
from release-monitoring.org.
The fetching process first tries to use the package mappings of the
"Buildroot" distribution [1]. This mapping mechanism allows to tell
release-monitoring.org what is the name of a package in a given
distribution/build-system. For example, the package xutil_util-macros
in Buildroot is named xorg-util-macros on release-monitoring.org. This
mapping can be seen in the section "Mappings" of
https://release-monitoring.org/project/15037/.
If there is no mapping, then it does a regular search, and within the
search results, looks for a package whose name matches the Buildroot
name.
Even though fetching from release-monitoring.org is a bit slow, using
multiprocessing.Pool has proven to not be reliable, with some requests
ending up with an exception. So we keep a serialized approach, but
with a single HTTPSConnectionPool() for all queries. Long term, we
hope to be able to use a database dump of release-monitoring.org
instead.
From an output point of view, the latest version column:
- Is green when the version in Buildroot matches the latest upstream
version
- Is orange when the latest upstream version is unknown because the
package was not found on release-monitoring.org
- Is red when the version in Buildroot doesn't match the latest
upstream version. Note that we are not doing anything smart here:
we are just testing if the strings are equal or not.
- The cell contains the link to the project on release-monitoring.org
if found.
- The cell indicates if the match was done using a distro mapping, or
through a regular search.
[1] https://release-monitoring.org/distro/Buildroot/
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Tested-by: Matthew Weber <matthew.weber@rockwellcollins.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-02-05 16:19:59 +01:00
|
|
|
def check_package_latest_version(packages):
|
|
|
|
"""
|
|
|
|
Fills in the .latest_version field of all Package objects
|
|
|
|
|
2020-03-07 08:56:22 +01:00
|
|
|
This field is a dict and has the following keys:
|
|
|
|
|
support/scripts/pkg-stats: add latest upstream version information
This commit adds fetching the latest upstream version of each package
from release-monitoring.org.
The fetching process first tries to use the package mappings of the
"Buildroot" distribution [1]. This mapping mechanism allows to tell
release-monitoring.org what is the name of a package in a given
distribution/build-system. For example, the package xutil_util-macros
in Buildroot is named xorg-util-macros on release-monitoring.org. This
mapping can be seen in the section "Mappings" of
https://release-monitoring.org/project/15037/.
If there is no mapping, then it does a regular search, and within the
search results, looks for a package whose name matches the Buildroot
name.
Even though fetching from release-monitoring.org is a bit slow, using
multiprocessing.Pool has proven to not be reliable, with some requests
ending up with an exception. So we keep a serialized approach, but
with a single HTTPSConnectionPool() for all queries. Long term, we
hope to be able to use a database dump of release-monitoring.org
instead.
From an output point of view, the latest version column:
- Is green when the version in Buildroot matches the latest upstream
version
- Is orange when the latest upstream version is unknown because the
package was not found on release-monitoring.org
- Is red when the version in Buildroot doesn't match the latest
upstream version. Note that we are not doing anything smart here:
we are just testing if the strings are equal or not.
- The cell contains the link to the project on release-monitoring.org
if found.
- The cell indicates if the match was done using a distro mapping, or
through a regular search.
[1] https://release-monitoring.org/distro/Buildroot/
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Tested-by: Matthew Weber <matthew.weber@rockwellcollins.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-02-05 16:19:59 +01:00
|
|
|
- status: one of RM_API_STATUS_ERROR,
|
|
|
|
RM_API_STATUS_FOUND_BY_DISTRO, RM_API_STATUS_FOUND_BY_PATTERN,
|
|
|
|
RM_API_STATUS_NOT_FOUND
|
|
|
|
- version: string containing the latest version known by
|
|
|
|
release-monitoring.org for this package
|
|
|
|
- id: string containing the id of the project corresponding to this
|
|
|
|
package, as known by release-monitoring.org
|
|
|
|
"""
|
2019-08-01 17:12:44 +02:00
|
|
|
global http_pool
|
|
|
|
http_pool = HTTPSConnectionPool('release-monitoring.org', port=443,
|
|
|
|
cert_reqs='CERT_REQUIRED', ca_certs=certifi.where(),
|
|
|
|
timeout=30)
|
|
|
|
worker_pool = Pool(processes=64)
|
|
|
|
results = worker_pool.map(check_package_latest_version_worker, (pkg.name for pkg in packages))
|
|
|
|
for pkg, r in zip(packages, results):
|
2020-03-07 08:56:22 +01:00
|
|
|
pkg.latest_version = dict(zip(['status', 'version', 'id'], r))
|
2020-03-07 08:56:26 +01:00
|
|
|
|
2020-03-07 08:56:31 +01:00
|
|
|
if not pkg.has_valid_infra:
|
|
|
|
pkg.status['version'] = ("na", "no valid package infra")
|
|
|
|
continue
|
|
|
|
|
2020-03-07 08:56:26 +01:00
|
|
|
if pkg.latest_version['status'] == RM_API_STATUS_ERROR:
|
|
|
|
pkg.status['version'] = ('warning', "Release Monitoring API error")
|
|
|
|
elif pkg.latest_version['status'] == RM_API_STATUS_NOT_FOUND:
|
|
|
|
pkg.status['version'] = ('warning', "Package not found on Release Monitoring")
|
|
|
|
|
|
|
|
if pkg.latest_version['version'] is None:
|
|
|
|
pkg.status['version'] = ('warning', "No upstream version available on Release Monitoring")
|
|
|
|
elif pkg.latest_version['version'] != pkg.current_version:
|
|
|
|
pkg.status['version'] = ('error', "The newer version {} is available upstream".format(pkg.latest_version['version']))
|
|
|
|
else:
|
|
|
|
pkg.status['version'] = ('ok', 'up-to-date')
|
2020-03-01 22:25:28 +01:00
|
|
|
worker_pool.terminate()
|
2019-08-01 17:12:44 +02:00
|
|
|
del http_pool
|
support/scripts/pkg-stats: add latest upstream version information
This commit adds fetching the latest upstream version of each package
from release-monitoring.org.
The fetching process first tries to use the package mappings of the
"Buildroot" distribution [1]. This mapping mechanism allows to tell
release-monitoring.org what is the name of a package in a given
distribution/build-system. For example, the package xutil_util-macros
in Buildroot is named xorg-util-macros on release-monitoring.org. This
mapping can be seen in the section "Mappings" of
https://release-monitoring.org/project/15037/.
If there is no mapping, then it does a regular search, and within the
search results, looks for a package whose name matches the Buildroot
name.
Even though fetching from release-monitoring.org is a bit slow, using
multiprocessing.Pool has proven to not be reliable, with some requests
ending up with an exception. So we keep a serialized approach, but
with a single HTTPSConnectionPool() for all queries. Long term, we
hope to be able to use a database dump of release-monitoring.org
instead.
From an output point of view, the latest version column:
- Is green when the version in Buildroot matches the latest upstream
version
- Is orange when the latest upstream version is unknown because the
package was not found on release-monitoring.org
- Is red when the version in Buildroot doesn't match the latest
upstream version. Note that we are not doing anything smart here:
we are just testing if the strings are equal or not.
- The cell contains the link to the project on release-monitoring.org
if found.
- The cell indicates if the match was done using a distro mapping, or
through a regular search.
[1] https://release-monitoring.org/distro/Buildroot/
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Tested-by: Matthew Weber <matthew.weber@rockwellcollins.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-02-05 16:19:59 +01:00
|
|
|
|
|
|
|
|
2020-02-15 13:44:16 +01:00
|
|
|
def check_package_cves(nvd_path, packages):
|
|
|
|
if not os.path.isdir(nvd_path):
|
|
|
|
os.makedirs(nvd_path)
|
|
|
|
|
|
|
|
for cve in CVE.read_nvd_dir(nvd_path):
|
|
|
|
for pkg_name in cve.pkg_names:
|
|
|
|
if pkg_name in packages and cve.affects(packages[pkg_name]):
|
|
|
|
packages[pkg_name].cves.append(cve.identifier)
|
|
|
|
|
|
|
|
|
2018-04-04 22:05:33 +02:00
|
|
|
def calculate_stats(packages):
|
|
|
|
stats = defaultdict(int)
|
2020-03-07 08:56:27 +01:00
|
|
|
stats['packages'] = len(packages)
|
2018-04-04 22:05:33 +02:00
|
|
|
for pkg in packages:
|
|
|
|
# If packages have multiple infra, take the first one. For the
|
|
|
|
# vast majority of packages, the target and host infra are the
|
|
|
|
# same. There are very few packages that use a different infra
|
|
|
|
# for the host and target variants.
|
|
|
|
if len(pkg.infras) > 0:
|
|
|
|
infra = pkg.infras[0][1]
|
|
|
|
stats["infra-%s" % infra] += 1
|
|
|
|
else:
|
|
|
|
stats["infra-unknown"] += 1
|
2020-03-07 08:56:26 +01:00
|
|
|
if pkg.is_status_ok('license'):
|
2018-04-04 22:05:33 +02:00
|
|
|
stats["license"] += 1
|
|
|
|
else:
|
|
|
|
stats["no-license"] += 1
|
2020-03-07 08:56:26 +01:00
|
|
|
if pkg.is_status_ok('license-files'):
|
2018-04-04 22:05:33 +02:00
|
|
|
stats["license-files"] += 1
|
|
|
|
else:
|
|
|
|
stats["no-license-files"] += 1
|
2020-03-07 08:56:26 +01:00
|
|
|
if pkg.is_status_ok('hash'):
|
2018-04-04 22:05:33 +02:00
|
|
|
stats["hash"] += 1
|
|
|
|
else:
|
|
|
|
stats["no-hash"] += 1
|
2020-03-07 08:56:22 +01:00
|
|
|
if pkg.latest_version['status'] == RM_API_STATUS_FOUND_BY_DISTRO:
|
support/scripts/pkg-stats: add latest upstream version information
This commit adds fetching the latest upstream version of each package
from release-monitoring.org.
The fetching process first tries to use the package mappings of the
"Buildroot" distribution [1]. This mapping mechanism allows to tell
release-monitoring.org what is the name of a package in a given
distribution/build-system. For example, the package xutil_util-macros
in Buildroot is named xorg-util-macros on release-monitoring.org. This
mapping can be seen in the section "Mappings" of
https://release-monitoring.org/project/15037/.
If there is no mapping, then it does a regular search, and within the
search results, looks for a package whose name matches the Buildroot
name.
Even though fetching from release-monitoring.org is a bit slow, using
multiprocessing.Pool has proven to not be reliable, with some requests
ending up with an exception. So we keep a serialized approach, but
with a single HTTPSConnectionPool() for all queries. Long term, we
hope to be able to use a database dump of release-monitoring.org
instead.
From an output point of view, the latest version column:
- Is green when the version in Buildroot matches the latest upstream
version
- Is orange when the latest upstream version is unknown because the
package was not found on release-monitoring.org
- Is red when the version in Buildroot doesn't match the latest
upstream version. Note that we are not doing anything smart here:
we are just testing if the strings are equal or not.
- The cell contains the link to the project on release-monitoring.org
if found.
- The cell indicates if the match was done using a distro mapping, or
through a regular search.
[1] https://release-monitoring.org/distro/Buildroot/
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Tested-by: Matthew Weber <matthew.weber@rockwellcollins.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-02-05 16:19:59 +01:00
|
|
|
stats["rmo-mapping"] += 1
|
|
|
|
else:
|
|
|
|
stats["rmo-no-mapping"] += 1
|
2020-03-07 08:56:22 +01:00
|
|
|
if not pkg.latest_version['version']:
|
support/scripts/pkg-stats: add latest upstream version information
This commit adds fetching the latest upstream version of each package
from release-monitoring.org.
The fetching process first tries to use the package mappings of the
"Buildroot" distribution [1]. This mapping mechanism allows to tell
release-monitoring.org what is the name of a package in a given
distribution/build-system. For example, the package xutil_util-macros
in Buildroot is named xorg-util-macros on release-monitoring.org. This
mapping can be seen in the section "Mappings" of
https://release-monitoring.org/project/15037/.
If there is no mapping, then it does a regular search, and within the
search results, looks for a package whose name matches the Buildroot
name.
Even though fetching from release-monitoring.org is a bit slow, using
multiprocessing.Pool has proven to not be reliable, with some requests
ending up with an exception. So we keep a serialized approach, but
with a single HTTPSConnectionPool() for all queries. Long term, we
hope to be able to use a database dump of release-monitoring.org
instead.
From an output point of view, the latest version column:
- Is green when the version in Buildroot matches the latest upstream
version
- Is orange when the latest upstream version is unknown because the
package was not found on release-monitoring.org
- Is red when the version in Buildroot doesn't match the latest
upstream version. Note that we are not doing anything smart here:
we are just testing if the strings are equal or not.
- The cell contains the link to the project on release-monitoring.org
if found.
- The cell indicates if the match was done using a distro mapping, or
through a regular search.
[1] https://release-monitoring.org/distro/Buildroot/
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Tested-by: Matthew Weber <matthew.weber@rockwellcollins.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-02-05 16:19:59 +01:00
|
|
|
stats["version-unknown"] += 1
|
2020-03-07 08:56:22 +01:00
|
|
|
elif pkg.latest_version['version'] == pkg.current_version:
|
support/scripts/pkg-stats: add latest upstream version information
This commit adds fetching the latest upstream version of each package
from release-monitoring.org.
The fetching process first tries to use the package mappings of the
"Buildroot" distribution [1]. This mapping mechanism allows to tell
release-monitoring.org what is the name of a package in a given
distribution/build-system. For example, the package xutil_util-macros
in Buildroot is named xorg-util-macros on release-monitoring.org. This
mapping can be seen in the section "Mappings" of
https://release-monitoring.org/project/15037/.
If there is no mapping, then it does a regular search, and within the
search results, looks for a package whose name matches the Buildroot
name.
Even though fetching from release-monitoring.org is a bit slow, using
multiprocessing.Pool has proven to not be reliable, with some requests
ending up with an exception. So we keep a serialized approach, but
with a single HTTPSConnectionPool() for all queries. Long term, we
hope to be able to use a database dump of release-monitoring.org
instead.
From an output point of view, the latest version column:
- Is green when the version in Buildroot matches the latest upstream
version
- Is orange when the latest upstream version is unknown because the
package was not found on release-monitoring.org
- Is red when the version in Buildroot doesn't match the latest
upstream version. Note that we are not doing anything smart here:
we are just testing if the strings are equal or not.
- The cell contains the link to the project on release-monitoring.org
if found.
- The cell indicates if the match was done using a distro mapping, or
through a regular search.
[1] https://release-monitoring.org/distro/Buildroot/
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Tested-by: Matthew Weber <matthew.weber@rockwellcollins.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-02-05 16:19:59 +01:00
|
|
|
stats["version-uptodate"] += 1
|
|
|
|
else:
|
|
|
|
stats["version-not-uptodate"] += 1
|
2018-04-04 22:05:33 +02:00
|
|
|
stats["patches"] += pkg.patch_count
|
2020-02-15 13:44:16 +01:00
|
|
|
stats["total-cves"] += len(pkg.cves)
|
|
|
|
if len(pkg.cves) != 0:
|
|
|
|
stats["pkg-cves"] += 1
|
2018-04-04 22:05:33 +02:00
|
|
|
return stats
|
|
|
|
|
|
|
|
|
|
|
|
html_header = """
|
|
|
|
<head>
|
2017-07-06 03:36:31 +02:00
|
|
|
<script src=\"https://www.kryogenix.org/code/browser/sorttable/sorttable.js\"></script>
|
2009-10-28 00:28:40 +01:00
|
|
|
<style type=\"text/css\">
|
|
|
|
table {
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
td {
|
|
|
|
border: 1px solid black;
|
|
|
|
}
|
|
|
|
td.centered {
|
|
|
|
text-align: center;
|
|
|
|
}
|
2012-07-31 21:32:25 +02:00
|
|
|
td.wrong {
|
2010-07-26 15:15:14 +02:00
|
|
|
background: #ff9a69;
|
|
|
|
}
|
2012-07-31 21:32:25 +02:00
|
|
|
td.correct {
|
2010-07-26 15:15:14 +02:00
|
|
|
background: #d2ffc4;
|
|
|
|
}
|
2012-07-31 21:32:25 +02:00
|
|
|
td.nopatches {
|
|
|
|
background: #d2ffc4;
|
|
|
|
}
|
|
|
|
td.somepatches {
|
|
|
|
background: #ffd870;
|
|
|
|
}
|
|
|
|
td.lotsofpatches {
|
|
|
|
background: #ff9a69;
|
|
|
|
}
|
support/scripts/pkg-stats: add latest upstream version information
This commit adds fetching the latest upstream version of each package
from release-monitoring.org.
The fetching process first tries to use the package mappings of the
"Buildroot" distribution [1]. This mapping mechanism allows to tell
release-monitoring.org what is the name of a package in a given
distribution/build-system. For example, the package xutil_util-macros
in Buildroot is named xorg-util-macros on release-monitoring.org. This
mapping can be seen in the section "Mappings" of
https://release-monitoring.org/project/15037/.
If there is no mapping, then it does a regular search, and within the
search results, looks for a package whose name matches the Buildroot
name.
Even though fetching from release-monitoring.org is a bit slow, using
multiprocessing.Pool has proven to not be reliable, with some requests
ending up with an exception. So we keep a serialized approach, but
with a single HTTPSConnectionPool() for all queries. Long term, we
hope to be able to use a database dump of release-monitoring.org
instead.
From an output point of view, the latest version column:
- Is green when the version in Buildroot matches the latest upstream
version
- Is orange when the latest upstream version is unknown because the
package was not found on release-monitoring.org
- Is red when the version in Buildroot doesn't match the latest
upstream version. Note that we are not doing anything smart here:
we are just testing if the strings are equal or not.
- The cell contains the link to the project on release-monitoring.org
if found.
- The cell indicates if the match was done using a distro mapping, or
through a regular search.
[1] https://release-monitoring.org/distro/Buildroot/
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Tested-by: Matthew Weber <matthew.weber@rockwellcollins.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-02-05 16:19:59 +01:00
|
|
|
|
2018-10-02 04:37:28 +02:00
|
|
|
td.good_url {
|
|
|
|
background: #d2ffc4;
|
|
|
|
}
|
|
|
|
td.missing_url {
|
|
|
|
background: #ffd870;
|
|
|
|
}
|
|
|
|
td.invalid_url {
|
|
|
|
background: #ff9a69;
|
|
|
|
}
|
support/scripts/pkg-stats: add latest upstream version information
This commit adds fetching the latest upstream version of each package
from release-monitoring.org.
The fetching process first tries to use the package mappings of the
"Buildroot" distribution [1]. This mapping mechanism allows to tell
release-monitoring.org what is the name of a package in a given
distribution/build-system. For example, the package xutil_util-macros
in Buildroot is named xorg-util-macros on release-monitoring.org. This
mapping can be seen in the section "Mappings" of
https://release-monitoring.org/project/15037/.
If there is no mapping, then it does a regular search, and within the
search results, looks for a package whose name matches the Buildroot
name.
Even though fetching from release-monitoring.org is a bit slow, using
multiprocessing.Pool has proven to not be reliable, with some requests
ending up with an exception. So we keep a serialized approach, but
with a single HTTPSConnectionPool() for all queries. Long term, we
hope to be able to use a database dump of release-monitoring.org
instead.
From an output point of view, the latest version column:
- Is green when the version in Buildroot matches the latest upstream
version
- Is orange when the latest upstream version is unknown because the
package was not found on release-monitoring.org
- Is red when the version in Buildroot doesn't match the latest
upstream version. Note that we are not doing anything smart here:
we are just testing if the strings are equal or not.
- The cell contains the link to the project on release-monitoring.org
if found.
- The cell indicates if the match was done using a distro mapping, or
through a regular search.
[1] https://release-monitoring.org/distro/Buildroot/
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Tested-by: Matthew Weber <matthew.weber@rockwellcollins.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-02-05 16:19:59 +01:00
|
|
|
|
|
|
|
td.version-good {
|
|
|
|
background: #d2ffc4;
|
|
|
|
}
|
|
|
|
td.version-needs-update {
|
|
|
|
background: #ff9a69;
|
|
|
|
}
|
|
|
|
td.version-unknown {
|
|
|
|
background: #ffd870;
|
|
|
|
}
|
|
|
|
td.version-error {
|
|
|
|
background: #ccc;
|
|
|
|
}
|
|
|
|
|
2009-10-28 00:28:40 +01:00
|
|
|
</style>
|
2012-07-31 21:32:25 +02:00
|
|
|
<title>Statistics of Buildroot packages</title>
|
2009-10-28 00:28:40 +01:00
|
|
|
</head>
|
|
|
|
|
|
|
|
<a href=\"#results\">Results</a><br/>
|
|
|
|
|
2017-07-06 03:36:31 +02:00
|
|
|
<p id=\"sortable_hint\"></p>
|
2018-04-04 22:05:33 +02:00
|
|
|
"""
|
|
|
|
|
2017-07-06 03:36:31 +02:00
|
|
|
|
2018-04-04 22:05:33 +02:00
|
|
|
html_footer = """
|
|
|
|
</body>
|
|
|
|
<script>
|
|
|
|
if (typeof sorttable === \"object\") {
|
|
|
|
document.getElementById(\"sortable_hint\").innerHTML =
|
|
|
|
\"hint: the table can be sorted by clicking the column headers\"
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</html>
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
def infra_str(infra_list):
|
|
|
|
if not infra_list:
|
|
|
|
return "Unknown"
|
|
|
|
elif len(infra_list) == 1:
|
|
|
|
return "<b>%s</b><br/>%s" % (infra_list[0][1], infra_list[0][0])
|
|
|
|
elif infra_list[0][1] == infra_list[1][1]:
|
|
|
|
return "<b>%s</b><br/>%s + %s" % \
|
|
|
|
(infra_list[0][1], infra_list[0][0], infra_list[1][0])
|
|
|
|
else:
|
|
|
|
return "<b>%s</b> (%s)<br/><b>%s</b> (%s)" % \
|
|
|
|
(infra_list[0][1], infra_list[0][0],
|
|
|
|
infra_list[1][1], infra_list[1][0])
|
|
|
|
|
|
|
|
|
|
|
|
def boolean_str(b):
|
|
|
|
if b:
|
|
|
|
return "Yes"
|
|
|
|
else:
|
|
|
|
return "No"
|
|
|
|
|
|
|
|
|
|
|
|
def dump_html_pkg(f, pkg):
|
|
|
|
f.write(" <tr>\n")
|
|
|
|
f.write(" <td>%s</td>\n" % pkg.path[2:])
|
|
|
|
|
|
|
|
# Patch count
|
|
|
|
td_class = ["centered"]
|
|
|
|
if pkg.patch_count == 0:
|
|
|
|
td_class.append("nopatches")
|
|
|
|
elif pkg.patch_count < 5:
|
|
|
|
td_class.append("somepatches")
|
|
|
|
else:
|
|
|
|
td_class.append("lotsofpatches")
|
|
|
|
f.write(" <td class=\"%s\">%s</td>\n" %
|
|
|
|
(" ".join(td_class), str(pkg.patch_count)))
|
|
|
|
|
|
|
|
# Infrastructure
|
|
|
|
infra = infra_str(pkg.infras)
|
|
|
|
td_class = ["centered"]
|
|
|
|
if infra == "Unknown":
|
|
|
|
td_class.append("wrong")
|
|
|
|
else:
|
|
|
|
td_class.append("correct")
|
|
|
|
f.write(" <td class=\"%s\">%s</td>\n" %
|
|
|
|
(" ".join(td_class), infra_str(pkg.infras)))
|
|
|
|
|
|
|
|
# License
|
|
|
|
td_class = ["centered"]
|
2020-03-07 08:56:26 +01:00
|
|
|
if pkg.is_status_ok('license'):
|
2018-04-04 22:05:33 +02:00
|
|
|
td_class.append("correct")
|
|
|
|
else:
|
|
|
|
td_class.append("wrong")
|
|
|
|
f.write(" <td class=\"%s\">%s</td>\n" %
|
2020-03-07 08:56:26 +01:00
|
|
|
(" ".join(td_class), boolean_str(pkg.is_status_ok('license'))))
|
2018-04-04 22:05:33 +02:00
|
|
|
|
|
|
|
# License files
|
|
|
|
td_class = ["centered"]
|
2020-03-07 08:56:26 +01:00
|
|
|
if pkg.is_status_ok('license-files'):
|
2018-04-04 22:05:33 +02:00
|
|
|
td_class.append("correct")
|
|
|
|
else:
|
|
|
|
td_class.append("wrong")
|
|
|
|
f.write(" <td class=\"%s\">%s</td>\n" %
|
2020-03-07 08:56:26 +01:00
|
|
|
(" ".join(td_class), boolean_str(pkg.is_status_ok('license-files'))))
|
2018-04-04 22:05:33 +02:00
|
|
|
|
|
|
|
# Hash
|
|
|
|
td_class = ["centered"]
|
2020-03-07 08:56:26 +01:00
|
|
|
if pkg.is_status_ok('hash'):
|
2018-04-04 22:05:33 +02:00
|
|
|
td_class.append("correct")
|
|
|
|
else:
|
|
|
|
td_class.append("wrong")
|
|
|
|
f.write(" <td class=\"%s\">%s</td>\n" %
|
2020-03-07 08:56:26 +01:00
|
|
|
(" ".join(td_class), boolean_str(pkg.is_status_ok('hash'))))
|
2018-04-04 22:05:33 +02:00
|
|
|
|
|
|
|
# Current version
|
|
|
|
if len(pkg.current_version) > 20:
|
|
|
|
current_version = pkg.current_version[:20] + "..."
|
|
|
|
else:
|
|
|
|
current_version = pkg.current_version
|
|
|
|
f.write(" <td class=\"centered\">%s</td>\n" % current_version)
|
|
|
|
|
support/scripts/pkg-stats: add latest upstream version information
This commit adds fetching the latest upstream version of each package
from release-monitoring.org.
The fetching process first tries to use the package mappings of the
"Buildroot" distribution [1]. This mapping mechanism allows to tell
release-monitoring.org what is the name of a package in a given
distribution/build-system. For example, the package xutil_util-macros
in Buildroot is named xorg-util-macros on release-monitoring.org. This
mapping can be seen in the section "Mappings" of
https://release-monitoring.org/project/15037/.
If there is no mapping, then it does a regular search, and within the
search results, looks for a package whose name matches the Buildroot
name.
Even though fetching from release-monitoring.org is a bit slow, using
multiprocessing.Pool has proven to not be reliable, with some requests
ending up with an exception. So we keep a serialized approach, but
with a single HTTPSConnectionPool() for all queries. Long term, we
hope to be able to use a database dump of release-monitoring.org
instead.
From an output point of view, the latest version column:
- Is green when the version in Buildroot matches the latest upstream
version
- Is orange when the latest upstream version is unknown because the
package was not found on release-monitoring.org
- Is red when the version in Buildroot doesn't match the latest
upstream version. Note that we are not doing anything smart here:
we are just testing if the strings are equal or not.
- The cell contains the link to the project on release-monitoring.org
if found.
- The cell indicates if the match was done using a distro mapping, or
through a regular search.
[1] https://release-monitoring.org/distro/Buildroot/
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Tested-by: Matthew Weber <matthew.weber@rockwellcollins.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-02-05 16:19:59 +01:00
|
|
|
# Latest version
|
2020-03-07 08:56:22 +01:00
|
|
|
if pkg.latest_version['status'] == RM_API_STATUS_ERROR:
|
support/scripts/pkg-stats: add latest upstream version information
This commit adds fetching the latest upstream version of each package
from release-monitoring.org.
The fetching process first tries to use the package mappings of the
"Buildroot" distribution [1]. This mapping mechanism allows to tell
release-monitoring.org what is the name of a package in a given
distribution/build-system. For example, the package xutil_util-macros
in Buildroot is named xorg-util-macros on release-monitoring.org. This
mapping can be seen in the section "Mappings" of
https://release-monitoring.org/project/15037/.
If there is no mapping, then it does a regular search, and within the
search results, looks for a package whose name matches the Buildroot
name.
Even though fetching from release-monitoring.org is a bit slow, using
multiprocessing.Pool has proven to not be reliable, with some requests
ending up with an exception. So we keep a serialized approach, but
with a single HTTPSConnectionPool() for all queries. Long term, we
hope to be able to use a database dump of release-monitoring.org
instead.
From an output point of view, the latest version column:
- Is green when the version in Buildroot matches the latest upstream
version
- Is orange when the latest upstream version is unknown because the
package was not found on release-monitoring.org
- Is red when the version in Buildroot doesn't match the latest
upstream version. Note that we are not doing anything smart here:
we are just testing if the strings are equal or not.
- The cell contains the link to the project on release-monitoring.org
if found.
- The cell indicates if the match was done using a distro mapping, or
through a regular search.
[1] https://release-monitoring.org/distro/Buildroot/
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Tested-by: Matthew Weber <matthew.weber@rockwellcollins.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-02-05 16:19:59 +01:00
|
|
|
td_class.append("version-error")
|
2020-03-07 08:56:22 +01:00
|
|
|
if pkg.latest_version['version'] is None:
|
support/scripts/pkg-stats: add latest upstream version information
This commit adds fetching the latest upstream version of each package
from release-monitoring.org.
The fetching process first tries to use the package mappings of the
"Buildroot" distribution [1]. This mapping mechanism allows to tell
release-monitoring.org what is the name of a package in a given
distribution/build-system. For example, the package xutil_util-macros
in Buildroot is named xorg-util-macros on release-monitoring.org. This
mapping can be seen in the section "Mappings" of
https://release-monitoring.org/project/15037/.
If there is no mapping, then it does a regular search, and within the
search results, looks for a package whose name matches the Buildroot
name.
Even though fetching from release-monitoring.org is a bit slow, using
multiprocessing.Pool has proven to not be reliable, with some requests
ending up with an exception. So we keep a serialized approach, but
with a single HTTPSConnectionPool() for all queries. Long term, we
hope to be able to use a database dump of release-monitoring.org
instead.
From an output point of view, the latest version column:
- Is green when the version in Buildroot matches the latest upstream
version
- Is orange when the latest upstream version is unknown because the
package was not found on release-monitoring.org
- Is red when the version in Buildroot doesn't match the latest
upstream version. Note that we are not doing anything smart here:
we are just testing if the strings are equal or not.
- The cell contains the link to the project on release-monitoring.org
if found.
- The cell indicates if the match was done using a distro mapping, or
through a regular search.
[1] https://release-monitoring.org/distro/Buildroot/
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Tested-by: Matthew Weber <matthew.weber@rockwellcollins.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-02-05 16:19:59 +01:00
|
|
|
td_class.append("version-unknown")
|
2020-03-07 08:56:22 +01:00
|
|
|
elif pkg.latest_version['version'] != pkg.current_version:
|
support/scripts/pkg-stats: add latest upstream version information
This commit adds fetching the latest upstream version of each package
from release-monitoring.org.
The fetching process first tries to use the package mappings of the
"Buildroot" distribution [1]. This mapping mechanism allows to tell
release-monitoring.org what is the name of a package in a given
distribution/build-system. For example, the package xutil_util-macros
in Buildroot is named xorg-util-macros on release-monitoring.org. This
mapping can be seen in the section "Mappings" of
https://release-monitoring.org/project/15037/.
If there is no mapping, then it does a regular search, and within the
search results, looks for a package whose name matches the Buildroot
name.
Even though fetching from release-monitoring.org is a bit slow, using
multiprocessing.Pool has proven to not be reliable, with some requests
ending up with an exception. So we keep a serialized approach, but
with a single HTTPSConnectionPool() for all queries. Long term, we
hope to be able to use a database dump of release-monitoring.org
instead.
From an output point of view, the latest version column:
- Is green when the version in Buildroot matches the latest upstream
version
- Is orange when the latest upstream version is unknown because the
package was not found on release-monitoring.org
- Is red when the version in Buildroot doesn't match the latest
upstream version. Note that we are not doing anything smart here:
we are just testing if the strings are equal or not.
- The cell contains the link to the project on release-monitoring.org
if found.
- The cell indicates if the match was done using a distro mapping, or
through a regular search.
[1] https://release-monitoring.org/distro/Buildroot/
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Tested-by: Matthew Weber <matthew.weber@rockwellcollins.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-02-05 16:19:59 +01:00
|
|
|
td_class.append("version-needs-update")
|
|
|
|
else:
|
|
|
|
td_class.append("version-good")
|
|
|
|
|
2020-03-07 08:56:22 +01:00
|
|
|
if pkg.latest_version['status'] == RM_API_STATUS_ERROR:
|
support/scripts/pkg-stats: add latest upstream version information
This commit adds fetching the latest upstream version of each package
from release-monitoring.org.
The fetching process first tries to use the package mappings of the
"Buildroot" distribution [1]. This mapping mechanism allows to tell
release-monitoring.org what is the name of a package in a given
distribution/build-system. For example, the package xutil_util-macros
in Buildroot is named xorg-util-macros on release-monitoring.org. This
mapping can be seen in the section "Mappings" of
https://release-monitoring.org/project/15037/.
If there is no mapping, then it does a regular search, and within the
search results, looks for a package whose name matches the Buildroot
name.
Even though fetching from release-monitoring.org is a bit slow, using
multiprocessing.Pool has proven to not be reliable, with some requests
ending up with an exception. So we keep a serialized approach, but
with a single HTTPSConnectionPool() for all queries. Long term, we
hope to be able to use a database dump of release-monitoring.org
instead.
From an output point of view, the latest version column:
- Is green when the version in Buildroot matches the latest upstream
version
- Is orange when the latest upstream version is unknown because the
package was not found on release-monitoring.org
- Is red when the version in Buildroot doesn't match the latest
upstream version. Note that we are not doing anything smart here:
we are just testing if the strings are equal or not.
- The cell contains the link to the project on release-monitoring.org
if found.
- The cell indicates if the match was done using a distro mapping, or
through a regular search.
[1] https://release-monitoring.org/distro/Buildroot/
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Tested-by: Matthew Weber <matthew.weber@rockwellcollins.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-02-05 16:19:59 +01:00
|
|
|
latest_version_text = "<b>Error</b>"
|
2020-03-07 08:56:22 +01:00
|
|
|
elif pkg.latest_version['status'] == RM_API_STATUS_NOT_FOUND:
|
support/scripts/pkg-stats: add latest upstream version information
This commit adds fetching the latest upstream version of each package
from release-monitoring.org.
The fetching process first tries to use the package mappings of the
"Buildroot" distribution [1]. This mapping mechanism allows to tell
release-monitoring.org what is the name of a package in a given
distribution/build-system. For example, the package xutil_util-macros
in Buildroot is named xorg-util-macros on release-monitoring.org. This
mapping can be seen in the section "Mappings" of
https://release-monitoring.org/project/15037/.
If there is no mapping, then it does a regular search, and within the
search results, looks for a package whose name matches the Buildroot
name.
Even though fetching from release-monitoring.org is a bit slow, using
multiprocessing.Pool has proven to not be reliable, with some requests
ending up with an exception. So we keep a serialized approach, but
with a single HTTPSConnectionPool() for all queries. Long term, we
hope to be able to use a database dump of release-monitoring.org
instead.
From an output point of view, the latest version column:
- Is green when the version in Buildroot matches the latest upstream
version
- Is orange when the latest upstream version is unknown because the
package was not found on release-monitoring.org
- Is red when the version in Buildroot doesn't match the latest
upstream version. Note that we are not doing anything smart here:
we are just testing if the strings are equal or not.
- The cell contains the link to the project on release-monitoring.org
if found.
- The cell indicates if the match was done using a distro mapping, or
through a regular search.
[1] https://release-monitoring.org/distro/Buildroot/
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Tested-by: Matthew Weber <matthew.weber@rockwellcollins.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-02-05 16:19:59 +01:00
|
|
|
latest_version_text = "<b>Not found</b>"
|
|
|
|
else:
|
2020-03-07 08:56:22 +01:00
|
|
|
if pkg.latest_version['version'] is None:
|
support/scripts/pkg-stats: add latest upstream version information
This commit adds fetching the latest upstream version of each package
from release-monitoring.org.
The fetching process first tries to use the package mappings of the
"Buildroot" distribution [1]. This mapping mechanism allows to tell
release-monitoring.org what is the name of a package in a given
distribution/build-system. For example, the package xutil_util-macros
in Buildroot is named xorg-util-macros on release-monitoring.org. This
mapping can be seen in the section "Mappings" of
https://release-monitoring.org/project/15037/.
If there is no mapping, then it does a regular search, and within the
search results, looks for a package whose name matches the Buildroot
name.
Even though fetching from release-monitoring.org is a bit slow, using
multiprocessing.Pool has proven to not be reliable, with some requests
ending up with an exception. So we keep a serialized approach, but
with a single HTTPSConnectionPool() for all queries. Long term, we
hope to be able to use a database dump of release-monitoring.org
instead.
From an output point of view, the latest version column:
- Is green when the version in Buildroot matches the latest upstream
version
- Is orange when the latest upstream version is unknown because the
package was not found on release-monitoring.org
- Is red when the version in Buildroot doesn't match the latest
upstream version. Note that we are not doing anything smart here:
we are just testing if the strings are equal or not.
- The cell contains the link to the project on release-monitoring.org
if found.
- The cell indicates if the match was done using a distro mapping, or
through a regular search.
[1] https://release-monitoring.org/distro/Buildroot/
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Tested-by: Matthew Weber <matthew.weber@rockwellcollins.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-02-05 16:19:59 +01:00
|
|
|
latest_version_text = "<b>Found, but no version</b>"
|
|
|
|
else:
|
2019-02-07 22:04:26 +01:00
|
|
|
latest_version_text = "<a href=\"https://release-monitoring.org/project/%s\"><b>%s</b></a>" % \
|
2020-03-07 08:56:22 +01:00
|
|
|
(pkg.latest_version['id'], str(pkg.latest_version['version']))
|
support/scripts/pkg-stats: add latest upstream version information
This commit adds fetching the latest upstream version of each package
from release-monitoring.org.
The fetching process first tries to use the package mappings of the
"Buildroot" distribution [1]. This mapping mechanism allows to tell
release-monitoring.org what is the name of a package in a given
distribution/build-system. For example, the package xutil_util-macros
in Buildroot is named xorg-util-macros on release-monitoring.org. This
mapping can be seen in the section "Mappings" of
https://release-monitoring.org/project/15037/.
If there is no mapping, then it does a regular search, and within the
search results, looks for a package whose name matches the Buildroot
name.
Even though fetching from release-monitoring.org is a bit slow, using
multiprocessing.Pool has proven to not be reliable, with some requests
ending up with an exception. So we keep a serialized approach, but
with a single HTTPSConnectionPool() for all queries. Long term, we
hope to be able to use a database dump of release-monitoring.org
instead.
From an output point of view, the latest version column:
- Is green when the version in Buildroot matches the latest upstream
version
- Is orange when the latest upstream version is unknown because the
package was not found on release-monitoring.org
- Is red when the version in Buildroot doesn't match the latest
upstream version. Note that we are not doing anything smart here:
we are just testing if the strings are equal or not.
- The cell contains the link to the project on release-monitoring.org
if found.
- The cell indicates if the match was done using a distro mapping, or
through a regular search.
[1] https://release-monitoring.org/distro/Buildroot/
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Tested-by: Matthew Weber <matthew.weber@rockwellcollins.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-02-05 16:19:59 +01:00
|
|
|
|
|
|
|
latest_version_text += "<br/>"
|
|
|
|
|
2020-03-07 08:56:22 +01:00
|
|
|
if pkg.latest_version['status'] == RM_API_STATUS_FOUND_BY_DISTRO:
|
support/scripts/pkg-stats: add latest upstream version information
This commit adds fetching the latest upstream version of each package
from release-monitoring.org.
The fetching process first tries to use the package mappings of the
"Buildroot" distribution [1]. This mapping mechanism allows to tell
release-monitoring.org what is the name of a package in a given
distribution/build-system. For example, the package xutil_util-macros
in Buildroot is named xorg-util-macros on release-monitoring.org. This
mapping can be seen in the section "Mappings" of
https://release-monitoring.org/project/15037/.
If there is no mapping, then it does a regular search, and within the
search results, looks for a package whose name matches the Buildroot
name.
Even though fetching from release-monitoring.org is a bit slow, using
multiprocessing.Pool has proven to not be reliable, with some requests
ending up with an exception. So we keep a serialized approach, but
with a single HTTPSConnectionPool() for all queries. Long term, we
hope to be able to use a database dump of release-monitoring.org
instead.
From an output point of view, the latest version column:
- Is green when the version in Buildroot matches the latest upstream
version
- Is orange when the latest upstream version is unknown because the
package was not found on release-monitoring.org
- Is red when the version in Buildroot doesn't match the latest
upstream version. Note that we are not doing anything smart here:
we are just testing if the strings are equal or not.
- The cell contains the link to the project on release-monitoring.org
if found.
- The cell indicates if the match was done using a distro mapping, or
through a regular search.
[1] https://release-monitoring.org/distro/Buildroot/
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Tested-by: Matthew Weber <matthew.weber@rockwellcollins.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-02-05 16:19:59 +01:00
|
|
|
latest_version_text += "found by <a href=\"https://release-monitoring.org/distro/Buildroot/\">distro</a>"
|
|
|
|
else:
|
|
|
|
latest_version_text += "found by guess"
|
|
|
|
|
|
|
|
f.write(" <td class=\"%s\">%s</td>\n" %
|
|
|
|
(" ".join(td_class), latest_version_text))
|
|
|
|
|
2018-04-04 22:05:33 +02:00
|
|
|
# Warnings
|
|
|
|
td_class = ["centered"]
|
|
|
|
if pkg.warnings == 0:
|
|
|
|
td_class.append("correct")
|
|
|
|
else:
|
|
|
|
td_class.append("wrong")
|
|
|
|
f.write(" <td class=\"%s\">%d</td>\n" %
|
|
|
|
(" ".join(td_class), pkg.warnings))
|
|
|
|
|
2018-10-02 04:37:28 +02:00
|
|
|
# URL status
|
|
|
|
td_class = ["centered"]
|
2020-03-07 08:56:26 +01:00
|
|
|
url_str = pkg.status['url'][1]
|
|
|
|
if pkg.status['url'][0] in ("error", "warning"):
|
2018-10-02 04:37:28 +02:00
|
|
|
td_class.append("missing_url")
|
2020-03-07 08:56:26 +01:00
|
|
|
if pkg.status['url'][0] == "error":
|
2018-10-02 04:37:28 +02:00
|
|
|
td_class.append("invalid_url")
|
2020-03-07 08:56:26 +01:00
|
|
|
url_str = "<a href=%s>%s</a>" % (pkg.url, pkg.status['url'][1])
|
2018-10-02 04:37:28 +02:00
|
|
|
else:
|
|
|
|
td_class.append("good_url")
|
|
|
|
url_str = "<a href=%s>Link</a>" % pkg.url
|
|
|
|
f.write(" <td class=\"%s\">%s</td>\n" %
|
|
|
|
(" ".join(td_class), url_str))
|
|
|
|
|
2020-02-15 13:44:16 +01:00
|
|
|
# CVEs
|
|
|
|
td_class = ["centered"]
|
|
|
|
if len(pkg.cves) == 0:
|
|
|
|
td_class.append("correct")
|
|
|
|
else:
|
|
|
|
td_class.append("wrong")
|
|
|
|
f.write(" <td class=\"%s\">\n" % " ".join(td_class))
|
|
|
|
for cve in pkg.cves:
|
|
|
|
f.write(" <a href=\"https://security-tracker.debian.org/tracker/%s\">%s<br/>\n" % (cve, cve))
|
|
|
|
f.write(" </td>\n")
|
|
|
|
|
2018-04-04 22:05:33 +02:00
|
|
|
f.write(" </tr>\n")
|
|
|
|
|
|
|
|
|
|
|
|
def dump_html_all_pkgs(f, packages):
|
|
|
|
f.write("""
|
2017-07-06 03:36:31 +02:00
|
|
|
<table class=\"sortable\">
|
2009-10-28 00:28:40 +01:00
|
|
|
<tr>
|
2012-07-31 21:32:25 +02:00
|
|
|
<td>Package</td>
|
|
|
|
<td class=\"centered\">Patch count</td>
|
|
|
|
<td class=\"centered\">Infrastructure</td>
|
|
|
|
<td class=\"centered\">License</td>
|
2012-08-05 11:50:10 +02:00
|
|
|
<td class=\"centered\">License files</td>
|
2014-10-17 15:34:12 +02:00
|
|
|
<td class=\"centered\">Hash file</td>
|
2018-04-04 22:05:33 +02:00
|
|
|
<td class=\"centered\">Current version</td>
|
support/scripts/pkg-stats: add latest upstream version information
This commit adds fetching the latest upstream version of each package
from release-monitoring.org.
The fetching process first tries to use the package mappings of the
"Buildroot" distribution [1]. This mapping mechanism allows to tell
release-monitoring.org what is the name of a package in a given
distribution/build-system. For example, the package xutil_util-macros
in Buildroot is named xorg-util-macros on release-monitoring.org. This
mapping can be seen in the section "Mappings" of
https://release-monitoring.org/project/15037/.
If there is no mapping, then it does a regular search, and within the
search results, looks for a package whose name matches the Buildroot
name.
Even though fetching from release-monitoring.org is a bit slow, using
multiprocessing.Pool has proven to not be reliable, with some requests
ending up with an exception. So we keep a serialized approach, but
with a single HTTPSConnectionPool() for all queries. Long term, we
hope to be able to use a database dump of release-monitoring.org
instead.
From an output point of view, the latest version column:
- Is green when the version in Buildroot matches the latest upstream
version
- Is orange when the latest upstream version is unknown because the
package was not found on release-monitoring.org
- Is red when the version in Buildroot doesn't match the latest
upstream version. Note that we are not doing anything smart here:
we are just testing if the strings are equal or not.
- The cell contains the link to the project on release-monitoring.org
if found.
- The cell indicates if the match was done using a distro mapping, or
through a regular search.
[1] https://release-monitoring.org/distro/Buildroot/
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Tested-by: Matthew Weber <matthew.weber@rockwellcollins.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-02-05 16:19:59 +01:00
|
|
|
<td class=\"centered\">Latest version</td>
|
2017-04-08 21:35:33 +02:00
|
|
|
<td class=\"centered\">Warnings</td>
|
2018-10-02 04:37:28 +02:00
|
|
|
<td class=\"centered\">Upstream URL</td>
|
2020-02-15 13:44:16 +01:00
|
|
|
<td class=\"centered\">CVEs</td>
|
2009-10-28 00:28:40 +01:00
|
|
|
</tr>
|
2018-04-04 22:05:33 +02:00
|
|
|
""")
|
|
|
|
for pkg in sorted(packages):
|
|
|
|
dump_html_pkg(f, pkg)
|
|
|
|
f.write("</table>")
|
|
|
|
|
|
|
|
|
|
|
|
def dump_html_stats(f, stats):
|
|
|
|
f.write("<a id=\"results\"></a>\n")
|
|
|
|
f.write("<table>\n")
|
|
|
|
infras = [infra[6:] for infra in stats.keys() if infra.startswith("infra-")]
|
|
|
|
for infra in infras:
|
|
|
|
f.write(" <tr><td>Packages using the <i>%s</i> infrastructure</td><td>%s</td></tr>\n" %
|
|
|
|
(infra, stats["infra-%s" % infra]))
|
|
|
|
f.write(" <tr><td>Packages having license information</td><td>%s</td></tr>\n" %
|
|
|
|
stats["license"])
|
|
|
|
f.write(" <tr><td>Packages not having license information</td><td>%s</td></tr>\n" %
|
|
|
|
stats["no-license"])
|
|
|
|
f.write(" <tr><td>Packages having license files information</td><td>%s</td></tr>\n" %
|
|
|
|
stats["license-files"])
|
|
|
|
f.write(" <tr><td>Packages not having license files information</td><td>%s</td></tr>\n" %
|
|
|
|
stats["no-license-files"])
|
|
|
|
f.write(" <tr><td>Packages having a hash file</td><td>%s</td></tr>\n" %
|
|
|
|
stats["hash"])
|
|
|
|
f.write(" <tr><td>Packages not having a hash file</td><td>%s</td></tr>\n" %
|
|
|
|
stats["no-hash"])
|
|
|
|
f.write(" <tr><td>Total number of patches</td><td>%s</td></tr>\n" %
|
|
|
|
stats["patches"])
|
support/scripts/pkg-stats: add latest upstream version information
This commit adds fetching the latest upstream version of each package
from release-monitoring.org.
The fetching process first tries to use the package mappings of the
"Buildroot" distribution [1]. This mapping mechanism allows to tell
release-monitoring.org what is the name of a package in a given
distribution/build-system. For example, the package xutil_util-macros
in Buildroot is named xorg-util-macros on release-monitoring.org. This
mapping can be seen in the section "Mappings" of
https://release-monitoring.org/project/15037/.
If there is no mapping, then it does a regular search, and within the
search results, looks for a package whose name matches the Buildroot
name.
Even though fetching from release-monitoring.org is a bit slow, using
multiprocessing.Pool has proven to not be reliable, with some requests
ending up with an exception. So we keep a serialized approach, but
with a single HTTPSConnectionPool() for all queries. Long term, we
hope to be able to use a database dump of release-monitoring.org
instead.
From an output point of view, the latest version column:
- Is green when the version in Buildroot matches the latest upstream
version
- Is orange when the latest upstream version is unknown because the
package was not found on release-monitoring.org
- Is red when the version in Buildroot doesn't match the latest
upstream version. Note that we are not doing anything smart here:
we are just testing if the strings are equal or not.
- The cell contains the link to the project on release-monitoring.org
if found.
- The cell indicates if the match was done using a distro mapping, or
through a regular search.
[1] https://release-monitoring.org/distro/Buildroot/
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Tested-by: Matthew Weber <matthew.weber@rockwellcollins.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-02-05 16:19:59 +01:00
|
|
|
f.write("<tr><td>Packages having a mapping on <i>release-monitoring.org</i></td><td>%s</td></tr>\n" %
|
|
|
|
stats["rmo-mapping"])
|
|
|
|
f.write("<tr><td>Packages lacking a mapping on <i>release-monitoring.org</i></td><td>%s</td></tr>\n" %
|
|
|
|
stats["rmo-no-mapping"])
|
|
|
|
f.write("<tr><td>Packages that are up-to-date</td><td>%s</td></tr>\n" %
|
|
|
|
stats["version-uptodate"])
|
|
|
|
f.write("<tr><td>Packages that are not up-to-date</td><td>%s</td></tr>\n" %
|
|
|
|
stats["version-not-uptodate"])
|
|
|
|
f.write("<tr><td>Packages with no known upstream version</td><td>%s</td></tr>\n" %
|
|
|
|
stats["version-unknown"])
|
2020-02-15 13:44:16 +01:00
|
|
|
f.write("<tr><td>Packages affected by CVEs</td><td>%s</td></tr>\n" %
|
|
|
|
stats["pkg-cves"])
|
|
|
|
f.write("<tr><td>Total number of CVEs affecting all packages</td><td>%s</td></tr>\n" %
|
|
|
|
stats["total-cves"])
|
2018-04-04 22:05:33 +02:00
|
|
|
f.write("</table>\n")
|
|
|
|
|
|
|
|
|
2019-08-01 11:07:27 +02:00
|
|
|
def dump_html_gen_info(f, date, commit):
|
2018-04-04 22:05:33 +02:00
|
|
|
# Updated on Mon Feb 19 08:12:08 CET 2018, Git commit aa77030b8f5e41f1c53eb1c1ad664b8c814ba032
|
2019-07-19 15:06:30 +02:00
|
|
|
f.write("<p><i>Updated on %s, git commit %s</i></p>\n" % (str(date), commit))
|
2018-04-04 22:05:33 +02:00
|
|
|
|
|
|
|
|
2019-07-19 15:06:30 +02:00
|
|
|
def dump_html(packages, stats, date, commit, output):
|
2018-04-04 22:05:33 +02:00
|
|
|
with open(output, 'w') as f:
|
|
|
|
f.write(html_header)
|
|
|
|
dump_html_all_pkgs(f, packages)
|
|
|
|
dump_html_stats(f, stats)
|
2019-08-01 11:07:27 +02:00
|
|
|
dump_html_gen_info(f, date, commit)
|
2018-04-04 22:05:33 +02:00
|
|
|
f.write(html_footer)
|
|
|
|
|
|
|
|
|
2020-03-07 08:56:29 +01:00
|
|
|
def dump_json(packages, defconfigs, stats, date, commit, output):
|
2019-07-19 15:06:29 +02:00
|
|
|
# Format packages as a dictionnary instead of a list
|
|
|
|
# Exclude local field that does not contains real date
|
|
|
|
excluded_fields = ['url_worker', 'name']
|
|
|
|
pkgs = {
|
|
|
|
pkg.name: {
|
|
|
|
k: v
|
|
|
|
for k, v in pkg.__dict__.items()
|
|
|
|
if k not in excluded_fields
|
|
|
|
} for pkg in packages
|
|
|
|
}
|
2020-03-07 08:56:29 +01:00
|
|
|
defconfigs = {
|
|
|
|
d.name: {
|
|
|
|
k: v
|
|
|
|
for k, v in d.__dict__.items()
|
|
|
|
} for d in defconfigs
|
|
|
|
}
|
2019-07-19 15:06:29 +02:00
|
|
|
# Aggregate infrastructures into a single dict entry
|
|
|
|
statistics = {
|
|
|
|
k: v
|
|
|
|
for k, v in stats.items()
|
|
|
|
if not k.startswith('infra-')
|
|
|
|
}
|
|
|
|
statistics['infra'] = {k[6:]: v for k, v in stats.items() if k.startswith('infra-')}
|
|
|
|
# The actual structure to dump, add commit and date to it
|
|
|
|
final = {'packages': pkgs,
|
|
|
|
'stats': statistics,
|
2020-03-07 08:56:29 +01:00
|
|
|
'defconfigs': defconfigs,
|
2020-03-07 08:56:32 +01:00
|
|
|
'package_status_checks': Package.status_checks,
|
2019-07-19 15:06:30 +02:00
|
|
|
'commit': commit,
|
|
|
|
'date': str(date)}
|
2019-07-19 15:06:29 +02:00
|
|
|
|
|
|
|
with open(output, 'w') as f:
|
|
|
|
json.dump(final, f, indent=2, separators=(',', ': '))
|
|
|
|
f.write('\n')
|
|
|
|
|
|
|
|
|
2018-04-04 22:05:33 +02:00
|
|
|
def parse_args():
|
|
|
|
parser = argparse.ArgumentParser()
|
2019-07-19 15:06:29 +02:00
|
|
|
output = parser.add_argument_group('output', 'Output file(s)')
|
|
|
|
output.add_argument('--html', dest='html', action='store',
|
2018-04-04 22:05:33 +02:00
|
|
|
help='HTML output file')
|
2019-07-19 15:06:29 +02:00
|
|
|
output.add_argument('--json', dest='json', action='store',
|
|
|
|
help='JSON output file')
|
2019-07-19 15:06:28 +02:00
|
|
|
packages = parser.add_mutually_exclusive_group()
|
|
|
|
packages.add_argument('-n', dest='npackages', type=int, action='store',
|
2019-08-01 17:12:43 +02:00
|
|
|
help='Number of packages')
|
2019-07-19 15:06:28 +02:00
|
|
|
packages.add_argument('-p', dest='packages', action='store',
|
2019-08-01 17:12:43 +02:00
|
|
|
help='List of packages (comma separated)')
|
2020-02-15 13:44:16 +01:00
|
|
|
parser.add_argument('--nvd-path', dest='nvd_path',
|
|
|
|
help='Path to the local NVD database')
|
2019-07-19 15:06:29 +02:00
|
|
|
args = parser.parse_args()
|
|
|
|
if not args.html and not args.json:
|
|
|
|
parser.error('at least one of --html or --json (or both) is required')
|
|
|
|
return args
|
2018-04-04 22:05:33 +02:00
|
|
|
|
|
|
|
|
|
|
|
def __main__():
|
|
|
|
args = parse_args()
|
|
|
|
if args.packages:
|
|
|
|
package_list = args.packages.split(",")
|
|
|
|
else:
|
|
|
|
package_list = None
|
2019-07-19 15:06:30 +02:00
|
|
|
date = datetime.datetime.utcnow()
|
2019-09-12 18:55:22 +02:00
|
|
|
commit = subprocess.check_output(['git', 'rev-parse',
|
2020-03-01 22:18:48 +01:00
|
|
|
'HEAD']).splitlines()[0].decode()
|
2018-05-18 15:05:00 +02:00
|
|
|
print("Build package list ...")
|
2018-04-04 22:05:33 +02:00
|
|
|
packages = get_pkglist(args.npackages, package_list)
|
2020-03-07 08:56:24 +01:00
|
|
|
print("Getting developers ...")
|
|
|
|
developers = parse_developers()
|
2020-03-07 08:56:29 +01:00
|
|
|
print("Build defconfig list ...")
|
|
|
|
defconfigs = get_defconfig_list()
|
|
|
|
for d in defconfigs:
|
|
|
|
d.set_developers(developers)
|
2018-05-18 15:05:00 +02:00
|
|
|
print("Getting package make info ...")
|
2018-04-04 22:05:33 +02:00
|
|
|
package_init_make_info()
|
2018-05-18 15:05:00 +02:00
|
|
|
print("Getting package details ...")
|
2018-04-04 22:05:33 +02:00
|
|
|
for pkg in packages:
|
|
|
|
pkg.set_infra()
|
|
|
|
pkg.set_license()
|
|
|
|
pkg.set_hash_info()
|
|
|
|
pkg.set_patch_count()
|
|
|
|
pkg.set_check_package_warnings()
|
|
|
|
pkg.set_current_version()
|
2018-10-02 04:37:28 +02:00
|
|
|
pkg.set_url()
|
2020-03-07 08:56:24 +01:00
|
|
|
pkg.set_developers(developers)
|
2018-10-02 04:37:29 +02:00
|
|
|
print("Checking URL status")
|
|
|
|
check_package_urls(packages)
|
support/scripts/pkg-stats: add latest upstream version information
This commit adds fetching the latest upstream version of each package
from release-monitoring.org.
The fetching process first tries to use the package mappings of the
"Buildroot" distribution [1]. This mapping mechanism allows to tell
release-monitoring.org what is the name of a package in a given
distribution/build-system. For example, the package xutil_util-macros
in Buildroot is named xorg-util-macros on release-monitoring.org. This
mapping can be seen in the section "Mappings" of
https://release-monitoring.org/project/15037/.
If there is no mapping, then it does a regular search, and within the
search results, looks for a package whose name matches the Buildroot
name.
Even though fetching from release-monitoring.org is a bit slow, using
multiprocessing.Pool has proven to not be reliable, with some requests
ending up with an exception. So we keep a serialized approach, but
with a single HTTPSConnectionPool() for all queries. Long term, we
hope to be able to use a database dump of release-monitoring.org
instead.
From an output point of view, the latest version column:
- Is green when the version in Buildroot matches the latest upstream
version
- Is orange when the latest upstream version is unknown because the
package was not found on release-monitoring.org
- Is red when the version in Buildroot doesn't match the latest
upstream version. Note that we are not doing anything smart here:
we are just testing if the strings are equal or not.
- The cell contains the link to the project on release-monitoring.org
if found.
- The cell indicates if the match was done using a distro mapping, or
through a regular search.
[1] https://release-monitoring.org/distro/Buildroot/
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Tested-by: Matthew Weber <matthew.weber@rockwellcollins.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-02-05 16:19:59 +01:00
|
|
|
print("Getting latest versions ...")
|
|
|
|
check_package_latest_version(packages)
|
2020-02-15 13:44:16 +01:00
|
|
|
if args.nvd_path:
|
|
|
|
print("Checking packages CVEs")
|
|
|
|
check_package_cves(args.nvd_path, {p.name: p for p in packages})
|
2018-05-18 15:05:00 +02:00
|
|
|
print("Calculate stats")
|
2018-04-04 22:05:33 +02:00
|
|
|
stats = calculate_stats(packages)
|
2019-07-19 15:06:29 +02:00
|
|
|
if args.html:
|
|
|
|
print("Write HTML")
|
2019-07-19 15:06:30 +02:00
|
|
|
dump_html(packages, stats, date, commit, args.html)
|
2019-07-19 15:06:29 +02:00
|
|
|
if args.json:
|
|
|
|
print("Write JSON")
|
2020-03-07 08:56:29 +01:00
|
|
|
dump_json(packages, defconfigs, stats, date, commit, args.json)
|
2018-04-04 22:05:33 +02:00
|
|
|
|
|
|
|
|
|
|
|
__main__()
|