Skip to content

Conversation

@bmastbergen
Copy link
Collaborator

@bmastbergen bmastbergen commented Oct 14, 2025

Adds ability to verify that CVE references in PR commit messages correctly match the upstream commits they reference. Uses the kernel vulnerabilities database to cross-check CVE assignments against upstream commit hashes.

The --check-cves flag enables validation that detects three error conditions: mismatched CVE assignments between PR and upstream commits, CVE references to upstream commits with no CVE assignment, and failures accessing the vulnerabilities database. Output format matches existing checker patterns with support for both plain text and markdown modes.

Here is an example github comment from this code:
ctrliq/kernel-src-tree#616 (comment)

This was written by Claude BTW.

Copilot AI review requested due to automatic review settings October 14, 2025 14:33
@ciq-it-service-account
Copy link

ciq-it-service-account commented Oct 14, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request adds CVE verification functionality to the kernel commit checker, allowing validation that CVE references in PR commit messages correctly match their upstream counterparts. The change enables cross-referencing with the kernel vulnerabilities database to detect mismatched, missing, or invalid CVE assignments.

Key changes:

  • Adds --check-cves flag to enable CVE validation against the vulnerabilities database
  • Implements automatic cloning/updating of the kernel vulns repository
  • Integrates CVE information into existing bugfix detection output

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@bmastbergen bmastbergen requested a review from Copilot October 14, 2025 14:47
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@bmastbergen bmastbergen requested a review from Copilot October 14, 2025 15:07
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


def extract_cve_from_message(msg):
"""Extract CVE reference from commit message. Returns CVE ID or None.
Only matches 'cve CVE-2025-12345', ignores 'cve-bf' and 'cve-pre' variants."""
Copy link

Copilot AI Oct 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The docstring example uses CVE-2025-12345 which appears to be a future year. Consider using a more realistic example like CVE-2024-12345 or CVE-2023-12345.

Suggested change
Only matches 'cve CVE-2025-12345', ignores 'cve-bf' and 'cve-pre' variants."""
Only matches 'cve CVE-2024-12345', ignores 'cve-bf' and 'cve-pre' variants."""

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

@bmastbergen bmastbergen Oct 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The future is now copilot! Its 2025!

@bmastbergen bmastbergen requested a review from Copilot October 14, 2025 16:54
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

def extract_cve_from_message(msg):
"""Extract CVE reference from commit message. Returns CVE ID or None.
Only matches 'cve CVE-2025-12345', ignores 'cve-bf' and 'cve-pre' variants."""
match = re.search(r'(?<!\S)cve\s+(CVE-\d{4}-\d+)', msg, re.IGNORECASE)
Copy link

Copilot AI Oct 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The regex pattern uses a negative lookbehind (?<!\S) but the docstring mentions it ignores 'cve-bf' and 'cve-pre' variants. The current pattern would still match 'cve CVE-2025-12345' in 'somecve CVE-2025-12345'. Consider using word boundaries \\bcve\\s+ for clearer intent.

Suggested change
match = re.search(r'(?<!\S)cve\s+(CVE-\d{4}-\d+)', msg, re.IGNORECASE)
match = re.search(r'\bcve\s+(CVE-\d{4}-\d+)', msg, re.IGNORECASE)

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh Co-Pilot, your contexted didn't even follow the comment directly above which you also whined about.

PlaidCat
PlaidCat previously approved these changes Oct 17, 2025
Copy link
Collaborator

@PlaidCat PlaidCat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is too useful to block on a tree of if's

out_lines.append(' ' + line)
out_lines.append("") # blank line

# Check CVE if enabled
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really hate this tree of if statements.

Can we make a ticket to clean this up ... ideally as a part of python mock testing ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PlaidCat Yees, I fully agree with you! On my list to refactor this when I migrate to 'kt'

Copy link
Contributor

@roxanan1996 roxanan1996 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This script needs refactoring soon, as it becoming bigger and bigger but for now, it's fine.

One question: this does not cover the case where there are multiple commits upstream for a CVE but the pull requests does not include all of them, right?

@PlaidCat
Copy link
Collaborator

This script needs refactoring soon, as it becoming bigger and bigger but for now, it's fine.

One question: this does not cover the case where there are multiple commits upstream for a CVE but the pull requests does not include all of them, right?

Do you have an example of this since Kernel.org became the CNA.
I believe this is an artifact of the past when kernel.org had no control over CVEs cut against it.

it might be useful to some pre 2023 but we have no way of validating those within the kernel.org/vulns project (they're a bit of a mess)

Adds ability to verify that CVE references in PR commit messages correctly
match the upstream commits they reference. Uses the kernel vulnerabilities
database to cross-check CVE assignments against upstream commit hashes.

The --check-cves flag enables validation that detects three error conditions:
mismatched CVE assignments between PR and upstream commits, CVE references
to upstream commits with no CVE assignment, and failures accessing the
vulnerabilities database. Output format matches existing checker patterns
with support for both plain text and markdown modes.
@bmastbergen
Copy link
Collaborator Author

Addressed comments from @roxanan1996

I agree with both of you that this script could use some refactoring. Lets get it in and checking PRs then fix it up. Thanks!

@bmastbergen bmastbergen merged commit 66d35bd into mainline Oct 17, 2025
@bmastbergen bmastbergen deleted the ckc-add-cve-checking branch October 17, 2025 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

5 participants