Skip to content

Commit aa22a60

Browse files
committed
rules: fix rule page when elasticsearch is disabled
Disables the Statistics tabs when suricata_stats or elasticsearch is undefined. Closes #448
1 parent 828dc3f commit aa22a60

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

rules/templates/rules/rule.html

100644100755
Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ <h2 class="panel-title">Events list</h2>
3434
</ul>
3535
</div>
3636

37-
{% endif %}
37+
{% endif %} {# kibana or evebox #}
3838
{% if request.user.is_staff %}
3939
<div class="panel-heading">
4040
<h2 class="panel-title">Action</h2>
@@ -61,7 +61,7 @@ <h2 class="panel-title">Action</h2>
6161
<span class="text-muted">Transform rule</span>
6262
{% endif %}
6363
</li>
64-
{% endif %}
64+
{% endif %} {# rule.state #}
6565
{% if not rule.state_in_source %}
6666
<li>
6767
<a href="{% url 'toggle_availability' rule.sid %}">Toggle availability</a>
@@ -74,7 +74,7 @@ <h2 class="panel-title">Action</h2>
7474
{% endif %}
7575
</ul>
7676
</div>
77-
{% endif %}
77+
{% endif %} {# user.is_staff #}
7878
{% endblock %}
7979

8080
{% block content %}
@@ -121,12 +121,11 @@ <h2 class="panel-title">Information</h2>
121121
</div>
122122
{% endif %}
123123
</div> <!-- panel -->
124-
{% endif %}
125124
</div> <!-- col -->
125+
{% endif %}
126126
</div> <!-- row -->
127127

128128

129-
{% if elasticsearch %}
130129

131130
<script>
132131
$(document).ready(function(){
@@ -142,15 +141,16 @@ <h2 class="panel-title">Information</h2>
142141

143142
<!-- Nav tabs -->
144143
<ul class="nav nav-tabs" role="tablist" id="ruleinfo">
145-
{% if suricata_stats %}
144+
{% if suricata_stats and elasticsearch %}
146145
<li role="presentation" class="active"><a href="#stats" aria-controls="stats" role="tab" data-toggle="tab">Statistics</a></li>
147146
{% endif %}
148147
<li role="presentation"><a href="#rule_status" aria-controls="rule_status" role="tab" data-toggle="tab">Information</a></li>
149148
<li role="presentation"><a href="#rule_comments" aria-controls="rule_comments" role="tab" data-toggle="tab">History</a></li>
150149
</ul>
151150

152151
<div class="tab-content">
153-
152+
153+
{% if suricata_stats and elasticsearch %}
154154
<div role="tabpanel" class="tab-pane fade in active" id="stats">
155155
<div class="container-fluid" >
156156
<div class="col-md-4">
@@ -251,7 +251,7 @@ <h2 class="title">Destination IP (last {{ date }})
251251
</div> <!-- container -->
252252
</div>
253253

254-
</div> <!-- row -->
254+
</div> <!-- container-fluid -->
255255
{% if probes %}
256256
<div class="row">
257257
<div class="col-md-12">
@@ -281,10 +281,11 @@ <h2 class="title">Activity (last {{ date }})
281281
</div> <!-- col -->
282282
</div> <!-- row -->
283283

284-
{% endif %}
285-
</div> <!-- container -->
284+
{% endif %} {# if probes #}
285+
</div> <!-- tabpanel -->
286+
{% endif %} {# suricata_stats and elasticsearch #}
286287

287-
<div role="tabpanel" class="tab-pane fade in" id="rule_status">
288+
<div role="tabpanel" class="tab-pane fade in{% if not suricata_stats and not elasticsearch %} active{% endif %}" id="rule_status">
288289
<div class="container-fluid">
289290

290291
<h2 class="title">Definition</h2>
@@ -302,9 +303,8 @@ <h3 class="title">{{ ruleset.name }}</h3>
302303
</div>
303304
{% endif %}
304305
{% endfor %}
305-
{% endif %}
306+
{% endif %} {# rule_transformation #}
306307

307-
{% endif %}
308308
<div class="row">
309309
<div id="validity_error" class="col-md-12" style="display:none;">
310310
<h2 class="title">Rulesets error</h2>
@@ -342,7 +342,7 @@ <h2 class="panel-title"><a href="{% url 'ruleset' ruleset.pk %}">{{ ruleset.name
342342
</div>
343343
{% endfor %}
344344
</div>
345-
</div>
345+
</div> <!-- container-fluid -->
346346

347347
</div> <!-- col -->
348348

@@ -365,8 +365,6 @@ <h2 class="title">Suppressions</h2>
365365
</div> <!-- col -->
366366
{% endif %}
367367

368-
369-
{% if elasticsearch %}
370368
</div>
371369
</div>
372370

@@ -422,11 +420,12 @@ <h3 class="title">Add comment</h3>
422420
</div> <!-- tabpanel -->
423421

424422
<script>
425-
423+
{% if suricata_stats and elasticsearch %}
426424
{% if probes %}
427425
$( 'document' ).ready(function () { draw_timeline({{ from_date }}, [{% autoescape off %} {{ probes|join:',' }} {% endautoescape %}], "alert.signature_id:{{ rule.sid }}" ); });
428426
{% endif %}
429427

428+
430429
function load_stats() {
431430
$.ajax({
432431
url: '{% url 'elasticsearch' %}?query=rule&sid={{ rule.pk }}&from_date={{ from_date }}',
@@ -497,12 +496,12 @@ <h3 class="title">Add comment</h3>
497496
}
498497

499498
$( 'document' ).ready(load_ip_stats());
500-
499+
{% endif %} {# suricata_stats and elasticsearch #}
501500
</script>
502-
{% endif %}
503501

504-
</div>
505502

503+
</div>
504+
</div> <!-- container-fluid -->
506505
<script>
507506
function rule_validity_check() {
508507
$("div.ruleset-status").each(

0 commit comments

Comments
 (0)