Skip to content
This repository was archived by the owner on Sep 16, 2022. It is now read-only.
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
3 changes: 0 additions & 3 deletions backend/backend/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
from .celery import app as celery_app

__all__ = ('celery_app',)
22 changes: 0 additions & 22 deletions backend/backend/celery.py

This file was deleted.

15 changes: 0 additions & 15 deletions backend/backend/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import re

from netaddr import IPNetwork, AddrFormatError
from celery.schedules import crontab


def check_ip_range(ipr):
Expand Down Expand Up @@ -68,7 +67,6 @@ def check_ip_range(ipr):
'tagulous',
'device_registry.apps.DeviceRegistryConfig',
'profile_page.apps.ProfilePageConfig',
'monitoring.apps.MonitoringConfig',
'bootstrap4'
]

Expand Down Expand Up @@ -220,16 +218,3 @@ def check_ip_range(ipr):

# Retry to connect to DB (after receiving a connection error) within 60 seconds.
DB_RETRY_TO_CONNECT_SEC = 60

# Celery settings.
CELERY_BROKER_URL = 'amqp://%s:%s@%s:5672/%s' % (os.getenv('RABBIT_USER', 'user'),
os.getenv('RABBIT_PASSWORD', 'SuperSecurePassword'),
os.getenv('RABBIT_HOST', 'localhost'),
os.getenv('RABBIT_VHOST', 'wott-dash'))

CELERY_BEAT_SCHEDULE = {
'update_celery_pulse_timestamp': {
'task': 'monitoring.tasks.update_celery_pulse_timestamp',
'schedule': crontab() # Execute once a minute.
}
}
1 change: 0 additions & 1 deletion backend/backend/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,5 @@
url(r'^accounts/', include('registration.backends.simple.urls')),
path('user/', include('profile_page.urls')),
path('', include('device_registry.urls')),
path('monitoring/', include('monitoring.urls')),
url('', include('django_prometheus.urls'))
]
2 changes: 1 addition & 1 deletion backend/backend/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from .utils import ensure_connection_with_retries

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'backend.settings.base')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'backend.settings')

# Patch the standard django database connection class' method in order to try to
# connect to DB multiple times using exponential backoff algorithm until success
Expand Down
7 changes: 0 additions & 7 deletions backend/device_registry/tasks.py

This file was deleted.

17 changes: 9 additions & 8 deletions backend/device_registry/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
from django.db.models import Q
from django.utils import timezone

from tagulous.forms import TagWidget

from device_registry.forms import ClaimDeviceForm, DeviceAttrsForm, PortsForm, ConnectionsForm, DeviceMetadataForm
from device_registry.models import Action, Device, average_trust_score, PortScan, FirewallState
from device_registry.models import PairingKey, get_bootstrap_color
Expand Down Expand Up @@ -112,7 +114,7 @@ def get_queryset(self):
number = 0
number = int(number)
if filter_predicate == 'eq':
interval_start = timezone.now() - datetime.timedelta(**{measure: number + 1})
interval_start = timezone.now() - datetime.timedelta(**{measure: number+1})
interval_end = timezone.now() - datetime.timedelta(**{measure: number})
filter_value = (interval_start, interval_end)
predicate = 'range'
Expand Down Expand Up @@ -154,8 +156,7 @@ def get_context_data(self, **kwargs):
'Trust Score',
'Comment'
],
'filter_params': [(field_name, field_desc[1], field_desc[2]) for field_name, field_desc in
self.FILTER_FIELDS.items()],
'filter_params': [(field_name, field_desc[1], field_desc[2]) for field_name, field_desc in self.FILTER_FIELDS.items()],

