Skip to content
Open
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
2 changes: 1 addition & 1 deletion guarddog/analyzer/metadata/pypi/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
def get_email_addresses(package_info: dict) -> set[str]:
info = package_info.get("info", {})

return {info.get("author_email") or info.get("maintainer_email")} - {None}
return {info.get("author_email"), info.get("maintainer_email")} - {None, ""}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Parse PyPI email fields before returning them

PyPI core metadata allows Author-email and Maintainer-email to contain multiple comma-separated RFC-822 addresses (spec). Returning each raw field as one set entry means the shared detectors pass a value like maintainer_email='expired@old.tld, owner@gmail.com' to extract_email_address_domain(), which only examines the text after the last @; in that valid metadata shape, the newly included maintainer address with the expired domain is ignored. Parse these fields into individual addresses before returning the set.

Useful? React with 👍 / 👎.

17 changes: 17 additions & 0 deletions tests/analyzer/metadata/test_pypi_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from guarddog.analyzer.metadata.pypi.utils import get_email_addresses


def test_get_email_addresses_returns_both_author_and_maintainer():
package_info = {
"info": {
"author_email": "realdev@example.com",
"maintainer_email": "maintainer@example.org",
}
}
emails = get_email_addresses(package_info)
assert emails == {"realdev@example.com", "maintainer@example.org"}


def test_get_email_addresses_drops_none_and_empty():
package_info = {"info": {"author_email": "realdev@example.com", "maintainer_email": ""}}
assert get_email_addresses(package_info) == {"realdev@example.com"}