Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/psrt_ghsa_bot/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@

PSRT_GITHUB_TEAM_ORG = "python"
PSRT_GITHUB_TEAM_SLUG = "psrt"
COMPLETION_TAGS = (
"CLOSE",
Comment thread
StanFromIreland marked this conversation as resolved.
"CLOSED",
"COMPLETE",
"COMPLETED",
"NOTPLANNED",
"INVALID",
"DUPLICATE",
)


def load_psrt_members_from_devguide() -> set[str]:
Expand Down Expand Up @@ -148,10 +157,9 @@ def apply_to_repo(

print(f" 📋 Processing {ghsa_id} (state: {state})")

# If the summary contains '[CLOSE]', '[CLOSED]', '[COMPLETE]',
# or '[COMPLETED]' then we can close the ticket.
# If the summary contains a completion tag then we can close the ticket.
summary = security_advisory.get("summary", "")
if re.search(r"\[(?:CLOSED?|COMPLETED?)\]", summary.upper()) is not None:
if re.search(rf"\[(?:{'|'.join(COMPLETION_TAGS)})\]", summary.upper()) is not None:
github.rest.security_advisories.update_repository_advisory(
owner=owner,
repo=repo,
Expand Down
5 changes: 4 additions & 1 deletion tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,12 @@ def test_create_private_fork() -> None:
"[COMPLETE] some boring security thing",
"fix soemthing in datetime module [COMPLETED]",
"blah blah [closed] lowercase blah",
"[NOTPLANNED] no fix planned",
"[INVALID] some annoying spam",
"[DUPLICATE] we've seen this one before",
],
)
def test_closes_advisory_with_close_or_complete_tag(summary) -> None:
def test_closes_advisory_with_completion_tag(summary) -> None:
security_advisory = _create_advisory_dict("triage", None, [], summary=summary)

github = mock.Mock()
Expand Down
Loading