Skip to contentSkip to conversation

utils/checkpackagelib: remove unused variable

PATCH Applied Thomas Perale via buildroot 1 participant 12 messages Sep 18 – Oct 16

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 utils/checkpackagelib: remove unused variable

The self.pending_patch is set but unused.

Fixes b00ac4e346 utils/checkpackagelib: add new check MissingCVEPatch
---
 utils/checkpackagelib/lib_mk.py | 1 -
 1 file changed, 1 deletion(-)
utils/checkpackagelib/lib_mk.py +0 -1
index eb5fbf474c..065733d464 100644
@@ -130,7 +130,6 @@ class MissingCVEPatch(_CheckFunction):
     def check_patch_files(self):
         for patch_lineno, patch_name, patch_text in self.pending_patches:
             patch_file = self.package_dir / patch_name
-            self.pending_patch = None
 
             if not patch_file.is_file():
                 return ["{}:{}: patch file '{}' mentioned for ignored CVEs is missing"
Signature · 6 lines
2.55.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

PATCH 2/3 utils/checkpackagelib: support other identifiers than CVE

Currently the MissingCVEPatch check will complain if another identifiers than a CVE-YYYY-XXXX is passed after the 'CVE: ' trailer in the patch header introduced in [1].

If a package 'foo' defines the following:

FOO_IGNORE_CVES += GHSA-abcd-1234-efgh

And correctly references it in a patch header:

CVE: GHSA-abcd-1234-efgh

check-package will report the following:

package/foo/foo.mk: patch file '0001-some-patch.patch' is missing 'CVE:' tag

While we could argue that GHSA identifier should not be present in the 'IGNORE_CVES' variable, it's still valuable for users to have a way to correctly ignore and link a patch for their vulnerability report.

From our point of view it allows us to track GHSA vulnerabilities that could later be assigned a CVE so we can update the IGNORE_CVES variable.

This commit relaxes the constraint on the 'CVE' trailer to just check for the presence of the trailer in some patch.

[1] 1167d0ff3d docs/manual: mention CVE trailer

---
 utils/checkpackagelib/lib_mk.py      | 9 +++++++--
 utils/checkpackagelib/test_lib_mk.py | 5 +++++
 2 files changed, 12 insertions(+), 2 deletions(-)
utils/checkpackagelib/lib_mk.py +7 -2
index 065733d464..c5b85bcda9 100644
@@ -121,7 +121,7 @@ class Indent(_CheckFunction):
 class MissingCVEPatch(_CheckFunction):
     PATCH_COMMENT = re.compile(r"^#\s*(\S+\.patch)\s*$")
     IGNORE_CVES = re.compile(r"^[A-Z0-9_]+_IGNORE_CVES\s*\+?=")
-    CVE_TAG_IN_PATCH = re.compile(r"^CVE: *CVE-\d+-\d+$")
+    CVE_TAG_IN_PATCH = "CVE: "
 
     def before(self):
         self.pending_patches = []
@@ -136,7 +136,12 @@ class MissingCVEPatch(_CheckFunction):
                         .format(self.filename, patch_lineno, patch_name),
                         patch_text]
 
-            if not any(map(self.CVE_TAG_IN_PATCH.match, patch_file.open())):
+            trailers = [
+                line.partition(self.CVE_TAG_IN_PATCH)[2].strip()
+                for line in patch_file.open()
+                if line.startswith(self.CVE_TAG_IN_PATCH)
+            ]
+            if not trailers:
                 return ["{}: patch file '{}' is missing 'CVE:' tag"
                         .format(self.filename, patch_name),
                         patch_text]
utils/checkpackagelib/test_lib_mk.py +5 -0
index 21effa9489..ba9dbd6aea 100644
@@ -239,6 +239,11 @@ MissingCVEPatch = [
      {},
      'FOO_IGNORE_CVES += CVE-2000-1234\n',
      []),
+    ('patches present with other identifier',
+     {'0001-some-fix.patch': 'CVE: GHSA-abcd-1234-efgh'},
+     '# 0001-some-fix.patch\n'
+     'FOO_IGNORE_CVES += GHSA-abcd-1234-efgh\n',
+     []),
     ]
 
 
Signature · 6 lines
2.55.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
author Reviewed-by Titouan Christophe on v1 2/3
#2 lore raw

Re: [Buildroot] [PATCH 2/3] utils/checkpackagelib: support other identifiers than CVE

Hi Thomas and all,

Quoted 23 lines · Thomas Perale

Currently the MissingCVEPatch check will complain if another identifiers than a CVE-YYYY-XXXX is passed after the 'CVE: ' trailer in the patch header introduced in [1].

If a package 'foo' defines the following:

FOO_IGNORE_CVES += GHSA-abcd-1234-efgh

And correctly references it in a patch header:

CVE: GHSA-abcd-1234-efgh

check-package will report the following:

package/foo/foo.mk: patch file '0001-some-patch.patch' is missing 'CVE:' tag

While we could argue that GHSA identifier should not be present in the 'IGNORE_CVES' variable, it's still valuable for users to have a way to correctly ignore and link a patch for their vulnerability report.

From our point of view it allows us to track GHSA vulnerabilities that
could later be assigned a CVE so we can update the IGNORE_CVES variable.

Quoted 6 lines

This commit relaxes the constraint on the 'CVE' trailer to just check for the presence of the trailer in some patch.

