Skip to content

Add optional CVE metadata for Security entries - #95

Open
StanFromIreland wants to merge 2 commits into
python:mainfrom
StanFromIreland:cve-identifier
Open

StanFromIreland wants to merge 2 commits into
python:mainfrom
StanFromIreland:cve-identifier

Conversation

@StanFromIreland

Copy link
Copy Markdown
Member

This recently came up on Discourse, CVEs are useful information for users, however they aren't always listed in the entries. The patch adds a special field for them, and support to render them beside the issue number in the changelog.

Comment thread src/blurb/_merge.py Outdated
body = f'bpo-{issue_number}: {body}'
prefix = f'bpo-{issue_number}'
if cve := metadata.get('cve'):
prefix = f'{prefix}, {cve}' if prefix else cve

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's do something like this to use the Sphinx :cve: role:

https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#role-cve

Suggested change
prefix = f'{prefix}, {cve}' if prefix else cve
cve_role = f':cve:`{cve.removeprefix("CVE-")}`'
prefix = f'{prefix}, {cve_role}' if prefix else cve_role

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Shall we put the CVE before the gh-number?

That's what we did at https://blog.python.org/2026/10/python-31022-31117/ and I think the CVE is more interesting for readers?

@StanFromIreland StanFromIreland Oct 18, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We can't add the role, it would break 3.11, as it uses an older version of Sphinx that does not support the role. I have a PR (python/cpython#159415) in CPython to add as part of our build process, like we do for the GitHub reference.

Comment thread src/blurb/_merge.py
Comment thread tests/test_merge.py Outdated
Comment thread src/blurb/_blurb_file.py
Comment on lines +202 to +203
if 'cve' in metadata and metadata.get('section') != cve_section:
throw(f"'cve:' may only be used in the {cve_section!r} section!")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We have sometimes included CVEs in non-security sections:

Should we not allow those? In those cases, should they have been under Security?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

IMO, from a distributor's perspective (though I've never worn that hat ;-)), it would have been clearer to put these in the Security section, since that's what prompted the update.

I'm also not entirely sure these should be marked with .. cve:, as my intention was to reserve that for CVEs we issue ourselves.

Comment thread src/blurb/_add.py Outdated
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants