Skip to content

remove initial attempt at squat detection #8807

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 1 commit into from
Nov 11, 2020
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
2 changes: 0 additions & 2 deletions tests/unit/admin/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,6 @@ def test_includeme():
),
pretend.call("admin.flags", "/admin/flags/", domain=warehouse),
pretend.call("admin.flags.edit", "/admin/flags/edit/", domain=warehouse),
pretend.call("admin.squats", "/admin/squats/", domain=warehouse),
pretend.call("admin.squats.review", "/admin/squats/review/", domain=warehouse),
pretend.call("admin.checks.list", "/admin/checks/", domain=warehouse),
pretend.call(
"admin.checks.detail", "/admin/checks/{check_name}", domain=warehouse
Expand Down
12 changes: 0 additions & 12 deletions tests/unit/admin/views/test_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import datetime
import uuid

import pretend
Expand Down Expand Up @@ -90,15 +89,6 @@ def test_gets_project(self, db_request):
[RoleFactory(project=project) for _ in range(5)],
key=lambda x: (x.role_name, x.user.username),
)
delta = datetime.timedelta(days=1)
squatter = ProjectFactory(
name=project.name[:-1], created=project.created + delta
)
squattee = ProjectFactory(
name=project.name[1:], created=project.created - delta
)
db_request.db.add(squatter)
db_request.db.add(squattee)
db_request.matchdict["project_name"] = str(project.normalized_name)
result = views.project_detail(project, db_request)

Expand All @@ -107,8 +97,6 @@ def test_gets_project(self, db_request):
"releases": [],
"maintainers": roles,
"journal": journals[:30],
"squatters": [squatter],
"squattees": [squattee],
"ONE_MB": views.ONE_MB,
"MAX_FILESIZE": views.MAX_FILESIZE,
"MAX_PROJECT_SIZE": views.MAX_PROJECT_SIZE,
Expand Down
47 changes: 0 additions & 47 deletions tests/unit/admin/views/test_squats.py

This file was deleted.

47 changes: 0 additions & 47 deletions tests/unit/forklift/test_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
from wtforms.validators import ValidationError

from warehouse.admin.flags import AdminFlag, AdminFlagValue
from warehouse.admin.squats import Squat
from warehouse.classifiers.models import Classifier
from warehouse.forklift import legacy
from warehouse.metrics import IMetricsService
Expand Down Expand Up @@ -3216,52 +3215,6 @@ def test_upload_succeeds_creates_project(self, pyramid_config, db_request, metri
),
]

def test_upload_succeeds_creates_squats(self, pyramid_config, db_request, metrics):
pyramid_config.testing_securitypolicy(userid=1)

squattee = ProjectFactory(name="example")
user = UserFactory.create()
EmailFactory.create(user=user)

filename = "{}-{}.tar.gz".format("exmaple", "1.0")

db_request.user = user
db_request.POST = MultiDict(
{
"metadata_version": "1.2",
"name": "exmaple",
"version": "1.0",
"filetype": "sdist",
"md5_digest": _TAR_GZ_PKG_MD5,
"content": pretend.stub(
filename=filename,
file=io.BytesIO(_TAR_GZ_PKG_TESTDATA),
type="application/tar",
),
}
)

storage_service = pretend.stub(store=lambda path, filepath, meta: None)
db_request.find_service = lambda svc, name=None, context=None: {
IFileStorage: storage_service,
IMetricsService: metrics,
}.get(svc)
db_request.user_agent = "warehouse-tests/6.6.6"

resp = legacy.file_upload(db_request)

assert resp.status_code == 200

# Ensure that a Project object has been created.
squatter = db_request.db.query(Project).filter(Project.name == "exmaple").one()

# Ensure that a Squat object has been created.
squat = db_request.db.query(Squat).one()

assert squat.squattee == squattee
assert squat.squatter == squatter
assert squat.reviewed is False

@pytest.mark.parametrize(
("emails_verified", "expected_success"),
[
Expand Down
4 changes: 0 additions & 4 deletions warehouse/admin/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,6 @@ def includeme(config):
config.add_route("admin.flags", "/admin/flags/", domain=warehouse)
config.add_route("admin.flags.edit", "/admin/flags/edit/", domain=warehouse)

# Squats
config.add_route("admin.squats", "/admin/squats/", domain=warehouse)
config.add_route("admin.squats.review", "/admin/squats/review/", domain=warehouse)

# Malware checks
config.add_route("admin.checks.list", "/admin/checks/", domain=warehouse)
config.add_route(
Expand Down
36 changes: 0 additions & 36 deletions warehouse/admin/squats.py

This file was deleted.

5 changes: 0 additions & 5 deletions warehouse/admin/templates/admin/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,6 @@
<i class="fa fa-flag"></i> <span>Flags</span>
</a>
</li>
<li>
<a href="{{ request.route_path('admin.squats') }}">
<i class="fa fa-dumbbell"></i> <span>Squats</span>
</a>
</li>
<li>
<a href="{{ request.route_path('admin.checks.list') }}">
<i class="fa fa-check"></i> <span>Checks</span>
Expand Down
53 changes: 0 additions & 53 deletions warehouse/admin/templates/admin/projects/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -275,59 +275,6 @@ <h3 class="box-title">Project activity</h3>
</div>
</div>

<div class="box box-secondary collapsed-box">
<div class="box-header with-border">
<h3 class="box-title">Squatting</h3>
<div class="box-tools">
<button class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip" title="Expand"><i class="fa fa-plus"></i></button>
</div>
</div>

{% if squatters %}
<div class="box-body box-squats">
<h4>Projects that might be squatting on this project:</h4>
<table class="table table-hover">
<tr>
<th>name</th>
<th>created</th>
</tr>
{% for project in squatters %}
<tr>
<td>
<a href="{{ request.route_path('admin.project.detail', project_name=project.normalized_name) }}">
{{ project.normalized_name }}
</a>
</td>
<td>{{ project.created }}</td>
</tr>
{% endfor %}
</table>
</div>
{% endif %}

{% if squattees %}
<div class="box-body box-squats">
<h4>Projects that this project might be squatting on:</h4>
<table class="table table-hover">
<tr>
<th>name</th>
<th>created</th>
</tr>
{% for project in squattees %}
<tr>
<td>
<a href="{{ request.route_path('admin.project.detail', project_name=project.normalized_name) }}">
{{ project.normalized_name }}
</a>
</td>
<td>{{ project.created }}</td>
</tr>
{% endfor %}
</table>
</div>
{% endif %}
</div>

<!-- Deletion form -->
{% include 'delete.html' %}

Expand Down
80 changes: 0 additions & 80 deletions warehouse/admin/templates/admin/squats/index.html

This file was deleted.

18 changes: 1 addition & 17 deletions warehouse/admin/views/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from paginate_sqlalchemy import SqlalchemyOrmPage as SQLAlchemyORMPage
from pyramid.httpexceptions import HTTPBadRequest, HTTPMovedPermanently, HTTPSeeOther
from pyramid.view import view_config
from sqlalchemy import func, or_
from sqlalchemy import or_
from sqlalchemy.orm import joinedload
from sqlalchemy.orm.exc import NoResultFound

Expand Down Expand Up @@ -121,27 +121,11 @@ def project_detail(project, request):
)
]

squattees = (
request.db.query(Project)
.filter(Project.created < project.created)
.filter(func.levenshtein(Project.normalized_name, project.normalized_name) <= 2)
.all()
)

squatters = (
request.db.query(Project)
.filter(Project.created > project.created)
.filter(func.levenshtein(Project.normalized_name, project.normalized_name) <= 2)
.all()
)

return {
"project": project,
"releases": releases,
"maintainers": maintainers,
"journal": journal,
"squatters": squatters,
"squattees": squattees,
"ONE_MB": ONE_MB,
"MAX_FILESIZE": MAX_FILESIZE,
"ONE_GB": ONE_GB,
Expand Down
Loading