[1] 1167d0ff3d docs/manual: mention CVE trailer

Quoted 19 lines
---
  utils/checkpackagelib/lib_mk.py      | 9 +++++++--
  utils/checkpackagelib/test_lib_mk.py | 5 +++++
  2 files changed, 12 insertions(+), 2 deletions(-)
utils/checkpackagelib/lib_mk.py +1 -1
index 065733d464..c5b85bcda9 100644
@@ -121,7 +121,7 @@ class Indent(_CheckFunction):
  class MissingCVEPatch(_CheckFunction):
      PATCH_COMMENT = re.compile(r"^#\s*(\S+\.patch)\s*$")
      IGNORE_CVES = re.compile(r"^[A-Z0-9_]+_IGNORE_CVES\s*\+?=")
-    CVE_TAG_IN_PATCH = re.compile(r"^CVE: *CVE-\d+-\d+$")
+    CVE_TAG_IN_PATCH = "CVE: "
 
      def before(self):
          self.pending_patches = []

utils/checkpackagelib/lib_mk.py class MissingCVEPatch(_CheckFunction): · line 140

Quoted 6 lines
utils/checkpackagelib/lib_mk.py +2 -1
@@ -136,7 +136,12 @@ class MissingCVEPatch(_CheckFunction):
                          .format(self.filename, patch_lineno, patch_name),
                          patch_text]
 
-            if not any(map(self.CVE_TAG_IN_PATCH.match, patch_file.open())):
+            trailers = [
+                line.partition(self.CVE_TAG_IN_PATCH)[2].strip()

Nitpick: might be simplified with just

    line[len(self.CVE_TAG_IN_PATCH):]

because we already check that the line startswith it. I personally think it's slightly easier to understand, although definitely not a blocker.

Quoted 13 lines
utils/checkpackagelib/lib_mk.py +4 -0
+                for line in patch_file.open()
+                if line.startswith(self.CVE_TAG_IN_PATCH)
+            ]
+            if not trailers:
                  return ["{}: patch file '{}' is missing 'CVE:' tag"
                          .format(self.filename, patch_name),
                          patch_text]
utils/checkpackagelib/test_lib_mk.py +0 -0
index 21effa9489..ba9dbd6aea 100644
@@ -239,6 +239,11 @@ MissingCVEPatch = [
       {},

utils/checkpackagelib/test_lib_mk.py MissingCVEPatch = [ · line 249

Quoted 10 lines
utils/checkpackagelib/test_lib_mk.py +5 -0
       'FOO_IGNORE_CVES += CVE-2000-1234\n',
       []),
+    ('patches present with other identifier',
+     {'0001-some-fix.patch': 'CVE: GHSA-abcd-1234-efgh'},
+     '# 0001-some-fix.patch\n'
+     'FOO_IGNORE_CVES += GHSA-abcd-1234-efgh\n',
+     []),
      ]
 
 

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#3 lore raw

Re: [Buildroot] [PATCH 2/3] utils/checkpackagelib: support other identifiers than CVE

In reply to Thomas Perale via buildroot
Quoted 23 lines · Thomas Perale via buildroot

Currently the MissingCVEPatch check will complain if another identifiers than a CVE-YYYY-XXXX is passed after the 'CVE: ' trailer in the patch header introduced in [1].

If a package 'foo' defines the following:

FOO_IGNORE_CVES += GHSA-abcd-1234-efgh

And correctly references it in a patch header:

CVE: GHSA-abcd-1234-efgh

check-package will report the following:

package/foo/foo.mk: patch file '0001-some-patch.patch' is missing 'CVE:' tag

While we could argue that GHSA identifier should not be present in the 'IGNORE_CVES' variable, it's still valuable for users to have a way to correctly ignore and link a patch for their vulnerability report.

From our point of view it allows us to track GHSA vulnerabilities that could later be assigned a CVE so we can update the IGNORE_CVES variable.

Quoted 6 lines

This commit relaxes the constraint on the 'CVE' trailer to just check for the presence of the trailer in some patch.

[1] 1167d0ff3d docs/manual: mention CVE trailer

Applied to master, thanks! But see below.

Quoted 10 lines
---
 utils/checkpackagelib/lib_mk.py      | 9 +++++++--
 utils/checkpackagelib/test_lib_mk.py | 5 +++++
 2 files changed, 12 insertions(+), 2 deletions(-)
utils/checkpackagelib/lib_mk.py +0 -0
index 065733d464..c5b85bcda9 100644

utils/checkpackagelib/lib_mk.py class Indent(_CheckFunction): · line 124

Quoted 5 lines
utils/checkpackagelib/lib_mk.py +1 -1
@@ -121,7 +121,7 @@ class Indent(_CheckFunction):
 class MissingCVEPatch(_CheckFunction):
     PATCH_COMMENT = re.compile(r"^#\s*(\S+\.patch)\s*$")
     IGNORE_CVES = re.compile(r"^[A-Z0-9_]+_IGNORE_CVES\s*\+?=")
-    CVE_TAG_IN_PATCH = re.compile(r"^CVE: *CVE-\d+-\d+$")
+    CVE_TAG_IN_PATCH = "CVE: "

This would allow multiple CVEs on one line, which is not actually supported.
So I've kept the regex and just allowed any alphanumerical character or dash in the ID.

Regards,
Arnout

Quoted 35 lines
utils/checkpackagelib/lib_mk.py +6 -1
     def before(self):
         self.pending_patches = []
