Openembedded Core Discussions
 help / color / mirror / Atom feed
From: "Yoann Congal" <yoann.congal@smile.fr>
To: <peter.tatrai.ext@siemens.com>,
	<openembedded-core@lists.openembedded.org>
Subject: Re: [OE-core] [scarthgap][PATCH 1/2] cve-check: keep global CVE exclusions out of unrelated reports
Date: Thu, 26 Nov 2026 16:15:09 +0100	[thread overview]
Message-ID: <DN58OUJGUFE1.1NS2QSHQ709AG@smile.fr> (raw)
In-Reply-To: <20261120092309.4056817-2-peter.tatrai.ext@siemens.com>

Hello,

On Fri Nov 20, 2026 at 10:23 AM CET, Peter via openembedded-core Tatrai wrote:
> From: Peter Tatrai <peter.tatrai.ext@siemens.com>
>
> The Scarthgap SPDX 3.0 backport [1] did not bring over product
> filtering for CVE_STATUS assessments. The follow-up [2] made SPDX
> export all CVE_STATUS assessments, exposing the same problem in SPDX
> that already affected CVE-check reports.
>
> Global exclusion lists are loaded for every recipe. Without product
> filtering, assessments intended for one product can appear in the
> CVE-check and SPDX/VEX reports of unrelated packages.

Can you put an extracts/examples of that please? Like before/after this
patch?

That sounds like a good bug to fix but I need more details since the
backport is not trivial.

> Backport the scoped parser from OE-Core commit abca80a716e9 and the
> product matcher from 452e605b55ad as they appear in Wrynose. Preserve
> Scarthgap's tuple and set APIs and the behavior of unscoped entries.

I have no idea if that makes sense but I suspect this would be easier to
review if the 2 squashed commit were backported separately (one in each
scarthgap patch): That way, I could compare the merged wrynose ones
with yours.

If applicable, please split the 2 commits for the next iteration.

