aboutsummaryrefslogtreecommitdiffstats
path: root/lib/srtgui/templates/cve.html
blob: c3cfcac50a1f70f962a1a9762e2a9893f6c213fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
{% extends "base.html" %}

{% load projecttags %}

{% block title %} {{object.name}} - SRTool {% endblock %}

{% block pagecontent %}

<div class="row">
  <!-- Breadcrumbs -->
    <div class="col-md-12">
        <ul class="breadcrumb" id="breadcrumb">
            <li><a href="{% url 'landing' %}">Home</a></li><span class="divider">&rarr;</span>
            <li><a href="{% url 'cves' %}">CVE's</a></li><span class="divider">&rarr;</span>
            <li>{{object.name}}</li>
            <li><a class="btn btn-default navbar-btn " id="cve-prev" href="{% url 'cve' cve_prev %}">Prev</a></li>
            <li><a class="btn btn-default navbar-btn " id="cve-next" href="{% url 'cve' cve_next %}">Next</a></li>
        </ul>
    </div>
</div>

<!-- Begin container -->

{% if is_edit %}
<form method="POST">{% csrf_token %}
{% endif %}

<div class="row">
  <div class="col-md-12">
    <div class="page-header build-data">
		<span id="cve-name-container">
          <span id="cve-name" class="srt_h1">{{object.name}} {% if not object.public %} <font color="red">[PRIVATE]</font> {% endif %}</span>
		  {% if object.is_local and request.user.is_contributor %}<span class="glyphicon glyphicon-edit" id="cve-change-form-toggle"></span>{% endif %}
          {% if request.user.is_creator %}
              <span style="padding-left:30px;"><button id="select-quickedit" class="btn btn-default" type="button">Edit Status...</button></span>
              <span style="padding-left:30px;"><button id="select-notification" class="btn btn-default" type="button">Create Notification ...</button></span>
              {% if is_edit %}
                <input type="submit" id="submit-cve-update" class="btn btn-primary btn-lg" name="cve-edit" value="Save CVE data"/>
                <input type="submit" id="submit-cve-cancel" class="btn btn-primary btn-lg" name="cve-edit" value="Cancel Edit"/>
              {% else %}
                <span style="padding-left:30px;"><button id="select-cveedit" class="btn btn-default" type="button">Edit CVE Data ...</button></span>
              {% endif %}
              <span style="padding-left:30px;"><button id="submit-delete-cve" class="btn btn-default" type="button">Delete CVE</button></span>
          {% endif %}
		</span>
        {% if not is_edit %}
		<form id="cve-name-change-form" class="form-inline" style="display: none;">
		  <div class="form-group">
			<input class="form-control input-lg" type="text" id="cve-name-change-input" autocomplete="off" value="{{object.name}}">
		  </div>
		  <button id="cve-name-change-btn" class="btn btn-default btn-lg" type="button">Save</button>
		  <a href="#" id="cve-name-change-cancel" class="btn btn-lg btn-link">Cancel</a>
		</form>
        {% endif %}
    </div>
  </div>
</div>

<!-- include SRtool Metadata/Notification -->
{% include "srtool_metadata_include.html" with default_category="CVE" default_url="cve" %}

<div class="row">
  <div class="col-md-12 tabbable">
    <ul class="nav nav-tabs">
        {% for details,state,id,cve_html in cve_list_table %}
        <li class="{{state}}">
            <a href="#{{id}}" data-toggle="tab">
                {{id}}
                <span class="glyphicon glyphicon-question-sign get-help" title="{{id}} CVE data"></span>
            </a>
        </li>
        {% endfor %}
    </ul>

    <div class="tab-content">
      {% for details,state,id,cve_html in cve_list_table %}
      <div class="tab-pane {{state}}" id="{{id}}">

      {% if 'Local' == id %}
          {% include 'cve-nist-local.html' %}
      {% elif 'Edit' == id %}
          {% include 'cve-edit-local.html' %}
      {% else %}
          {% include 'cve-nist.html' %}
      {% endif %}

      </div> <!-- end tab-pane -->
      {% endfor %}
    </div> <!-- end tab-content -->

  </div> <!-- end tabbable -->
</div> <!-- end row -->

{% if is_edit %}
</form>{% csrf_token %}
{% endif %}

<div class="row" style="padding-left: 25px;">
    <h3>History</h3>

    <table class="table table-striped table-condensed" data-testid="vuln-hyperlinks-table">
        <thead>
            <tr>
                <th>Comment</th>
                <th>Date</th>
                <th>Author</th>
            </tr>
        </thead>

        {% if object.cve_history.all %}
          {% for c in object.cve_history.all %}
            <tr>
                <td>{{ c.comment }}</td>
                <td>{{ c.date }}</td>
                <td>{{ c.author }}</td>
            </tr>
          {% endfor %}
        {% else %}
            <tr>
                <td>No history found</td>
            </tr>
        {% endif %}
    </table>
</div>

<HR ALIGN="center" WIDTH="100%">
Created={{object.srt_created}} Updated={{object.srt_updated}}