@@ -136,7 +136,12 @@ class MissingCVEPatch(_CheckFunction):
                         .format(self.filename, patch_lineno, patch_name),
                         patch_text]
 
-            if not any(map(self.CVE_TAG_IN_PATCH.match, patch_file.open())):
+            trailers = [
+                line.partition(self.CVE_TAG_IN_PATCH)[2].strip()
+                for line in patch_file.open()
+                if line.startswith(self.CVE_TAG_IN_PATCH)
+            ]
+            if not trailers:
                 return ["{}: patch file '{}' is missing 'CVE:' tag"
                         .format(self.filename, patch_name),
                         patch_text]
utils/checkpackagelib/test_lib_mk.py +5 -0
index 21effa9489..ba9dbd6aea 100644
@@ -239,6 +239,11 @@ MissingCVEPatch = [
      {},
      'FOO_IGNORE_CVES += CVE-2000-1234\n',
      []),
+    ('patches present with other identifier',
+     {'0001-some-fix.patch': 'CVE: GHSA-abcd-1234-efgh'},
+     '# 0001-some-fix.patch\n'
+     'FOO_IGNORE_CVES += GHSA-abcd-1234-efgh\n',
+     []),
     ]
 
 
Signature · 1 line
2.55.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#4 lore raw

Re: [Buildroot] [PATCH 2/3] utils/checkpackagelib: support other identifiers than CVE

In reply to Thomas Perale via buildroot

In reply of:

Quoted 23 lines

Currently the MissingCVEPatch check will complain if another identifiers than a CVE-YYYY-XXXX is passed after the 'CVE: ' trailer in the patch header introduced in [1].

If a package 'foo' defines the following:

FOO_IGNORE_CVES += GHSA-abcd-1234-efgh

And correctly references it in a patch header:

CVE: GHSA-abcd-1234-efgh

check-package will report the following:

package/foo/foo.mk: patch file '0001-some-patch.patch' is missing 'CVE:' tag

While we could argue that GHSA identifier should not be present in the 'IGNORE_CVES' variable, it's still valuable for users to have a way to correctly ignore and link a patch for their vulnerability report.

From our point of view it allows us to track GHSA vulnerabilities that could later be assigned a CVE so we can update the IGNORE_CVES variable.

Quoted 7 lines

This commit relaxes the constraint on the 'CVE' trailer to just check for the presence of the trailer in some patch.

[1] 1167d0ff3d docs/manual: mention CVE trailer

Applied to 2025.02.x, 2026.08.x. Thanks

Quoted 38 lines
---
 utils/checkpackagelib/lib_mk.py      | 9 +++++++--
 utils/checkpackagelib/test_lib_mk.py | 5 +++++
 2 files changed, 12 insertions(+), 2 deletions(-)
utils/checkpackagelib/lib_mk.py +7 -2
index 065733d464..c5b85bcda9 100644
@@ -121,7 +121,7 @@ class Indent(_CheckFunction):
 class MissingCVEPatch(_CheckFunction):
     PATCH_COMMENT = re.compile(r"^#\s*(\S+\.patch)\s*$")
     IGNORE_CVES = re.compile(r"^[A-Z0-9_]+_IGNORE_CVES\s*\+?=")
-    CVE_TAG_IN_PATCH = re.compile(r"^CVE: *CVE-\d+-\d+$")
+    CVE_TAG_IN_PATCH = "CVE: "
 
     def before(self):
         self.pending_patches = []
@@ -136,7 +136,12 @@ class MissingCVEPatch(_CheckFunction):
                         .format(self.filename, patch_lineno, patch_name),
                         patch_text]
 
-            if not any(map(self.CVE_TAG_IN_PATCH.match, patch_file.open())):
+            trailers = [
+                line.partition(self.CVE_TAG_IN_PATCH)[2].strip()
+                for line in patch_file.open()
+                if line.startswith(self.CVE_TAG_IN_PATCH)
+            ]
+            if not trailers:
                 return ["{}: patch file '{}' is missing 'CVE:' tag"
                         .format(self.filename, patch_name),
                         patch_text]
utils/checkpackagelib/test_lib_mk.py +0 -0
index 21effa9489..ba9dbd6aea 100644
@@ -239,6 +239,11 @@ MissingCVEPatch = [
      {},

utils/checkpackagelib/test_lib_mk.py MissingCVEPatch = [ · line 249

Quoted 10 lines
utils/checkpackagelib/test_lib_mk.py +5 -0
      'FOO_IGNORE_CVES += CVE-2000-1234\n',
      []),
+    ('patches present with other identifier',
+     {'0001-some-fix.patch': 'CVE: GHSA-abcd-1234-efgh'},
+     '# 0001-some-fix.patch\n'
+     'FOO_IGNORE_CVES += GHSA-abcd-1234-efgh\n',
+     []),
     ]
 
 

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#5 lore raw

PATCH 3/3 utils/checkpackagelib: check IGNORE_CVES identifiers match patch trailers

In reply to Thomas Perale via buildroot

The ability to check with make check-package the 'IGNORE_CVES' variable content reference an existing patches was added in commit [1].

This commit extend it to actually check that the entries that are referenced in the 'IGNORE_CVES' variable are matching the trailers in the referenced patch.

With this change the following foo.mk content:

```
FOO_IGNORE_CVES += CVE-2000-1234
```

Running make check-package will output an error if the content of the patch is the following:

