File tree Expand file tree Collapse file tree 4 files changed +12
-0
lines changed Expand file tree Collapse file tree 4 files changed +12
-0
lines changed Original file line number Diff line number Diff line change 112
112
# Suricata binary
113
113
SURICATA_BINARY = "suricata"
114
114
115
+ SURICATA_NAME_IS_HOSTNAME = False
116
+
115
117
# Elastic search
116
118
117
119
USE_ELASTICSEARCH = True
Original file line number Diff line number Diff line change 19
19
"""
20
20
21
21
from django import forms
22
+ from django .conf import settings
22
23
from suricata .models import Suricata
23
24
from rules .models import Ruleset
24
25
from rules .forms import CommentForm
@@ -27,6 +28,8 @@ class SuricataForm(forms.ModelForm, CommentForm):
27
28
class Meta :
28
29
model = Suricata
29
30
exclude = ('created_date' , 'updated_date' )
31
+ if settings .SURICATA_NAME_IS_HOSTNAME :
32
+ exclude = exclude + ('name' , )
30
33
31
34
class SuricataUpdateForm (CommentForm ):
32
35
reload = forms .BooleanField (required = False )
Original file line number Diff line number Diff line change 21
21
from django .db import models
22
22
from django .core .exceptions import ValidationError
23
23
from django .utils import timezone
24
+ from django .conf import settings
24
25
25
26
# Create your models here.
26
27
import os
28
+ import socket
27
29
28
30
from rules .models import Ruleset
29
31
@@ -87,6 +89,8 @@ def get_absolute_url(self):
87
89
return reverse ('suricata_index' )
88
90
89
91
def get_probe_hostnames (limit = 10 ):
92
+ if settings .SURICATA_NAME_IS_HOSTNAME :
93
+ return [ socket .gethostname () ]
90
94
suricata = Suricata .objects .all ()
91
95
if suricata != None :
92
96
return [ suricata [0 ].name ]
Original file line number Diff line number Diff line change 19
19
"""
20
20
21
21
from time import time
22
+ import socket
22
23
23
24
from django .shortcuts import render , redirect
24
25
from django .db import IntegrityError
@@ -53,6 +54,8 @@ def get_suri():
53
54
def index (request , error = None ):
54
55
# try to get suricata from db
55
56
suri = get_suri ()
57
+ if settings .SURICATA_NAME_IS_HOSTNAME :
58
+ suri .name = socket .gethostname ()
56
59
57
60
if suri :
58
61
context = {'suricata' : suri }
You can’t perform that action at this time.
0 commit comments