Skip to content

Commit cec4a2d

Browse files
committed
suricata: add SURICATA_NAME_IS_HOSTNAME option
If True, the name of the Suricata object will be equal to the hostname. This will prevent amount of bug reports of people that are using SELKS distribution. The option is False by default for backward compatibility.
1 parent 63e6df4 commit cec4a2d

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

scirius/settings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@
112112
# Suricata binary
113113
SURICATA_BINARY = "suricata"
114114

115+
SURICATA_NAME_IS_HOSTNAME = False
116+
115117
# Elastic search
116118

117119
USE_ELASTICSEARCH = True

suricata/forms.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"""
2020

2121
from django import forms
22+
from django.conf import settings
2223
from suricata.models import Suricata
2324
from rules.models import Ruleset
2425
from rules.forms import CommentForm
@@ -27,6 +28,8 @@ class SuricataForm(forms.ModelForm, CommentForm):
2728
class Meta:
2829
model = Suricata
2930
exclude = ('created_date', 'updated_date')
31+
if settings.SURICATA_NAME_IS_HOSTNAME:
32+
exclude = exclude + ('name', )
3033

3134
class SuricataUpdateForm(CommentForm):
3235
reload = forms.BooleanField(required=False)

suricata/models.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@
2121
from django.db import models
2222
from django.core.exceptions import ValidationError
2323
from django.utils import timezone
24+
from django.conf import settings
2425

2526
# Create your models here.
2627
import os
28+
import socket
2729

2830
from rules.models import Ruleset
2931

@@ -87,6 +89,8 @@ def get_absolute_url(self):
8789
return reverse('suricata_index')
8890

8991
def get_probe_hostnames(limit = 10):
92+
if settings.SURICATA_NAME_IS_HOSTNAME:
93+
return [ socket.gethostname() ]
9094
suricata = Suricata.objects.all()
9195
if suricata != None:
9296
return [ suricata[0].name ]

suricata/views.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"""
2020

2121
from time import time
22+
import socket
2223

2324
from django.shortcuts import render, redirect
2425
from django.db import IntegrityError
@@ -53,6 +54,8 @@ def get_suri():
5354
def index(request, error = None):
5455
# try to get suricata from db
5556
suri = get_suri()
57+
if settings.SURICATA_NAME_IS_HOSTNAME:
58+
suri.name = socket.gethostname()
5659

5760
if suri:
5861
context = {'suricata': suri}

0 commit comments

Comments
 (0)