# TODO: convert this into a list of dicts for multiple filters
'filter': self.request.filter_dict
Expand Down Expand Up @@ -183,8 +184,8 @@ def claim_device_view(request):
get_device.owner = request.user
get_device.claim_token = ""
get_device.save(update_fields=['owner', 'claim_token'])
text, style = f'You\'ve successfully claimed {get_device.get_name()}. ' \
f'Learn more about the security state of the device by clicking ' \
text, style = f'You\'ve successfully claimed {get_device.get_name()}. '\
f'Learn more about the security state of the device by clicking '\
f'<a class="claim-link" href="{reverse("device-detail-security", kwargs={"pk": get_device.pk})}">' \
f'here</a>.', \
'success'
Expand All @@ -194,7 +195,7 @@ def claim_device_view(request):
# GET with claim_token and device_id set will fill the form.
# Empty GET or any other request will generate empty form.
if request.method == 'GET' and \
'claim_token' in request.GET and \
'claim_token' in request.GET and \
'device_id' in request.GET:
try:
Device.objects.get(
Expand Down Expand Up @@ -465,7 +466,7 @@ def actions_view(request, device_pk=None):
if insecure_password_devices.exists():
text_blocks = []
for dev in insecure_password_devices:
device_text_block = f'<a href="{reverse("device-detail", kwargs={"pk": dev.pk})}">{dev.get_name()}</a>'
device_text_block = f'<a href="{ reverse("device-detail", kwargs={"pk": dev.pk}) }">{ dev.get_name() }</a>'
text_blocks.append(device_text_block)
full_string = ', '.join(text_blocks)
action = Action(
Expand All @@ -483,7 +484,7 @@ def actions_view(request, device_pk=None):
if disabled_firewall_devices.exists():
text_blocks = []
for dev in disabled_firewall_devices:
device_text_block = f'<a href="{reverse("device-detail", kwargs={"pk": dev.pk})}">{dev.get_name()}</a>'
device_text_block = f'<a href="{ reverse("device-detail", kwargs={"pk": dev.pk}) }">{ dev.get_name() }</a>'
text_blocks.append(device_text_block)
full_string = ', '.join(text_blocks)
action = Action(
Expand Down
Empty file removed backend/monitoring/__init__.py
Empty file.
3 changes: 0 additions & 3 deletions backend/monitoring/admin.py

This file was deleted.

5 changes: 0 additions & 5 deletions backend/monitoring/apps.py

This file was deleted.

21 changes: 0 additions & 21 deletions backend/monitoring/migrations/0001_initial.py

This file was deleted.

Empty file.
5 changes: 0 additions & 5 deletions backend/monitoring/models.py

This file was deleted.

12 changes: 0 additions & 12 deletions backend/monitoring/tasks.py

This file was deleted.

7 changes: 0 additions & 7 deletions backend/monitoring/urls.py

This file was deleted.

21 changes: 0 additions & 21 deletions backend/monitoring/views.py

This file was deleted.

100 changes: 27 additions & 73 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,42 @@ services:
migrate:
command: python manage.py migrate --noinput
environment:
- DJANGO_SETTINGS_MODULE=backend.settings.dev
- DB_PASSWORD=SuperSecurePassword
- DB_USER=postgres
- DJANGO_SETTINGS_MODULE=backend.settings.dev
- DB_PASSWORD=SuperSecurePassword
- DB_USER=postgres
build:
context: .
volumes:
- ./backend:/usr/src/app
depends_on:
- psql
- psql
- nginx-static

dash-dev:
hostname: dash-dev0
environment:
- DJANGO_SETTINGS_MODULE=backend.settings.dev
- DB_PASSWORD=SuperSecurePassword
- DB_USER=postgres
- DATASTORE_KEY_JSON
- DJANGO_SETTINGS_MODULE=backend.settings.dev
- DB_PASSWORD=SuperSecurePassword
- DB_USER=postgres
- DATASTORE_KEY_JSON
build:
context: .
volumes:
- ./backend:/usr/src/app
ports:
- '8000:8000'
depends_on:
- psql
- migrate
- nginx-static
- psql
- migrate
- nginx-static

api-dev:
hostname: api-dev0
environment:
- DJANGO_SETTINGS_MODULE=backend.settings.dev
- DB_PASSWORD=SuperSecurePassword
- DB_USER=postgres
- DATASTORE_KEY_JSON
- DJANGO_SETTINGS_MODULE=backend.settings.dev
- DB_PASSWORD=SuperSecurePassword
- DB_USER=postgres
- DATASTORE_KEY_JSON
image: api:latest
build:
context: .
Expand All @@ -46,25 +47,25 @@ services:
ports:
- '8001:8000'
depends_on:
- psql
- migrate
- psql
- migrate

mtls-api-dev:
hostname: mtls-api-dev0
environment:
- DJANGO_SETTINGS_MODULE=backend.settings.dev
- DB_PASSWORD=SuperSecurePassword
- DB_USER=postgres
- DATASTORE_KEY_JSON
- DJANGO_SETTINGS_MODULE=backend.settings.dev
- DB_PASSWORD=SuperSecurePassword
- DB_USER=postgres
- DATASTORE_KEY_JSON
build:
context: .
volumes:
- ./backend:/usr/src/app
ports:
- '8002:8000'
depends_on:
- psql
- migrate
- psql
- migrate

nginx-static:
hostname: wott-static
Expand All @@ -79,58 +80,11 @@ services:

psql:
environment:
- POSTGRES_DB=wott-backend
- POSTGRES_PASSWORD=SuperSecurePassword
- POSTGRES_DB=wott-backend
- POSTGRES_PASSWORD=SuperSecurePassword
image: postgres:alpine
volumes:
- db-data:/var/lib/postgresql/data

rabbit:
image: rabbitmq:3-alpine
environment:
- RABBITMQ_DEFAULT_USER=user
- RABBITMQ_DEFAULT_PASS=SuperSecurePassword
- RABBITMQ_DEFAULT_VHOST=wott-dash
ports:
- '5672:5672'

celery:
environment:
- DJANGO_SETTINGS_MODULE=backend.settings.dev
- DB_PASSWORD=SuperSecurePassword
- DB_USER=postgres
- RABBIT_HOST=rabbit
- RABBIT_USER=user
- RABBIT_PASSWORD=SuperSecurePassword
- RABBIT_VHOST=wott-dash
build:
context: .
command: celery -A backend worker -l error --time-limit=90 --soft-time-limit=60
volumes:
- ./backend:/usr/src/app
depends_on:
- psql
- migrate
- rabbit

celery-beat:
environment:
- DJANGO_SETTINGS_MODULE=backend.settings.dev
- DB_PASSWORD=SuperSecurePassword
- DB_USER=postgres
- RABBIT_HOST=rabbit
- RABBIT_USER=user
- RABBIT_PASSWORD=SuperSecurePassword
- RABBIT_VHOST=wott-dash
build:
context: .
command: celery -A backend beat -l error
volumes:
- ./backend:/usr/src/app
depends_on:
- psql
- migrate
- rabbit
- db-data:/var/lib/postgresql/data

volumes:
db-data:
Expand Down
Loading