utils/checkpackagelib: remove unused variable
PATCH 1/3 utils/checkpackagelib: remove unused variable
The self.pending_patch is set but unused.
--- utils/checkpackagelib/lib_mk.py | 1 - 1 file changed, 1 deletion(-)
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"
Signature · 6 lines
2.55.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
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
@@ -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
@@ -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
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-efghAnd 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:' tagWhile 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 theIGNORE_CVESvariable.
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]
1167d0ff3ddocs/manual: mention CVE trailerSigned-off-by Thomas Perale <[email protected]>
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@@ -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@@ -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
Re: [Buildroot] [PATCH 2/3] utils/checkpackagelib: support other identifiers than CVE
In reply to Thomas Perale via buildrootQuoted 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-efghAnd 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:' tagWhile 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_CVESvariable.
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]
1167d0ff3ddocs/manual: mention CVE trailerSigned-off-by Thomas Perale <[email protected]>
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
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
-1def 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@@ -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
Raphaël Mélotte via buildroot
AppliedRe: [Buildroot] [PATCH 2/3] utils/checkpackagelib: support other identifiers than CVE
In reply to Thomas Perale via buildrootIn 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-efghAnd 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:' tagWhile 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_CVESvariable.
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]
1167d0ff3ddocs/manual: mention CVE trailerSigned-off-by Thomas Perale <[email protected]>Reviewed-by Titouan Christophe <[email protected]>
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@@ -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@@ -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
PATCH 3/3 utils/checkpackagelib: check IGNORE_CVES identifiers match patch trailers
In reply to Thomas Perale via buildrootThe 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
@@ -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
@@ -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
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-packagethe '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.mkcontent:``` FOO_IGNORE_CVES += CVE-2000-1234 ```Running
make check-packagewill output an error if the content of the patch is the following:
Quoted 7 lines
``` CVE: CVE-2001-1234 ```[1]
b00ac4e346utils/checkpackagelib: add new check MissingCVEPatchSigned-off-by Thomas Perale <[email protected]>
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@@ -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@@ -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
Re: [Buildroot] [PATCH 3/3] utils/checkpackagelib: check IGNORE_CVES identifiers match patch trailers
In reply to Thomas Perale via buildrootQuoted 16 lines · Thomas Perale via buildroot
The ability to check with
make check-packagethe '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.mkcontent:``` FOO_IGNORE_CVES += CVE-2000-1234 ```Running
make check-packagewill output an error if the content of the patch is the following:
Quoted 7 lines
``` CVE: CVE-2001-1234 ```[1]
b00ac4e346utils/checkpackagelib: add new check MissingCVEPatchSigned-off-by Thomas Perale <[email protected]>
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@@ -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@@ -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
Raphaël Mélotte via buildroot
AppliedRe: [Buildroot] [PATCH 3/3] utils/checkpackagelib: check IGNORE_CVES identifiers match patch trailers
In reply to Thomas Perale via buildrootIn reply of:
Quoted 16 lines
The ability to check with
make check-packagethe '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.mkcontent:``` FOO_IGNORE_CVES += CVE-2000-1234 ```Running
make check-packagewill output an error if the content of the patch is the following:
Quoted 8 lines
``` CVE: CVE-2001-1234 ```[1]
b00ac4e346utils/checkpackagelib: add new check MissingCVEPatchSigned-off-by Thomas Perale <[email protected]>
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@@ -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@@ -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
Hello Thomas,
Quoted 4 lines · Thomas Perale
The
self.pending_patchis set but unused.Fixes b00ac4e346 utils/checkpackagelib: add new check MissingCVEPatchSigned-off-by Thomas Perale <[email protected]>
Quoted 9 lines
--- utils/checkpackagelib/lib_mk.py | 1 - 1 file changed, 1 deletion(-)utils/checkpackagelib/lib_mk.py +0
-0
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
Quoted 4 lines · Thomas Perale via buildroot
The
self.pending_patchis set but unused.Fixes b00ac4e346 utils/checkpackagelib: add new check MissingCVEPatchSigned-off-by Thomas Perale <[email protected]>
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@@ -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
Raphaël Mélotte via buildroot
AppliedIn reply of:
Quoted 5 lines
The
self.pending_patchis set but unused.Fixes b00ac4e346 utils/checkpackagelib: add new check MissingCVEPatchSigned-off-by Thomas Perale <[email protected]>
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
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