```
CVE: CVE-2001-1234
```

[1] b00ac4e346 utils/checkpackagelib: add new check MissingCVEPatch

---
 utils/checkpackagelib/lib_mk.py      | 25 +++++++++++++++++++---
 utils/checkpackagelib/test_lib_mk.py | 32 ++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+), 3 deletions(-)
utils/checkpackagelib/lib_mk.py +22 -3
index c5b85bcda9..33988cab8b 100644
@@ -120,12 +120,14 @@ class Indent(_CheckFunction):
 
 class MissingCVEPatch(_CheckFunction):
     PATCH_COMMENT = re.compile(r"^#\s*(\S+\.patch)\s*$")
-    IGNORE_CVES = re.compile(r"^[A-Z0-9_]+_IGNORE_CVES\s*\+?=")
+    IGNORE_CVES = re.compile(r"^[A-Z0-9_]+_IGNORE_CVES\s*\+?=\s*(.*)$")
     CVE_TAG_IN_PATCH = "CVE: "
 
     def before(self):
         self.pending_patches = []
+        self.pending_cves = []
         self.package_dir = Path(self.filename).parent
+        self.line_continuation = False
 
     def check_patch_files(self):
         for patch_lineno, patch_name, patch_text in self.pending_patches:
@@ -146,6 +148,11 @@ class MissingCVEPatch(_CheckFunction):
                         .format(self.filename, patch_name),
                         patch_text]
 
+            if set(self.pending_cves) != set(trailers):
+                return ["{}: patch file '{}' 'CVE:' tag(s) '{}' does not match the ignored identifier(s) '{}'"
+                        .format(self.filename, patch_name, ", ".join(trailers), ", ".join(self.pending_cves)),
+                        patch_text]
+
     def check_line(self, lineno, text):
         m = self.PATCH_COMMENT.match(text.rstrip())
         if m:
@@ -157,9 +164,21 @@ class MissingCVEPatch(_CheckFunction):
         if text.lstrip().startswith("#"):
             return
 
-        if self.IGNORE_CVES.search(text):
-            return self.check_patch_files()
+        m = self.IGNORE_CVES.search(text)
+        if m or self.line_continuation:
+            value = (m.group(1) if m else text).rstrip()
+            self.line_continuation = value.endswith("\\")
+            if self.line_continuation:
+                value = value[:-1]
+            self.pending_cves += value.split()
+            if self.line_continuation:
+                return
+            result = self.check_patch_files()
+            self.pending_cves = []
+            self.pending_patches = []
+            return result
 
+        self.pending_cves = []
         self.pending_patches = []
 
 
utils/checkpackagelib/test_lib_mk.py +32 -0
index ba9dbd6aea..7152b40e2b 100644
@@ -244,6 +244,38 @@ MissingCVEPatch = [
      '# 0001-some-fix.patch\n'
      'FOO_IGNORE_CVES += GHSA-abcd-1234-efgh\n',
      []),
+    ('CVE tag does not match ignored identifier',
+     {'0001-some-fix.patch': 'CVE: CVE-2000-1234'},
+     '# 0001-some-fix.patch\n'
+     'FOO_IGNORE_CVES += CVE-2001-1234\n',
+     [['{}: patch file \'0001-some-fix.patch\' \'CVE:\' tag(s) \'CVE-2000-1234\' '
+       'does not match the ignored identifier(s) \'CVE-2001-1234\'',
+       '# 0001-some-fix.patch\n']]),
+    ('multiple ignored identifiers, patch matches one',
+     {'0001-some-fix.patch': 'CVE: CVE-2000-1234'},
+     '# 0001-some-fix.patch\n'
+     'FOO_IGNORE_CVES += CVE-2000-1234 CVE-2001-1234\n',
+     [['{}: patch file \'0001-some-fix.patch\' \'CVE:\' tag(s) \'CVE-2000-1234\' '
+       'does not match the ignored identifier(s) \'CVE-2000-1234, CVE-2001-1234\'',
+       '# 0001-some-fix.patch\n']]),
+    ('multiple ignored identifiers, all referenced across patch',
+     {'0001-some-fix.patch': 'CVE: CVE-2000-1234\nCVE: CVE-2001-1234\n'},
+     '# 0001-some-fix.patch\n'
+     'FOO_IGNORE_CVES += CVE-2000-1234 CVE-2001-1234\n',
+     []),
+    ('multiple ignored identifiers, all referenced across multiple patches',
+     {'0001-some-fix.patch': 'CVE: CVE-2000-1234\nCVE: CVE-2001-1234',
+      '0002-other-fix.patch': 'CVE: CVE-2000-1234\nCVE: CVE-2001-1234'},
+     '# 0001-some-fix.patch\n'
+     '# 0002-other-fix.patch\n'
+     'FOO_IGNORE_CVES += CVE-2000-1234 CVE-2001-1234\n',
+     []),
+    ('ignored identifiers split across continuation lines',
+     {'0001-some-fix.patch': 'CVE: CVE-2000-1234\nCVE: CVE-2001-1234\n'},
+     '# 0001-some-fix.patch\n'
+     'FOO_IGNORE_CVES += CVE-2000-1234 \\\n'
+     '\tCVE-2001-1234\n',
+     []),
     ]
 
 
Signature · 6 lines
2.55.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
author Acked-by Titouan Christophe on v1 3/3
#6 lore raw

