From: Yann E. MORIN <yann.morin.1998@free.fr>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH v2 5/7] support/scripts/gen-missing-cpe: add new script
Date: Sun, 16 May 2021 14:08:39 +0200 [thread overview]
Message-ID: <20210516120839.GC2506@scaer> (raw)
In-Reply-To: <20210131133819.1818537-6-thomas.petazzoni@bootlin.com>
Thomas, All,
On 2021-01-31 14:38 +0100, Thomas Petazzoni spake thusly:
> From: Matt Weber <matthew.weber@rockwellcollins.com>
>
> This script queries the list of CPE IDs for the packages of the
> current configuration (based on the "make show-info" output), and:
>
> - for CPE IDs that do not have any matching entry in the CPE
> database, it emits a warning
>
> - for CPE IDs that do have a matching entry, but not with the same
> version, it generates a snippet of XML that can be used to propose
> an updated version to NIST.
>
> Ref: NIST has a group email (cpe_dictionary at nist.gov) used to
> recieve these version update and new entry xml files. They do
> process the XML and provide feedback. In some cases they will
> propose back something different where the vendor or version is
> slightly different.
>
> Limitations
> - Currently any use of non-number version identifiers isn't
> supported by NIST as they use ranges to determine impact
> of a CVE
> - Any Linux version from a non-upstream is also not supported
> without manually adjusting the information as the custom
> kernel will more then likely not match the upstream version
> used in the dictionary
>
> Signed-off-by: Matt Weber <matthew.weber@rockwellcollins.com>
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Applied to master, with most of the changes pointed out by Arnout,
thanks. I'll further reply to Arnout's comment...
Regards,
Yann E. MORIN.
> ---
> support/scripts/gen-missing-cpe | 65 +++++++++++++++++++++++++++++++++
> 1 file changed, 65 insertions(+)
> create mode 100755 support/scripts/gen-missing-cpe
>
> diff --git a/support/scripts/gen-missing-cpe b/support/scripts/gen-missing-cpe
> new file mode 100755
> index 0000000000..ed7747295a
> --- /dev/null
> +++ b/support/scripts/gen-missing-cpe
> @@ -0,0 +1,65 @@
> +#!/usr/bin/env python3
> +
> +import argparse
> +import sys
> +import json
> +import subprocess
> +import os
> +from cpedb import CPEDB, CPE
> +
> +
> +def gen_update_xml_reports(cpes, cpedb, output):
> + cpe_need_update = []
> +
> + for cpe in cpes:
> + result = cpedb.find(cpe)
> + if not result:
> + result = cpedb.find_partial(CPE.no_version(cpe))
> + if result:
> + cpe_need_update.append(cpe)
> + else:
> + print("WARNING: no match found for '%s'" % cpe)
> +
> + for cpe in cpe_need_update:
> + xml = cpedb.gen_update_xml(cpe)
> + fname = CPE.product(cpe) + '-' + CPE.version(cpe) + '.xml'
> + print("Generating %s" % fname)
> + fp = open(os.path.join(output, fname), 'w+')
> + fp.write(xml)
> + fp.close()
> +
> + print("Generated %d update files out of %d CPEs" % (len(cpe_need_update), len(cpes)))
> +
> +
> +def get_cpe_ids():
> + print("Getting list of CPE for enabled packages")
> + cmd = ["make", "--no-print-directory", "show-info"]
> + js = json.loads(subprocess.check_output(cmd).decode("utf-8"))
> + return set([v["cpe-id"] for k, v in js.items() if "cpe-id" in v])
> +
> +
> +def resolvepath(path):
> + return os.path.abspath(os.path.expanduser(path))
> +
> +
> +def parse_args():
> + parser = argparse.ArgumentParser()
> + parser.add_argument('--output', dest='output',
> + help='Path to the output CPE update files', type=resolvepath, required=True)
> + parser.add_argument('--nvd-path', dest='nvd_path',
> + help='Path to the local NVD database', type=resolvepath, required=True)
> + return parser.parse_args()
> +
> +
> +def __main__():
> + args = parse_args()
> + if not os.path.isdir(args.output):
> + print("ERROR: output directory %s does not exist" % args.output)
> + sys.exit(1)
> + cpedb = CPEDB(args.nvd_path)
> + cpedb.get_xml_dict()
> + cpes = get_cpe_ids()
> + gen_update_xml_reports(cpes, cpedb, args.output)
> +
> +
> +__main__()
> --
> 2.29.2
>
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
next prev parent reply other threads:[~2021-05-16 12:08 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-31 13:38 [Buildroot] [PATCH v2 0/7] CPE validation Thomas Petazzoni
2021-01-31 13:38 ` [Buildroot] [PATCH v2 1/7] package/pkg-utils.mk: introduce "name" field in show-info output Thomas Petazzoni
2021-01-31 13:38 ` [Buildroot] [PATCH v2 2/7] support/scripts/pkg-stats: properly handle host packages with -c option Thomas Petazzoni
2021-02-02 19:29 ` Arnout Vandecappelle
2021-01-31 13:38 ` [Buildroot] [PATCH v2 3/7] support/scripts/cpedb.py: new CPE XML helper Thomas Petazzoni
2021-01-31 22:47 ` Yann E. MORIN
2021-01-31 22:51 ` Yann E. MORIN
2021-02-02 20:31 ` Arnout Vandecappelle
2021-01-31 13:38 ` [Buildroot] [PATCH v2 4/7] support/scripts/pkg-stats: check CPE existence in CPE dictionnary Thomas Petazzoni
2021-02-02 20:49 ` Arnout Vandecappelle
2021-01-31 13:38 ` [Buildroot] [PATCH v2 5/7] support/scripts/gen-missing-cpe: add new script Thomas Petazzoni
2021-02-02 21:29 ` Arnout Vandecappelle
2021-02-08 21:09 ` Matthew Weber
2021-05-16 12:13 ` Yann E. MORIN
2021-05-16 12:08 ` Yann E. MORIN [this message]
2021-01-31 13:38 ` [Buildroot] [PATCH v2 6/7] Makefile: add new missing-cpe target Thomas Petazzoni
2021-02-02 21:29 ` Arnout Vandecappelle
2021-02-08 21:10 ` Matthew Weber
2021-01-31 13:38 ` [Buildroot] [PATCH v2 7/7] docs/manual: add details about vulnerability management Thomas Petazzoni
2021-02-02 22:02 ` Arnout Vandecappelle
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210516120839.GC2506@scaer \
--to=yann.morin.1998@free.fr \
--cc=buildroot@busybox.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.