Skip to content

Commit

Permalink
Merge pull request #51 from UKB-IT-Sec/48-show-vlan-blacklist-for-arm…
Browse files Browse the repository at this point in the history
…is-import-if-configured

add vlan blacklist as infobox if configured
  • Loading branch information
weidenba authored Jan 11, 2025
2 parents c1ddbc7 + 8fd9e93 commit 05fa620
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 9 deletions.
3 changes: 3 additions & 0 deletions src/helper/armis.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ def _remove_existing_devices(deviceList):
_mac_list = MacList()
return [device for device in deviceList if not _mac_list.check_existing_mac(device)[0]]

def get_vlan_blacklist():
return armis_config['armis-server'].get('vlan_blacklist', '').strip() or None

# flake8: noqa: E231
@armiscloud
def get_devices(acloud, sites):
Expand Down
3 changes: 2 additions & 1 deletion src/nac/subviews/armis.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from django.contrib.auth.mixins import LoginRequiredMixin


from helper.armis import get_armis_sites, get_devices, get_tenant_url, get_boundaries, map_ids_to_names
from helper.armis import get_armis_sites, get_devices, get_tenant_url, get_boundaries, map_ids_to_names, get_vlan_blacklist


class ArmisView(LoginRequiredMixin, View):
Expand All @@ -33,6 +33,7 @@ def _get_context(self): # sets the site-context for armis_import.html, uses cac
cache.set('armis_sites', armis_sites, 3600)
context['armis_sites'] = armis_sites
context['tenant_url'] = get_tenant_url()
context['vlan_blacklist'] = get_vlan_blacklist()
return context

def get(self, request, *args, **kwargs): # rendering the html base with site-context
Expand Down
8 changes: 8 additions & 0 deletions src/static/default.css
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ td {
grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); /* displays checkbox in 100pt width columns, as many as possible based on window size*/
gap: 10px 20px;
padding: 10px;
flex: 1;
margin-right: 20px;
}

.checkbox-item {
Expand All @@ -102,4 +104,10 @@ td {
width: 20px;
height: 20px;
cursor: pointer;
}

.split-content {
display: flex;
justify-content: space-between;
margin-bottom: 15px;
}
30 changes: 22 additions & 8 deletions src/templates/armis_import.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,34 @@
{% block content %}
<div class="container">
<h1>Armis Import</h1>
<p>
<button id="toggleSiteForm" class="btn btn-secondary btn-sm">
{% if display %}Hide Sites{% else %}Show Sites{% endif %}
</button>
<button class="btn btn-secondary btn-sm" type="button" data-bs-toggle="collapse" data-bs-target="#vlan_blacklist" aria-expanded="false" aria-controls="vlan_blacklist">
VLAN Blacklist
</button>
</p>
<div>
<div class="collapse" id="vlan_blacklist">
<div class="card card-body" style="background-color:rgb(190, 190, 190);">
<strong>{{vlan_blacklist}}</strong>
</div>
</div>
</div>
<div id="formContainer" style="display: {% if display %}block{% else %}none{% endif %}">
<form id="siteSubmitForm" method="POST" action="{% url 'armis_import' %}">
{% csrf_token %}
<div class="checkbox-container">
{% for site_id, site_info in armis_sites.items %}
<div class="checkbox-item">
<input type="checkbox" id="site-{{ site_id }}" name="site-ids[]" value="{{ site_id }}" class="custom-checkbox">
<label for="site-{{ site_id }}" class="checkbox-label">{{ site_info.name }}</label>
</div>
{% endfor %}
</div>
<div class="split-content">
<div class="checkbox-container">
{% for site_id, site_info in armis_sites.items %}
<div class="checkbox-item">
<input type="checkbox" id="site-{{ site_id }}" name="site-ids[]" value="{{ site_id }}" class="custom-checkbox">
<label for="site-{{ site_id }}" class="checkbox-label">{{ site_info.name }}</label>
</div>
{% endfor %}
</div>
</div>
<button type="submit" class="btn btn-secondary btn-sm">Select</button>
</form>
</div>
Expand Down

0 comments on commit 05fa620

Please sign in to comment.