> [1] Scarthgap SPDX 3.0 backport:
> https://git.openembedded.org/openembedded-core/commit/?id=9c9b9545049a
> [2] Export all CVE_STATUS assessments:
> https://git.openembedded.org/openembedded-core/commit/?id=9a204670b1c0
>
> Signed-off-by: Peter Tatrai <peter.tatrai.ext@siemens.com>
> ---
>  meta/classes/vex.bbclass                  |  1 -
>  meta/lib/oe/cve_check.py                  | 76 ++++++++++++++++++++---
>  meta/lib/oe/spdx30_tasks.py               |  1 -
>  meta/lib/oeqa/selftest/cases/cve_check.py | 48 ++++++++++++++
>  4 files changed, 117 insertions(+), 9 deletions(-)
>
> diff --git a/meta/classes/vex.bbclass b/meta/classes/vex.bbclass
> index 97213ea..3c44dbb 100644
> --- a/meta/classes/vex.bbclass
> +++ b/meta/classes/vex.bbclass
> @@ -141,7 +141,6 @@ python do_generate_vex () {
>      for cve_id in (d.getVarFlags("CVE_STATUS") or {}):
>          mapping, detail, description = decode_cve_status(d, cve_id)
>          if not mapping or not detail:
> -            bb.warn(f"Skipping {cve_id} — missing or unknown CVE status")

Was this warn removal voluntary? If yes, then this should be explained
in the commit message.

>              continue
>          cve_data[cve_id] = {
>              "abbrev-status": mapping,
> diff --git a/meta/lib/oe/cve_check.py b/meta/lib/oe/cve_check.py
> index 7c09b78..9620dc5 100644
> --- a/meta/lib/oe/cve_check.py
> +++ b/meta/lib/oe/cve_check.py
> @@ -227,22 +227,84 @@ def convert_cve_version(version):
>  
>  def decode_cve_status(d, cve):
>      """
> -    Convert CVE_STATUS into status, detail and description.
> +    Convert a matching CVE_STATUS into status, detail and description.
> +
> +    Keep the Scarthgap tuple API for cve-check and existing SPDX consumers.

While referencing scarthgap in the commit message is fair, I don't think
it's necessary in the code itself, where the "Scarthgap tuple API" is
simply the current API. And you won't document a change you won't make
in the code.

This looks like a LLM output. Please review our AI-Assisted Contribution
Policy[0] and update your contribution if that apply.

>      """
> -    status = d.getVarFlag("CVE_STATUS", cve)
> +    status = decode_cve_status_scoped(d, cve)
>      if not status:
>          return ("", "", "")
> +    # Scarthgap applies unscoped statuses even when CVE_PRODUCT is empty.

(Same: scarthgap reference in code)

> +    unscoped = status["vendor"] == status["product"] == "*"
> +    if not unscoped and not has_cve_product_match(status, d.getVar("CVE_PRODUCT") or ""):
> +        return ("", "", "")
> +    return (status["mapping"], status["detail"], status["description"])
> +
> +
> +def has_cve_product_match(detailed_status, products):
> +    """
> +    Check product/vendor match between detailed_status from decode_cve_status and a string of
> +    products (like from CVE_PRODUCT)
> +    """
> +    for product in products.split():
> +        vendor = "*"
> +        if ":" in product:
> +            vendor, product = product.split(":", 1)
> +
> +        if (vendor == detailed_status["vendor"] or detailed_status["vendor"] == "*") and \
> +            (product == detailed_status["product"] or detailed_status["product"] == "*"):
> +            return True
>  
> -    status_split = status.split(':', 1)
> -    detail = status_split[0]
> -    description = status_split[1].strip() if (len(status_split) > 1) else ""
> +    #if no match, return False
> +    return False
>  
> +
> +def decode_cve_status_scoped(d, cve):
> +    """
> +    Convert CVE_STATUS into status, vendor, product, detail and description.
> +    """
> +    status = d.getVarFlag("CVE_STATUS", cve)
> +    if not status:
> +        return {}
> +
> +    status_split = status.split(':', 4)
> +    status_out = {}
> +    status_out["detail"] = status_split[0]
> +    product = "*"
> +    vendor = "*"
> +    description = ""
> +    if len(status_split) >= 4 and status_split[1].strip() == "cpe":
> +        # Both vendor and product are mandatory if cpe: present, the syntax is then:
> +        # detail: cpe:vendor:product:description
> +        vendor = status_split[2].strip()
> +        product = status_split[3].strip()
> +        description = status_split[4].strip()
> +    elif len(status_split) >= 2 and status_split[1].strip() == "cpe":
> +        # Malformed CPE
> +        bb.warn(
> +            'Invalid CPE information for CVE_STATUS[%s] = "%s", not setting CPE'
> +            % (cve, status)
> +        )
> +    else:
> +        # Other case: no CPE, the syntax is then:
> +        # detail: description
> +        description = status.split(':', 1)[1].strip() if (len(status_split) > 1) else ""
> +
> +    status_out["vendor"] = vendor
> +    status_out["product"] = product
> +    status_out["description"] = description
> +
> +    detail = status_out["detail"]
>      status_mapping = d.getVarFlag("CVE_CHECK_STATUSMAP", detail)
>      if status_mapping is None:
> -        bb.warn('Invalid detail "%s" for CVE_STATUS[%s] = "%s", fallback to Unpatched' % (detail, cve, status))
> +        bb.warn(
> +            'Invalid detail "%s" for CVE_STATUS[%s] = "%s", fallback to Unpatched'
> +            % (detail, cve, status)
> +        )
>          status_mapping = "Unpatched"
> +    status_out["mapping"] = status_mapping
>  
> -    return (status_mapping, detail, description)
> +    return status_out
>  
>  def extend_cve_status(d):
>      # do this only once in case multiple classes use this
> diff --git a/meta/lib/oe/spdx30_tasks.py b/meta/lib/oe/spdx30_tasks.py
> index 0e9c6fa..539901f 100644
> --- a/meta/lib/oe/spdx30_tasks.py
> +++ b/meta/lib/oe/spdx30_tasks.py
> @@ -470,7 +470,6 @@ def _get_cves_info(d):
>      for cve_id in (d.getVarFlags("CVE_STATUS") or {}):
>          mapping, detail, description = oe.cve_check.decode_cve_status(d, cve_id)
>          if not mapping or not detail:
> -            bb.warn(f"Skipping {cve_id} — missing or unknown CVE status")

(same: undocumented warn() removal)

>              continue
>          yield cve_id, mapping, detail, description
>          patched_cves.discard(cve_id)
> diff --git a/meta/lib/oeqa/selftest/cases/cve_check.py b/meta/lib/oeqa/selftest/cases/cve_check.py
> index 60cecd1..8cd5eb9 100644
> --- a/meta/lib/oeqa/selftest/cases/cve_check.py
> +++ b/meta/lib/oeqa/selftest/cases/cve_check.py
> @@ -11,6 +11,54 @@ from oeqa.utils.commands import bitbake, get_bb_vars
>  
>  class CVECheck(OESelftestTestCase):
>  
> +    def test_scoped_status(self):
> +        import bb
> +        from oe.cve_check import decode_cve_status, extend_cve_status, get_patched_cves
> +        from unittest.mock import patch
> +
> +        d = bb.data.init()
> +        cve = "CVE-2020-0001"
> +        d.setVarFlag("CVE_CHECK_STATUSMAP", "fixed-version", "Patched")
> +        d.setVarFlag("CVE_CHECK_STATUSMAP", "ignored", "Ignored")
> +        d.setVarFlag("CVE_STATUS", cve, "fixed-version: cpe:oracle:berkeley_db: Fixed: see upstream")
> +        for product, expected in (
> +            ("oracle:berkeley_db", ("Patched", "fixed-version", "Fixed: see upstream")),
> +            ("other:berkeley_db", ("", "", "")),
> +            ("oracle:zlib", ("", "", "")),
> +            ("zlib:zlib oracle:berkeley_db", ("Patched", "fixed-version", "Fixed: see upstream")),
> +        ):
> +            with self.subTest(product=product):
> +                d.setVar("CVE_PRODUCT", product)
> +                self.assertEqual(decode_cve_status(d, cve), expected)
> +                with patch("oe.patch.src_patches", return_value=[]):
> +                    self.assertEqual(get_patched_cves(d), {cve} if expected[0] else set())
> +
> +        d.setVar("CVE_PRODUCT", "zlib")
> +        d.setVarFlag("CVE_STATUS", cve, "ignored: Existing unscoped reason: unchanged")
> +        self.assertEqual(decode_cve_status(d, cve),
> +                         ("Ignored", "ignored", "Existing unscoped reason: unchanged"))
> +        d.setVar("CVE_STATUS_GROUPS", "SCOPED_GROUP")
> +        d.setVar("SCOPED_GROUP", cve)
> +        d.setVarFlag("SCOPED_GROUP", "status", "ignored: cpe:*:zlib: Matching group")
> +        extend_cve_status(d)
> +        self.assertEqual(decode_cve_status(d, cve), ("Ignored", "ignored", "Matching group"))
> +        d.setVar("CVE_PRODUCT", "glibc")
> +        self.assertEqual(decode_cve_status(d, cve), ("", "", ""))
> +
> +    def test_scoped_status_spdx(self):
> +        import bb
> +        import oe.spdx30_tasks
> +        from unittest.mock import patch
> +
> +        d = bb.data.init()
> +        d.setVar("CVE_PRODUCT", "zlib:zlib")
> +        d.setVarFlag("CVE_CHECK_STATUSMAP", "ignored", "Ignored")
> +        d.setVarFlag("CVE_STATUS", "CVE-2020-0001", "ignored: cpe:*:berkeley_db: Not zlib")
> +        d.setVarFlag("CVE_STATUS", "CVE-2020-0002", "ignored: cpe:*:zlib: Matches zlib")
> +        with patch("oe.patch.src_patches", return_value=[]):
> +            self.assertEqual(list(oe.spdx30_tasks._get_cves_info(d)),
> +                             [("CVE-2020-0002", "Ignored", "ignored", "Matches zlib")])
> +
>      def test_version_compare(self):
>          from oe.cve_check import Version
>  

Regards,

[0]: https://docs.yoctoproject.org/dev/contributor-guide/ai-assisted-contribution-policy.html
-- 
Yoann Congal
Smile ECS


  reply	other threads:[~2026-11-26 15:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20  9:23 [scarthgap][PATCH 0/2] Scope global CVE exclusions by product P. Tatrai
2026-11-20  9:23 ` [scarthgap][PATCH 1/2] cve-check: keep global CVE exclusions out of unrelated reports P. Tatrai
2026-11-26 15:15   ` Yoann Congal [this message]
2026-11-20  9:23 ` [scarthgap][PATCH 2/2] cve-exclusions: qualify global assessments by product P. Tatrai
2026-11-26 15:21   ` [OE-core] " Yoann Congal

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=DN58OUJGUFE1.1NS2QSHQ709AG@smile.fr \
    --to=yoann.congal@smile.fr \
    --cc=openembedded-core@lists.openembedded.org \
    --cc=peter.tatrai.ext@siemens.com \
    /path/to/YOUR_REPLY

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

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