Skip to content
This repository has been archived by the owner on Sep 16, 2022. It is now read-only.

Commit

Permalink
Update Vulnerable Packages display logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
a-martynovich committed Oct 11, 2019
1 parent 0c2f5fd commit 37bd62c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
7 changes: 1 addition & 6 deletions backend/device_registry/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def hostname(self):
def actions_count(self):
return sum((self.deviceinfo.default_password is True,
self.firewallstate.policy != FirewallState.POLICY_ENABLED_BLOCK,
self.vulnerable_packages().exists(),
bool(self.vulnerable_packages and self.vulnerable_packages.exists()),
bool(self.insecure_services),
bool(self.sshd_issues())))

Expand Down Expand Up @@ -302,11 +302,6 @@ def vulnerable_packages(self):
if self.deb_packages.exists():
return self.deb_packages.filter(vulnerabilities__isnull=False).distinct().order_by('name')

def has_vulnerable_packages(self):
packages = self.vulnerable_packages
if packages is not None:
return packages.count()

class Meta:
ordering = ('created',)

Expand Down
10 changes: 5 additions & 5 deletions backend/device_registry/templates/device_info_security.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ <h4 class="tab-title">Security</h4>
<tr>
<th scope="row">Vulnerable Packages</th>
<td>
{% with object.has_vulnerable_packages as has_vulnerable_packages %}
{% if has_vulnerable_packages is None %}
{% with object.vulnerable_packages as vulnerable_packages %}
{% if vulnerable_packages is None %}
N/A
{% elif has_vulnerable_packages %}
{% elif vulnerable_packages.count %}
<ul>
{% for package in object.vulnerable_packages %}
{% for package in vulnerable_packages %}
<li>{{ package.name }} / {{ package.version }}
({% for v in package.vulnerabilities.all %}<a href="https://security-tracker.debian.org/tracker/{{ v.name }}"
target="_blank">{{ v.name }}</a>{% if not forloop.last %},&nbsp;&nbsp;{% endif %}{% endfor %})
target="_blank">{{ v.name }}</a>{% if not forloop.last %}, {% endif %}{% endfor %})
</li>
{% endfor %}
</ul>
Expand Down
3 changes: 0 additions & 3 deletions backend/device_registry/tests/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,9 +689,6 @@ def test_vulnerable_packages_render(self):
self.assertContains(response, 'CVE-123')





class PairingKeysView(TestCase):
def setUp(self):
User = get_user_model()
Expand Down

0 comments on commit 37bd62c

Please sign in to comment.