Re: [Buildroot] [PATCH 3/3] utils/checkpackagelib: check IGNORE_CVES identifiers match patch trailers

Hi Thomas and all,

Quoted 16 lines · Thomas Perale

The ability to check with make check-package the 'IGNORE_CVES' variable content reference an existing patches was added in commit [1].

This commit extend it to actually check that the entries that are referenced in the 'IGNORE_CVES' variable are matching the trailers in the referenced patch.

With this change the following foo.mk content:

```
FOO_IGNORE_CVES += CVE-2000-1234
```

Running make check-package will output an error if the content of the patch is the following:

Quoted 7 lines
```
CVE: CVE-2001-1234
```

[1] b00ac4e346 utils/checkpackagelib: add new check MissingCVEPatch

Quoted 94 lines
---
  utils/checkpackagelib/lib_mk.py      | 25 +++++++++++++++++++---
  utils/checkpackagelib/test_lib_mk.py | 32 ++++++++++++++++++++++++++++
  2 files changed, 54 insertions(+), 3 deletions(-)
utils/checkpackagelib/lib_mk.py +22 -3
index c5b85bcda9..33988cab8b 100644
@@ -120,12 +120,14 @@ class Indent(_CheckFunction):
 
  class MissingCVEPatch(_CheckFunction):
      PATCH_COMMENT = re.compile(r"^#\s*(\S+\.patch)\s*$")
-    IGNORE_CVES = re.compile(r"^[A-Z0-9_]+_IGNORE_CVES\s*\+?=")
+    IGNORE_CVES = re.compile(r"^[A-Z0-9_]+_IGNORE_CVES\s*\+?=\s*(.*)$")
      CVE_TAG_IN_PATCH = "CVE: "
 
      def before(self):
          self.pending_patches = []
+        self.pending_cves = []
          self.package_dir = Path(self.filename).parent
+        self.line_continuation = False
 
      def check_patch_files(self):
          for patch_lineno, patch_name, patch_text in self.pending_patches:
@@ -146,6 +148,11 @@ class MissingCVEPatch(_CheckFunction):
                          .format(self.filename, patch_name),
                          patch_text]
 
+            if set(self.pending_cves) != set(trailers):
+                return ["{}: patch file '{}' 'CVE:' tag(s) '{}' does not match the ignored identifier(s) '{}'"
+                        .format(self.filename, patch_name, ", ".join(trailers), ", ".join(self.pending_cves)),
+                        patch_text]
+
      def check_line(self, lineno, text):
          m = self.PATCH_COMMENT.match(text.rstrip())
          if m:
@@ -157,9 +164,21 @@ class MissingCVEPatch(_CheckFunction):
          if text.lstrip().startswith("#"):
              return
 
-        if self.IGNORE_CVES.search(text):
-            return self.check_patch_files()
+        m = self.IGNORE_CVES.search(text)
+        if m or self.line_continuation:
+            value = (m.group(1) if m else text).rstrip()
+            self.line_continuation = value.endswith("\\")
+            if self.line_continuation:
+                value = value[:-1]
+            self.pending_cves += value.split()
+            if self.line_continuation:
+                return
+            result = self.check_patch_files()
+            self.pending_cves = []
+            self.pending_patches = []
+            return result
 
+        self.pending_cves = []
          self.pending_patches = []
 
 
utils/checkpackagelib/test_lib_mk.py +25 -0
index ba9dbd6aea..7152b40e2b 100644
@@ -244,6 +244,38 @@ MissingCVEPatch = [
       '# 0001-some-fix.patch\n'
       'FOO_IGNORE_CVES += GHSA-abcd-1234-efgh\n',
       []),
+    ('CVE tag does not match ignored identifier',
+     {'0001-some-fix.patch': 'CVE: CVE-2000-1234'},
+     '# 0001-some-fix.patch\n'
+     'FOO_IGNORE_CVES += CVE-2001-1234\n',
+     [['{}: patch file \'0001-some-fix.patch\' \'CVE:\' tag(s) \'CVE-2000-1234\' '
+       'does not match the ignored identifier(s) \'CVE-2001-1234\'',
+       '# 0001-some-fix.patch\n']]),
+    ('multiple ignored identifiers, patch matches one',
+     {'0001-some-fix.patch': 'CVE: CVE-2000-1234'},
+     '# 0001-some-fix.patch\n'
+     'FOO_IGNORE_CVES += CVE-2000-1234 CVE-2001-1234\n',
+     [['{}: patch file \'0001-some-fix.patch\' \'CVE:\' tag(s) \'CVE-2000-1234\' '
+       'does not match the ignored identifier(s) \'CVE-2000-1234, CVE-2001-1234\'',
+       '# 0001-some-fix.patch\n']]),
+    ('multiple ignored identifiers, all referenced across patch',
+     {'0001-some-fix.patch': 'CVE: CVE-2000-1234\nCVE: CVE-2001-1234\n'},
+     '# 0001-some-fix.patch\n'
+     'FOO_IGNORE_CVES += CVE-2000-1234 CVE-2001-1234\n',
+     []),
+    ('multiple ignored identifiers, all referenced across multiple patches',
+     {'0001-some-fix.patch': 'CVE: CVE-2000-1234\nCVE: CVE-2001-1234',
+      '0002-other-fix.patch': 'CVE: CVE-2000-1234\nCVE: CVE-2001-1234'},
+     '# 0001-some-fix.patch\n'
+     '# 0002-other-fix.patch\n'
+     'FOO_IGNORE_CVES += CVE-2000-1234 CVE-2001-1234\n',

utils/checkpackagelib/test_lib_mk.py MissingCVEPatch = [ · line 281

Quoted 10 lines
utils/checkpackagelib/test_lib_mk.py +7 -0
+     []),
+    ('ignored identifiers split across continuation lines',
+     {'0001-some-fix.patch': 'CVE: CVE-2000-1234\nCVE: CVE-2001-1234\n'},
+     '# 0001-some-fix.patch\n'
+     'FOO_IGNORE_CVES += CVE-2000-1234 \\\n'
+     '\tCVE-2001-1234\n',
+     []),
      ]
 
 

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#7 lore raw

