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

Replace "Comment" with "Recommended Actions" #472

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 6 additions & 5 deletions backend/device_registry/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,12 @@ def hostname(self):

@property
def actions_count(self):
return sum((self.deviceinfo.default_password is True,
self.firewallstate.policy != FirewallState.POLICY_ENABLED_BLOCK,
bool(self.vulnerable_packages and self.vulnerable_packages.exists()),
bool(self.insecure_services),
bool(self.sshd_issues())))
if hasattr(self, 'firewallstate') and hasattr(self, 'portscan'):
return sum((self.deviceinfo.default_password is True,
self.firewallstate.policy != FirewallState.POLICY_ENABLED_BLOCK,
bool(self.vulnerable_packages and self.vulnerable_packages.exists()),
bool(self.insecure_services),
bool(self.sshd_issues())))

COEFFICIENTS = {
'app_armor_enabled': .5,
Expand Down
5 changes: 5 additions & 0 deletions backend/device_registry/serializers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.utils.translation import ugettext_lazy as _
from django.utils.timesince import timesince
from django.urls import reverse

from rest_framework import serializers
from rest_framework.utils.representation import smart_repr
Expand Down Expand Up @@ -222,4 +223,8 @@ class Meta:
def to_representation(self, instance):
representation = super(DeviceListSerializer, self).to_representation(instance)
representation['last_ping'] = timesince(instance.last_ping) + ' ago'
representation['actions'] = {
'count': instance.actions_count or '',
'url': reverse('device_actions', args=[instance.pk])
}
return representation
7 changes: 6 additions & 1 deletion backend/device_registry/templates/root.html
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ <h4 class="modal-title" id="modal-title"></h4>
{data: 'hostname' },
{data: 'last_ping', type: 'last-ping' , orderable: true, sortable:true,},
{data: 'trust_score', render: render_trustscore },
{data: 'comment' },
{data: 'actions', render: render_actions_count }
],
select: {
style: 'os multi+shift',
Expand Down Expand Up @@ -648,6 +648,11 @@ <h4 class="modal-title" id="modal-title"></h4>
}
$('.toast').toast({delay: 5000});

function render_actions_count(data, type, row, meta) {
if (type == 'sort') return data;
return data? `<a class="badge badge-pill badge-primary" href="${data.url}"}>${data.count}</span>`: "";
}

{% if not user.profile.wizard_shown %}
$(() => {
let sidebarToggled = false;
Expand Down
2 changes: 1 addition & 1 deletion backend/device_registry/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def get_context_data(self, **kwargs):
'Hostname',
'Last Ping',
'Trust Score',
'Comment'
'Recommended Actions'
],
'filter_params': [(field_name, field_desc[1], field_desc[2]) for field_name, field_desc in
self.FILTER_FIELDS.items()],
Expand Down