-
Notifications
You must be signed in to change notification settings - Fork 1k
Add rudimentary verdicts view. Progress on #6062. #7207
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
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import uuid | ||
|
||
from random import randint | ||
|
||
import pretend | ||
import pytest | ||
|
||
from pyramid.httpexceptions import HTTPBadRequest, HTTPNotFound | ||
|
||
from warehouse.admin.views import verdicts as views | ||
|
||
from ....common.db.malware import MalwareVerdictFactory | ||
|
||
|
||
class TestListVerdicts: | ||
def test_none(self, db_request): | ||
assert views.get_verdicts(db_request) == {"verdicts": []} | ||
|
||
def test_some(self, db_request): | ||
verdicts = [MalwareVerdictFactory.create() for _ in range(10)] | ||
|
||
assert views.get_verdicts(db_request) == {"verdicts": verdicts} | ||
|
||
def test_some_with_multipage(self, db_request): | ||
verdicts = [MalwareVerdictFactory.create() for _ in range(60)] | ||
|
||
db_request.GET["page"] = "2" | ||
|
||
assert views.get_verdicts(db_request) == {"verdicts": verdicts[25:50]} | ||
|
||
def test_with_invalid_page(self): | ||
request = pretend.stub(params={"page": "not an integer"}) | ||
|
||
with pytest.raises(HTTPBadRequest): | ||
views.get_verdicts(request) | ||
|
||
|
||
class TestGetVerdict: | ||
def test_found(self, db_request): | ||
verdicts = [MalwareVerdictFactory.create() for _ in range(10)] | ||
index = randint(0, 9) | ||
lookup_id = verdicts[index].id | ||
db_request.matchdict["verdict_id"] = lookup_id | ||
|
||
assert views.get_verdict(db_request) == {"verdict": verdicts[index]} | ||
|
||
def test_not_found(self, db_request): | ||
db_request.matchdict["verdict_id"] = uuid.uuid4() | ||
|
||
with pytest.raises(HTTPNotFound): | ||
views.get_verdict(db_request) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
warehouse/admin/templates/admin/malware/verdicts/detail.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
{# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
-#} | ||
{% extends "admin/base.html" %} | ||
|
||
{% block title %}Verdict {{ verdict.id }}{% endblock %} | ||
|
||
{% block breadcrumb %} | ||
<li><a href="{{ request.route_path('admin.verdicts.list') }}">Verdicts</a></li> | ||
<li class="active">{{ verdict.id }}</li> | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<div class="box box-primary"> | ||
<div class="box-body box-profile"> | ||
<table class="table table-hover"> | ||
xmunoz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<tr> | ||
<th scope="row">Message</th> | ||
<td>{{ verdict.message }}</td> | ||
</tr> | ||
<tr> | ||
<th scope="row">Run Date</th> | ||
<td>{{ verdict.run_date }}</td> | ||
</tr> | ||
<tr> | ||
<th scope="row">Check</th> | ||
<td> | ||
<a href="{{ request.route_path('admin.checks.detail', check_name=verdict.check.name) }}"> | ||
{{ verdict.check.name }} v{{ verdict.check.version }} | ||
</a> | ||
</td> | ||
</tr> | ||
<tr> | ||
<th scope="row">Object</th> | ||
<td>{% include 'object_link.html' %}</td> | ||
</tr> | ||
<tr> | ||
<th scope="row">Verdict Classification</th> | ||
<td>{{ verdict.classification.value }}</td> | ||
</tr> | ||
<tr> | ||
<th scope="row">Verdict Confidence</th> | ||
<td>{{ verdict.confidence.value }}</td> | ||
</tr> | ||
<tr> | ||
<th scope="row">Manually Reviewed</th> | ||
<td>{{ verdict.manually_reviewed }}</td> | ||
</tr> | ||
{% if verdict.manually_reviewed %} | ||
<tr> | ||
<th scope="row">Administrator Verdict</th> | ||
<td>{{ verdict.administrator_verdict }}</td> | ||
</tr> | ||
{% endif %} | ||
{% if verdict.full_report_link %} | ||
<tr> | ||
<th scope="row">Full Report Link</th> | ||
<td>{{ verdict.full_report_link }}</td> | ||
</tr> | ||
{% endif %} | ||
{% if verdict.details %} | ||
<tr> | ||
<th scope="row">Details</th> | ||
<td><pre>{{ verdict.details|tojson(indent=4) }}</pre></td> | ||
</tr> | ||
{% endif %} | ||
</table> | ||
</div> | ||
</div> | ||
{% endblock %} |
93 changes: 93 additions & 0 deletions
93
warehouse/admin/templates/admin/malware/verdicts/index.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
{# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
-#} | ||
{% extends "admin/base.html" %} | ||
|
||
{% import "admin/utils/pagination.html" as pagination %} | ||
|
||
{% block title %}Malware Verdicts{% endblock %} | ||
|
||
{% block breadcrumb %} | ||
<li class="active">Verdicts</li> | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<div class="box box-primary"> | ||
<div class="box-body table-responsive no-padding"> | ||
<table class="table table-hover"> | ||
<tr> | ||
<th>Object</th> | ||
<th>Check</th> | ||
<th>Classification</th> | ||
<th>Confidence</th> | ||
<th>Detail</th> | ||
</tr> | ||
{% for verdict in verdicts %} | ||
<tr> | ||
<td>{% include 'object_link.html' %}</td> | ||
<td> | ||
<a href="{{ request.route_path('admin.checks.detail', check_name=verdict.check.name) }}"> | ||
{{ verdict.check.name }} v{{ verdict.check.version }} | ||
</a> | ||
</td> | ||
<td> | ||
xmunoz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<span title="{{ verdict.classification.value }}"> | ||
<i class="fa fa-exclamation"></i> | ||
{% if verdict.classification.value == 'indeterminate' %} | ||
<i class="fa fa-exclamation"></i> | ||
{% elif verdict.classification.value == 'threat' %} | ||
<i class="fa fa-exclamation"></i> | ||
<i class="fa fa-exclamation"></i> | ||
{% endif %} | ||
</span> | ||
</td> | ||
<td> | ||
<span title="{{ verdict.confidence.value }}"> | ||
<i class="fa fa-star"></i> | ||
{% if verdict.confidence.value == 'medium' %} | ||
<i class="fa fa-star"></i> | ||
{% elif verdict.confidence.value == 'high' %} | ||
<i class="fa fa-star"></i> | ||
<i class="fa fa-star"></i> | ||
{% endif %} | ||
</span> | ||
</td> | ||
<td> | ||
<a href="{{ request.route_path('admin.verdicts.detail', verdict_id=verdict.id) }}"> | ||
Detail | ||
</a> | ||
</td> | ||
</tr> | ||
{% else %} | ||
<tr> | ||
<td colspan="5"> | ||
<center> | ||
<i>No verdicts!</i> | ||
</center> | ||
</td> | ||
</tr> | ||
{% endfor %} | ||
</table> | ||
<div class="box-footer"> | ||
<div class="col-sm-5"> | ||
{{ pagination.summary(verdicts) }} | ||
</div> | ||
<div class="col-sm-7"> | ||
<div class="pull-right"> | ||
{{ pagination.paginate(verdicts) }} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock content %} |
21 changes: 21 additions & 0 deletions
21
warehouse/admin/templates/admin/malware/verdicts/object_link.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
-#} | ||
|
||
{% if verdict.project %} | ||
<a href="{{ request.route_path('admin.project.detail', project_name=verdict.project.normalized_name) }}"><i class="fa fa-cube"></i> {{ verdict.project.name }} </a> | ||
{% elif verdict.release %} | ||
<a href="{{ request.route_path('admin.project.release', project_name=verdict.release.project.normalized_name, version=verdict.release.version) }}"><i class="far fa-folder"></i> {{ verdict.release.project.name }}-{{ verdict.release.version }} </a> | ||
{% else %} | ||
<a href="{{ request.route_path('admin.project.release', project_name=verdict.release_file.release.project.normalized_name, version=verdict.release_file.release.version) }}"><i class="far fa-file"></i> {{ verdict.release_file.filename}} </a> | ||
{% endif %} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.