Re: [Buildroot] [PATCH 3/3] utils/checkpackagelib: check IGNORE_CVES identifiers match patch trailers

In reply to Thomas Perale via buildroot
Quoted 16 lines · Thomas Perale via buildroot

The ability to check with make check-package the 'IGNORE_CVES' variable content reference an existing patches was added in commit [1].

This commit extend it to actually check that the entries that are referenced in the 'IGNORE_CVES' variable are matching the trailers in the referenced patch.

With this change the following foo.mk content:

```
FOO_IGNORE_CVES += CVE-2000-1234
```

Running make check-package will output an error if the content of the patch is the following:

Quoted 7 lines
```
CVE: CVE-2001-1234
```

[1] b00ac4e346 utils/checkpackagelib: add new check MissingCVEPatch

Applied to master, thanks!

Regards,
Arnout

Quoted 106 lines
---
 utils/checkpackagelib/lib_mk.py      | 25 +++++++++++++++++++---
 utils/checkpackagelib/test_lib_mk.py | 32 ++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+), 3 deletions(-)
utils/checkpackagelib/lib_mk.py +22 -3
index c5b85bcda9..33988cab8b 100644
@@ -120,12 +120,14 @@ class Indent(_CheckFunction):
 
 class MissingCVEPatch(_CheckFunction):
     PATCH_COMMENT = re.compile(r"^#\s*(\S+\.patch)\s*$")
-    IGNORE_CVES = re.compile(r"^[A-Z0-9_]+_IGNORE_CVES\s*\+?=")
+    IGNORE_CVES = re.compile(r"^[A-Z0-9_]+_IGNORE_CVES\s*\+?=\s*(.*)$")
     CVE_TAG_IN_PATCH = "CVE: "
 
     def before(self):
         self.pending_patches = []
+        self.pending_cves = []
         self.package_dir = Path(self.filename).parent
+        self.line_continuation = False
 
     def check_patch_files(self):
         for patch_lineno, patch_name, patch_text in self.pending_patches:
@@ -146,6 +148,11 @@ class MissingCVEPatch(_CheckFunction):
                         .format(self.filename, patch_name),
                         patch_text]
 
+            if set(self.pending_cves) != set(trailers):
+                return ["{}: patch file '{}' 'CVE:' tag(s) '{}' does not match the ignored identifier(s) '{}'"
+                        .format(self.filename, patch_name, ", ".join(trailers), ", ".join(self.pending_cves)),
+                        patch_text]
+
     def check_line(self, lineno, text):
         m = self.PATCH_COMMENT.match(text.rstrip())
         if m:
@@ -157,9 +164,21 @@ class MissingCVEPatch(_CheckFunction):
         if text.lstrip().startswith("#"):
             return
 
-        if self.IGNORE_CVES.search(text):
-            return self.check_patch_files()
+        m = self.IGNORE_CVES.search(text)
+        if m or self.line_continuation:
+            value = (m.group(1) if m else text).rstrip()
+            self.line_continuation = value.endswith("\\")
+            if self.line_continuation:
+                value = value[:-1]
+            self.pending_cves += value.split()
+            if self.line_continuation:
+                return
+            result = self.check_patch_files()
+            self.pending_cves = []
+            self.pending_patches = []
+            return result
 
+        self.pending_cves = []
         self.pending_patches = []
 
 
utils/checkpackagelib/test_lib_mk.py +32 -0
index ba9dbd6aea..7152b40e2b 100644
@@ -244,6 +244,38 @@ MissingCVEPatch = [
      '# 0001-some-fix.patch\n'
      'FOO_IGNORE_CVES += GHSA-abcd-1234-efgh\n',
      []),
