Skip to content

Close GHSAs when the associated CVE has a patch (#54) - #70

Merged
sethmlarson merged 5 commits into
python:mainfrom
brettcs:close-ghsa-on-cve-patch
Nov 3, 2026
Merged

sethmlarson merged 5 commits into
python:mainfrom
brettcs:close-ghsa-on-cve-patch

Conversation

@brettcs

@brettcs brettcs commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

This implements the requested feature. It tries to be efficient about it, only requesting CVEs when a draft GHSA already has one.

I could add a lot more tests for the new iterator function itself as well as different shapes of input data. The current tests don't seem to strive for that much coverage, so I've stopped here, but I'm very open to feedback about more you would or wouldn't like to see.

@brettcs

brettcs commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

@sethmlarson Please take a look.

@sethmlarson sethmlarson left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks! Some thoughts for you:

Comment thread src/psrt_ghsa_bot/app.py Resolved
Comment thread src/psrt_ghsa_bot/app.py Resolved
Comment thread src/psrt_ghsa_bot/app.py Resolved
Comment thread src/psrt_ghsa_bot/app.py
try:
cve = cve_api.show_cve_record(cve_id)
cve_refs = cve["containers"]["cna"]["references"]
except KeyError, RequestFailed, TypeError:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Does this error out if the CVE ID is reserved but hasn't been published yet?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's a good question that I would probably need to play with the cvelib CLI to verify. The API docs don't say anything about the API being limited about what kinds of CVEs it returns, but basically every key lookup is optional and I don't know what reserved CVE records will actually look like.

I think what you're getting it is we should check both the CVE state and the existence of a patch? If that's right that sounds good to me too, I can make that change.

Comment thread tests/test_app.py
import datetime
import json
import operator
from collections import abc

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

same as above, we can drop the abc and use typing

Comment thread tests/test_app.py Resolved
Comment thread tests/test_app.py Resolved

@sethmlarson sethmlarson left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM, thank you!

@sethmlarson
sethmlarson merged commit ab1223b into python:main Nov 3, 2026
3 checks passed
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