Skip to content

Revert verified urls #15874

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 27, 2024
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
32 changes: 0 additions & 32 deletions tests/unit/packaging/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -758,38 +758,6 @@ def test_trusted_published_all(self, db_session):

assert release.trusted_published

@pytest.mark.parametrize(
"url, publisher_url, expected",
[
("xpto.com", "https://pub/url/", False), # Totally different
("https://pub/", "https://pub/url/", False), # Missing parts
("https://pub/url/", "https://pub/url/", True), # Exactly the same
("https://pub/url/blah.md", "https://pub/url/", True), # Additonal parts
("https://pub/url", "https://pub/url/", True), # Missing trailing slash
("https://pub/url/", "https://pub/url", True), # Extratrailing slash
],
)
def test_is_url_verified(self, db_session, url, publisher_url, expected):
project = DBProjectFactory.create()
release = DBReleaseFactory.create(project=project)
release_file = DBFileFactory.create(
release=release,
filename=f"{release.project.name}-{release.version}.tar.gz",
python_version="source",
)
DBFileEventFactory.create(
source=release_file,
tag="fake:event",
additional={"publisher_url": publisher_url},
)
DBFileEventFactory.create(
source=release_file,
tag="fake:event",
additional={"publisher_url": publisher_url},
)

assert project.is_verified_url(url) is expected

def test_trusted_published_mixed(self, db_session):
release = DBReleaseFactory.create()
rfile_1 = DBFileFactory.create(
Expand Down
51 changes: 25 additions & 26 deletions warehouse/locale/messages.pot
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ msgstr ""
#: warehouse/templates/includes/accounts/profile-actions.html:30
#: warehouse/templates/includes/accounts/profile-callout.html:18
#: warehouse/templates/includes/hash-modal.html:23
#: warehouse/templates/includes/packaging/project-data.html:125
#: warehouse/templates/includes/packaging/project-data.html:106
#: warehouse/templates/index.html:100 warehouse/templates/index.html:104
#: warehouse/templates/manage/account.html:228
#: warehouse/templates/manage/account.html:234
Expand Down Expand Up @@ -3077,48 +3077,47 @@ msgstr ""
msgid "Members"
msgstr ""

#: warehouse/templates/includes/packaging/project-data.html:27
#: warehouse/templates/includes/packaging/project-data.html:16
msgid "Verified details"
msgstr ""

#: warehouse/templates/includes/packaging/project-data.html:30
#: warehouse/templates/includes/packaging/project-data.html:73
msgid "Project links"
msgstr ""

#: warehouse/templates/includes/packaging/project-data.html:52
#: warehouse/templates/includes/packaging/project-data.html:31
msgid "Maintainers"
msgstr ""

#: warehouse/templates/includes/packaging/project-data.html:54
#: warehouse/templates/includes/packaging/project-data.html:33
msgid "Avatar for {username} from gravatar.com"
msgstr ""

#: warehouse/templates/includes/packaging/project-data.html:70
#: warehouse/templates/includes/packaging/project-data.html:49
msgid "Unverified details"
msgstr ""

#: warehouse/templates/includes/packaging/project-data.html:85
#: warehouse/templates/includes/packaging/project-data.html:52
msgid "Project links"
msgstr ""

#: warehouse/templates/includes/packaging/project-data.html:66
msgid "GitHub Statistics"
msgstr ""

#: warehouse/templates/includes/packaging/project-data.html:93
#: warehouse/templates/includes/packaging/project-data.html:74
msgid "Stars:"
msgstr ""

#: warehouse/templates/includes/packaging/project-data.html:101
#: warehouse/templates/includes/packaging/project-data.html:82
msgid "Forks:"
msgstr ""

#: warehouse/templates/includes/packaging/project-data.html:109
#: warehouse/templates/includes/packaging/project-data.html:90
msgid "Open issues:"
msgstr ""

#: warehouse/templates/includes/packaging/project-data.html:117
#: warehouse/templates/includes/packaging/project-data.html:98
msgid "Open PRs:"
msgstr ""

#: warehouse/templates/includes/packaging/project-data.html:125
#: warehouse/templates/includes/packaging/project-data.html:106
#, python-format
msgid ""
"View statistics for this project via <a href=\"%(libs_io_href)s\" "
Expand All @@ -3127,38 +3126,38 @@ msgid ""
"rel=\"noopener\">our public dataset on Google BigQuery</a>"
msgstr ""

#: warehouse/templates/includes/packaging/project-data.html:132
#: warehouse/templates/includes/packaging/project-data.html:113
msgid "Meta"
msgstr ""

#: warehouse/templates/includes/packaging/project-data.html:134
#: warehouse/templates/includes/packaging/project-data.html:115
msgid "License:"
msgstr ""

#: warehouse/templates/includes/packaging/project-data.html:137
#: warehouse/templates/includes/packaging/project-data.html:139
#: warehouse/templates/includes/packaging/project-data.html:118
#: warehouse/templates/includes/packaging/project-data.html:120
msgid "Author:"
msgstr ""

#: warehouse/templates/includes/packaging/project-data.html:142
#: warehouse/templates/includes/packaging/project-data.html:144
#: warehouse/templates/includes/packaging/project-data.html:123
#: warehouse/templates/includes/packaging/project-data.html:125
#: warehouse/templates/pages/help.html:610
msgid "Maintainer:"
msgstr ""

#: warehouse/templates/includes/packaging/project-data.html:149
#: warehouse/templates/includes/packaging/project-data.html:130
msgid "Tags"
msgstr ""

#: warehouse/templates/includes/packaging/project-data.html:159
#: warehouse/templates/includes/packaging/project-data.html:140
msgid "Requires:"
msgstr ""

#: warehouse/templates/includes/packaging/project-data.html:164
#: warehouse/templates/includes/packaging/project-data.html:145
msgid "Provides-Extra:"
msgstr ""

#: warehouse/templates/includes/packaging/project-data.html:172
#: warehouse/templates/includes/packaging/project-data.html:153
#: warehouse/templates/pages/classifiers.html:16
#: warehouse/templates/pages/classifiers.html:21
#: warehouse/templates/pages/sitemap.html:39
Expand Down
18 changes: 0 additions & 18 deletions warehouse/packaging/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
Text,
UniqueConstraint,
func,
literal,
or_,
orm,
sql,
Expand Down Expand Up @@ -400,23 +399,6 @@ def latest_version(self):
.first()
)