+    ('CVE tag does not match ignored identifier',
+     {'0001-some-fix.patch': 'CVE: CVE-2000-1234'},
+     '# 0001-some-fix.patch\n'
+     'FOO_IGNORE_CVES += CVE-2001-1234\n',
+     [['{}: patch file \'0001-some-fix.patch\' \'CVE:\' tag(s) \'CVE-2000-1234\' '
+       'does not match the ignored identifier(s) \'CVE-2001-1234\'',
+       '# 0001-some-fix.patch\n']]),
+    ('multiple ignored identifiers, patch matches one',
+     {'0001-some-fix.patch': 'CVE: CVE-2000-1234'},
+     '# 0001-some-fix.patch\n'
+     'FOO_IGNORE_CVES += CVE-2000-1234 CVE-2001-1234\n',
+     [['{}: patch file \'0001-some-fix.patch\' \'CVE:\' tag(s) \'CVE-2000-1234\' '
+       'does not match the ignored identifier(s) \'CVE-2000-1234, CVE-2001-1234\'',
+       '# 0001-some-fix.patch\n']]),
+    ('multiple ignored identifiers, all referenced across patch',
+     {'0001-some-fix.patch': 'CVE: CVE-2000-1234\nCVE: CVE-2001-1234\n'},
+     '# 0001-some-fix.patch\n'
+     'FOO_IGNORE_CVES += CVE-2000-1234 CVE-2001-1234\n',
+     []),
+    ('multiple ignored identifiers, all referenced across multiple patches',
+     {'0001-some-fix.patch': 'CVE: CVE-2000-1234\nCVE: CVE-2001-1234',
+      '0002-other-fix.patch': 'CVE: CVE-2000-1234\nCVE: CVE-2001-1234'},
+     '# 0001-some-fix.patch\n'
+     '# 0002-other-fix.patch\n'
+     'FOO_IGNORE_CVES += CVE-2000-1234 CVE-2001-1234\n',
+     []),
+    ('ignored identifiers split across continuation lines',
+     {'0001-some-fix.patch': 'CVE: CVE-2000-1234\nCVE: CVE-2001-1234\n'},
+     '# 0001-some-fix.patch\n'
+     'FOO_IGNORE_CVES += CVE-2000-1234 \\\n'
+     '\tCVE-2001-1234\n',
+     []),
     ]
 
 
Signature · 1 line
2.55.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#8 lore raw

Re: [Buildroot] [PATCH 3/3] utils/checkpackagelib: check IGNORE_CVES identifiers match patch trailers

In reply to Thomas Perale via buildroot

In reply of:

Quoted 16 lines

The ability to check with make check-package the 'IGNORE_CVES' variable content reference an existing patches was added in commit [1].

This commit extend it to actually check that the entries that are referenced in the 'IGNORE_CVES' variable are matching the trailers in the referenced patch.

With this change the following foo.mk content:

```
FOO_IGNORE_CVES += CVE-2000-1234
```

Running make check-package will output an error if the content of the patch is the following:

Quoted 8 lines
```
CVE: CVE-2001-1234
```

[1] b00ac4e346 utils/checkpackagelib: add new check MissingCVEPatch

Applied to 2025.02.x, 2026.08.x. Thanks

Quoted 94 lines
---
 utils/checkpackagelib/lib_mk.py      | 25 +++++++++++++++++++---
 utils/checkpackagelib/test_lib_mk.py | 32 ++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+), 3 deletions(-)
utils/checkpackagelib/lib_mk.py +22 -3
index c5b85bcda9..33988cab8b 100644
@@ -120,12 +120,14 @@ class Indent(_CheckFunction):
 
 class MissingCVEPatch(_CheckFunction):
     PATCH_COMMENT = re.compile(r"^#\s*(\S+\.patch)\s*$")
-    IGNORE_CVES = re.compile(r"^[A-Z0-9_]+_IGNORE_CVES\s*\+?=")
+    IGNORE_CVES = re.compile(r"^[A-Z0-9_]+_IGNORE_CVES\s*\+?=\s*(.*)$")
     CVE_TAG_IN_PATCH = "CVE: "
 
     def before(self):
         self.pending_patches = []
+        self.pending_cves = []
         self.package_dir = Path(self.filename).parent
+        self.line_continuation = False
 
     def check_patch_files(self):
         for patch_lineno, patch_name, patch_text in self.pending_patches:
@@ -146,6 +148,11 @@ class MissingCVEPatch(_CheckFunction):
                         .format(self.filename, patch_name),
                         patch_text]
 
+            if set(self.pending_cves) != set(trailers):
+                return ["{}: patch file '{}' 'CVE:' tag(s) '{}' does not match the ignored identifier(s) '{}'"
+                        .format(self.filename, patch_name, ", ".join(trailers), ", ".join(self.pending_cves)),
+                        patch_text]
+
     def check_line(self, lineno, text):
         m = self.PATCH_COMMENT.match(text.rstrip())
         if m:
@@ -157,9 +164,21 @@ class MissingCVEPatch(_CheckFunction):
         if text.lstrip().startswith("#"):
             return
 
-        if self.IGNORE_CVES.search(text):
-            return self.check_patch_files()
+        m = self.IGNORE_CVES.search(text)
+        if m or self.line_continuation:
+            value = (m.group(1) if m else text).rstrip()
+            self.line_continuation = value.endswith("\\")
+            if self.line_continuation:
+                value = value[:-1]
+            self.pending_cves += value.split()
+            if self.line_continuation:
+                return
+            result = self.check_patch_files()
+            self.pending_cves = []
+            self.pending_patches = []
+            return result
 
+        self.pending_cves = []
         self.pending_patches = []
 
 
utils/checkpackagelib/test_lib_mk.py +25 -0
index ba9dbd6aea..7152b40e2b 100644
@@ -244,6 +244,38 @@ MissingCVEPatch = [
      '# 0001-some-fix.patch\n'
      'FOO_IGNORE_CVES += GHSA-abcd-1234-efgh\n',
      []),