<script>
    var selected_quickedit=false;
    var selected_notifyedit=false;

	/* CVE Name change support */
	var cveNameForm = $("#cve-name-change-form");
	var cveNameContainer = $("#cve-name-container");
	var cveName = $(".cve-name");
	var cveNameFormToggle = $("#cve-change-form-toggle");
	var cveNameChangeCancel = $("#cve-name-change-cancel");

    $(document).ready(function() {
        function onCommitAjaxSuccess(data, textstatus) {
            if (window.console && window.console.log) {
                console.log("XHR returned:", data, "(" + textstatus + ")");
            } else {
                alert("NO CONSOLE:\n");
                return;
            }
            if (data.error != "ok") {
                alert("error on request:\n" + data.error);
                return;
            }

            // reload the page with the updated tables
            if (('new_name' in data) && (0 == data.new_name.indexOf("url:"))) {
                window.location.replace(data.new_name.replace("url:",""));
            } else if (('new_name' in data) && ("" != data.new_name)) {
                var new_url = "{% url 'cve' object.name %}".replace("{{object.name}}",data.new_name);
                window.location.replace(new_url);
            } else {
                location.reload(true);
            }
        }

        function onCommitAjaxError(jqXHR, textstatus, error) {
            console.log("ERROR:"+error+"|"+textstatus);
            alert("XHR errored1:\n" + error + "\n(" + textstatus + ")");
        }

        /* ensure cookie exists {% csrf_token %} */
        function postCommitAjaxRequest(reqdata) {
        reqdata['cve_id'] = {{ object.id }};
        var ajax = $.ajax({
                type:"POST",
                data: reqdata,
                url:"{% url 'xhr_cve_commit' %}",
                headers: { 'X-CSRFToken': $.cookie("csrftoken")},
                success: onCommitAjaxSuccess,
                error: onCommitAjaxError,
            })
        }

        $('#select-quickedit').click(function(){
            if (selected_quickedit) {
                selected_quickedit=false;
                $("#details-quickedit").slideUp();
				$("#display-status").slideDown();
                document.getElementById("select-quickedit").innerText = "Edit status...";
                $("#select-quickedit").removeClass("blueborder");
            } else {
                selected_quickedit=true;
				$("#display-status").slideUp();
                $("#details-quickedit").slideDown();
                document.getElementById("select-quickedit").innerText = "Close edit status...";
                $("#select-quickedit").addClass("blueborder");
                document.getElementById("select-status-state").focus();
            }
        });

        $('#select-cveedit').click(function(){
        	window.location.replace("{% url 'cve_edit' object.name %}");
        });

        $('#submit-quickedit').click(function(){
            var note=$('#text-note').val().trim();
            var private_note=$('#text-private-note').val().trim();
            var tags=$('#text-tags').val().trim();
            var priority=$('#select-priority-state').val();
            var status=$('#select-status-state').val();
            var publish_state=$('#select-publish-state').val();
            var publish_date=$('#select-publish-date').val();
            var acknowledge_date=$('#text-acknowledge-date').val();
            var affected_components=$('#text-affected-components').val();
            postCommitAjaxRequest({
                "action"        : 'submit-quickedit',
                "priority"      : priority,
                "status"        : status,
                "note"          : note,
                "private_note"  : private_note,
                "tags"          : tags,
                "publish_state" : publish_state,
                "publish_date"  : publish_date,
                "acknowledge_date"  : acknowledge_date,
                "affected_components" : affected_components
                });
        });

        $('#select-notification').click(function(){
            if (selected_notifyedit) {
                selected_notifyedit=false;
                $("#details-notify-edit").slideUp();
				$("#display-status").slideDown();
                document.getElementById("select-notification").innerText = "Create Notification ...";
                $("#select-notification").removeClass("blueborder");
            } else {
                selected_notifyedit=true;
				$("#display-status").slideUp();
                $("#details-notify-edit").slideDown();
                document.getElementById("select-notification").innerText = "Close notification";
                $("#select-notification").addClass("blueborder");
                document.getElementById("select-category-notify").focus();
            }
        });

        $('#submit-notification').click(function(){
            var category=$('#select-category-notify').val();
            var priority=$('#select-priority-notify').val();
            var note=$('#notification-note').val().trim();
            var url=$('#notification-url').val().trim();
			var user_list=[];
			$('input[name="notification-users"]').each(function(){
				if ($(this).is(':checked')) {
					user_list.push($(this).prop('value'));
				}
			});
            user_list = user_list.join(",");
			if ("" == user_list) {
				alert("No users were selected");
				return;
			}
            postCommitAjaxRequest({
                "action"        : 'submit-notification',
                "category"      : category,
                "priority"      : priority,
                "note"          : note,
                "url"           : url,
                "users"         : user_list,
                });
        });

		/* CVE name change functionality */
		cveNameFormToggle.click(function(e){
		  e.preventDefault();
		  cveNameContainer.hide();
		  cveNameForm.fadeIn();
		});

		cveNameChangeCancel.click(function(e){
		  e.preventDefault();
		  cveNameForm.hide();
		  cveNameContainer.fadeIn();
		});

		$("#cve-name-change-btn").click(function(){
		  var newcveName = $("#cve-name-change-input").val();
          postCommitAjaxRequest({
              "action"        : 'submit-newname',
              "old_name"      : '{{object.name}}',
              "new_name"      : newcveName,
              });
		});

		$("#submit-create-vulnerability").click(function(){
          postCommitAjaxRequest({
              "action"        : 'submit-create-vulnerability',
              });
		});

		$("#submit-attach-vulnerability").click(function(){
          postCommitAjaxRequest({
              "action"        : 'submit-attach-vulnerability',
              "vul_name"      : $("#vulnerability_name").val(),
              });
		});

		$("#submit-delete-cve").click(function(){
		  var result = confirm("Are you sure you want to permamently delete '{{object.name}}' and all its related records?");
		  if (result){
            postCommitAjaxRequest({
              "action"        : 'submit-delete-cve'
              });
            }
		});



        /* Set the report link */
        $('#report_link').attr('href',"{% url 'report' request.resolver_match.url_name %}?record_list={{object.id}}");
        $('#alternate_cve_link').attr('href',"{% url 'cve_alternates' object.id %}");
    });
</script>
{% endblock %}