def is_verified_url(self, url):
url = url.rstrip("/") + "/" # Ensure a single trailing slash
return (
orm.object_session(self)
.query(File.Event)
.join(File)
.join(Release)
.join(Project)
.filter(Project.id == self.id)
.filter(
literal(url).ilike(
File.Event.additional.op("->>")("publisher_url") + "%"
)
)
.first()
) is not None


class DependencyKind(enum.IntEnum):
requires = 1
Expand Down
27 changes: 4 additions & 23 deletions warehouse/templates/includes/packaging/project-data.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,9 @@
# limitations under the License.
-#}

{% set verified_urls, unverified_urls = [],[] %}
{% for name, url in release.urls.items() %}
{% if is_valid_uri(url) %}
{% if name in ["Source", "Homepage", "Issues"] and project.is_verified_url(url) %}
{{ verified_urls.append((name, url)) or "" }}
{% else %}
{{ unverified_urls.append((name, url)) or "" }}
{% endif %}
{% endif %}
{% endfor %}

<div class="sidebar-section verified">
<h3 class="sidebar-section__title">{% trans %}Verified details{% endtrans %}</h3>
<small><i>These details have been verified by PyPI</i></small>
{% if verified_urls %}
<h6>{% trans %}Project links{% endtrans %}</h6>
{% for name, url in verified_urls %}
<li>
<a class="vertical-tabs__tab vertical-tabs__tab--with-icon vertical-tabs__tab--condensed" href="{{ url }}" rel="nofollow">
{{ url_icon(name, url) }}{{ name }} <i class="fa fa-circle-check check"></i>
</a>
</li>
{% endfor %}
{% endif %}
{% if project.organization %}
<h6>Owner</h6>
<span class="sidebar-section__maintainer">
Expand Down Expand Up @@ -69,15 +48,17 @@ <h6>{% trans %}Maintainers{% endtrans %}</h6>
<div class="sidebar-section verified">
<h3 class="sidebar-section__title">{% trans %}Unverified details{% endtrans %}</h3>
<small><i>These details have <b>not</b> been verified by PyPI</i></small>
{% if unverified_urls %}
{% if release.urls.values() | contains_valid_uris %}
<h6>{% trans %}Project links{% endtrans %}</h6>
<ul class="vertical-tabs__list">
{% for name, url in unverified_urls %}
{% for name, url in release.urls.items() %}
{% if is_valid_uri(url) %}
<li>
<a class="vertical-tabs__tab vertical-tabs__tab--with-icon vertical-tabs__tab--condensed" href="{{ url }}" rel="nofollow">
{{ url_icon(name, url) }}{{ name }}
</a>
</li>
{% endif %}
{% endfor %}
</ul>
{% endif %}
Expand Down
Loading