+    ('CVE tag does not match ignored identifier',
+     {'0001-some-fix.patch': 'CVE: CVE-2000-1234'},
+     '# 0001-some-fix.patch\n'
+     'FOO_IGNORE_CVES += CVE-2001-1234\n',
+     [['{}: patch file \'0001-some-fix.patch\' \'CVE:\' tag(s) \'CVE-2000-1234\' '
+       'does not match the ignored identifier(s) \'CVE-2001-1234\'',
+       '# 0001-some-fix.patch\n']]),
+    ('multiple ignored identifiers, patch matches one',
+     {'0001-some-fix.patch': 'CVE: CVE-2000-1234'},
+     '# 0001-some-fix.patch\n'
+     'FOO_IGNORE_CVES += CVE-2000-1234 CVE-2001-1234\n',
+     [['{}: patch file \'0001-some-fix.patch\' \'CVE:\' tag(s) \'CVE-2000-1234\' '
+       'does not match the ignored identifier(s) \'CVE-2000-1234, CVE-2001-1234\'',
+       '# 0001-some-fix.patch\n']]),
+    ('multiple ignored identifiers, all referenced across patch',
+     {'0001-some-fix.patch': 'CVE: CVE-2000-1234\nCVE: CVE-2001-1234\n'},
+     '# 0001-some-fix.patch\n'
+     'FOO_IGNORE_CVES += CVE-2000-1234 CVE-2001-1234\n',
+     []),
+    ('multiple ignored identifiers, all referenced across multiple patches',
+     {'0001-some-fix.patch': 'CVE: CVE-2000-1234\nCVE: CVE-2001-1234',
+      '0002-other-fix.patch': 'CVE: CVE-2000-1234\nCVE: CVE-2001-1234'},
+     '# 0001-some-fix.patch\n'
+     '# 0002-other-fix.patch\n'
+     'FOO_IGNORE_CVES += CVE-2000-1234 CVE-2001-1234\n',

utils/checkpackagelib/test_lib_mk.py MissingCVEPatch = [ · line 281

Quoted 10 lines
utils/checkpackagelib/test_lib_mk.py +7 -0
+     []),
+    ('ignored identifiers split across continuation lines',
+     {'0001-some-fix.patch': 'CVE: CVE-2000-1234\nCVE: CVE-2001-1234\n'},
+     '# 0001-some-fix.patch\n'
+     'FOO_IGNORE_CVES += CVE-2000-1234 \\\n'
+     '\tCVE-2001-1234\n',
+     []),
     ]
 
 

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

author Acked-by Titouan Christophe on v1 1/3
#9 lore raw
In reply to Thomas Perale via buildroot

Hello Thomas,

Quoted 4 lines · Thomas Perale

The self.pending_patch is set but unused.

Fixes b00ac4e346 utils/checkpackagelib: add new check MissingCVEPatch
Quoted 9 lines
---
  utils/checkpackagelib/lib_mk.py | 1 -
  1 file changed, 1 deletion(-)
utils/checkpackagelib/lib_mk.py +0 -0
index eb5fbf474c..065733d464 100644

utils/checkpackagelib/lib_mk.py class MissingCVEPatch(_CheckFunction): · line 135

Quoted 7 lines
utils/checkpackagelib/lib_mk.py +0 -1
@@ -130,7 +130,6 @@ class MissingCVEPatch(_CheckFunction):
      def check_patch_files(self):
          for patch_lineno, patch_name, patch_text in self.pending_patches:
              patch_file = self.package_dir / patch_name
-            self.pending_patch = None
 
              if not patch_file.is_file():
                  return ["{}:{}: patch file '{}' mentioned for ignored CVEs is missing"

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#10 lore raw
In reply to Thomas Perale via buildroot
Quoted 4 lines · Thomas Perale via buildroot

The self.pending_patch is set but unused.

Fixes b00ac4e346 utils/checkpackagelib: add new check MissingCVEPatch

Applied to master, thanks!

Regards,
Arnout

Quoted 18 lines
---
 utils/checkpackagelib/lib_mk.py | 1 -
 1 file changed, 1 deletion(-)
utils/checkpackagelib/lib_mk.py +0 -1
index eb5fbf474c..065733d464 100644
@@ -130,7 +130,6 @@ class MissingCVEPatch(_CheckFunction):
     def check_patch_files(self):
         for patch_lineno, patch_name, patch_text in self.pending_patches:
             patch_file = self.package_dir / patch_name
-            self.pending_patch = None
 
             if not patch_file.is_file():
                 return ["{}:{}: patch file '{}' mentioned for ignored CVEs is missing"
Signature · 1 line
2.55.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#11 lore raw
In reply to Thomas Perale via buildroot

In reply of:

Quoted 5 lines

The self.pending_patch is set but unused.

Fixes b00ac4e346 utils/checkpackagelib: add new check MissingCVEPatch

Applied to 2025.02.x, 2026.08.x. Thanks

Quoted 9 lines
---
 utils/checkpackagelib/lib_mk.py | 1 -
 1 file changed, 1 deletion(-)
utils/checkpackagelib/lib_mk.py +0 -0
index eb5fbf474c..065733d464 100644

utils/checkpackagelib/lib_mk.py class MissingCVEPatch(_CheckFunction): · line 135

Quoted 7 lines
utils/checkpackagelib/lib_mk.py +0 -1
@@ -130,7 +130,6 @@ class MissingCVEPatch(_CheckFunction):
     def check_patch_files(self):
         for patch_lineno, patch_name, patch_text in self.pending_patches:
             patch_file = self.package_dir / patch_name
-            self.pending_patch = None
 
             if not patch_file.is_file():
                 return ["{}:{}: patch file '{}' mentioned for ignored CVEs is missing"

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot