aboutsummaryrefslogtreecommitdiffstats
path: root/lib/srtgui/templates/publish.html
blob: cf0f2294cfcddb02b4ea54e6cc9bce76face7d85 (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
322
323
324
325
326
327
{% extends "base.html" %}

{% load static %}
{% load projecttags %}
{% load humanize %}

{% block title %} Publish Requests {% 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 'manage' %}">Management</a></li><span class="divider">&rarr;</span>
			<li>Publish Report Management</li>
		</ul>
	</div>
</div>

<h2>Publish Report Management</h2>
<ul>
	<li>The SRTool supports exporting new and updated CVEs to external publishing tools</li>
</ul>

<hr>

<h2>Publish Via Database Snapshots</h2>
<h3> On Demand</h3>
<ul>
	<li>This extracts the changes from a 'base' database backup snapshot to more recent 'top' snapshot</li>
	<li>The 'start' and 'stop' dates can extract a subset of those changes. Normally they are set to the 'base' and 'top' dates</li>
</ul>

<div style="padding-left:30px;">
  <div>
	<label> Start Snapshot: </label>
	<select id="snap_date_base">
	{% for snap in snapshot_list %}
	  <option value="{{snap.date}}" {% if snap_start_index == snap.index %}selected{% endif %}>
		({{snap.mode}}) {{snap.date}} {{snap.time}} | {{snap.day}}
	  </option>
	{% endfor %}
	</select>
  </div>
  <div>
	<label> Stop Snapshot: </label>
	<select id="snap_date_top">
	{% for snap in snapshot_list %}
	  <option value="{{snap.date}}" {% if snap_stop_index == snap.index %}selected{% endif %}>
		({{snap.mode}}) {{snap.date}} {{snap.time}} | {{snap.day}}
	  </option>
	{% endfor %}
	</select>
  </div>
  <div>
	Start Date: <input type="text" id="snap_date_start" value="{{snap_date_start}}">&nbsp;&nbsp;
	Stop Date: <input type="text" id="snap_date_stop" value="{{snap_date_stop}}">&nbsp;&nbsp;
	<I>(Format: yyyy-mm-dd)</I>
  </div>
<br>
</div>

<div>
	<span style="padding-left:30px;"><button id="export-snapshot" class="btn btn-default" type="button">Generate</button></span>
	<!--<button type="submit" name="action" value="export-snapshot">Export</button> -->
	<span id="export-snapshot-text">Generate the publish table on-demand (using snapshots)</span>
	<span id="generating-report" hidden style="color:red"><I>... Generating the report - this will take a few minutes ...</I></span>
</div>
<br>

<form method="POST"> {% csrf_token %}
<h3>Automatic (Under Development)</h3>
<div style="padding-left: 25px;">
	<label> Frequency: </label>
	<select id="snap_frequency">
	{% for snap in snapshot_frequency_list %}
	  <option value="{{snap}}" {% if snap == snap_frequency_select %}selected{% endif %}>
		{{snap}}
	  </option>
	{% endfor %}
	</select>
	<span style="padding-left:30px;"><button id="export-snapshot" class="btn btn-default" type="button" disabled>Save</button></span>
	<!--<button type="submit" name="action" value="export-snapshot">Export</button> -->
	Save the automatic publishing frequency
</div>
</form>

<h3>Generated Reports</h3>
<div style="padding-left: 25px;">
	<table class="table table-striped table-condensed" data-testid="vuln-hyperlinks-table">
		<thead>
			<tr>
				<th>Name</th>
				<th>Size</th>
				<th>Date</th>
				<th>Manage</th>
			</tr>
		</thead>
		{% if generated_report_list %}
		  {% for report in generated_report_list %}
		  <tr>
			<td>{{report.name}}</td>
			<td>{{report.size}}</td>
			<td>{{report.date}}</td>
			<td>
				<span id="attachment_entry_'+{{report.name}}+'" class="js-config-var-name"></span>
				<form id="downloadbanner-{{forloop.counter}}" enctype="multipart/form-data" method="post" >{% csrf_token %}
					<input type="hidden" id="action" name="action" value="download">
					<input type="hidden" id="report_id" name="report_name" value={{report.name}}>
					<span class="glyphicon glyphicon-download-alt submit-downloadreport" id="report_download_'+{{report.name}}+'" x-data="{{forloop.counter}}"></span>
					{% if request.user.is_creator %}
						<span class="glyphicon glyphicon-trash trash-report" id="report_trash_'+{{report.name}}+'" x-data="{{report.name}}"></span>
					{% endif %}
				</form>
			</td>
		  </tr>
		  {% endfor %}
		{% else %}
			<tr>
				<td>No report files found</td>
			</tr>
		{% endif %}
	</table>
	(last report = {{snap_last_calc}})
</div>

<hr>

<form method="POST"> {% csrf_token %}
<h2>Publish Via History Tables (Under development)</h2>
<ul>
	<li>These tools can be used to (a) gather the candidate CVEs, (b) review and edit the list if needed, (c) generate the report when ready</li>
	<li>The user can explicitly include and exclude CVEs from the "New" list and the "Updated" list, in case the automatic caltulations need adjustment</li>
	<li>These mark-ups are inserted into the respective CVE's history at a mid-point date of the period, so they are both persistent and period-specific</li>
	<li>The user can clear the markups from the given period and start over, but this will not affect any other period</li>
</ul>
<h3> Publish Preparation</h3>
<ul>
    <div>
	Start Date: <input type="text" name="date_start" value="{{date_start}}">&nbsp;&nbsp;
	Stop Date: <input type="text" name="date_stop" value="{{date_stop}}">
    </div>
    <br>
    <div>
    Product filter:
    <select name="product-filter" id="select-product-filter">
    <option value="0">WR Linux Suported Products</option>
    </select>
    </div>
    <br>
	<div>
    	<button type="submit" name="action" value="recalculate">Recalculate publish table</button>
		Gather the items for this period to be published from SRTool, with user changes (last done {{last_calc}})
	</div>
    <br>
	<div>
    	<button type="submit" name="action" value="reset">Reset user edits, Recalculate</button>
		Remove the user changes for this period, recalculate the table
	</div>
</ul>
<h3> Publish Preview and Modifications</h3>
<ul>
	<div>
    	<button type="submit" name="action" value="view">View the publish table</button>
		View the publish table, prune entries
	</div>
    <br>
	<div>
    	<button type="submit" name="action" value="add-cve">Add via CVEs</button>
		Add recent CVEs to the table
	</div>
    <br>
	<div>
    	<button type="submit" name="action" value="add-defect">Add via defects</button>
		Add CVEs of recent defects to the table
	</div>
    <br>
</ul>
<h3> Publish the Report</h3>
<ul>
	<div>
    	<button type="submit" name="action" value="export">Export</button>
		Export the publish table (using history)
	</div>
    <br>
</ul>
</form>

<script>
	var selected_newcomment=false;

	$(document).ready(function() {

		function onCommitAjaxSuccess(data, textstatus) {
			document.getElementById("export-snapshot").disabled = false;
			/* document.getElementById("download-snapshot").disabled = false;*/
			document.getElementById("export-snapshot-text").innerText = "Generate the publish table on-demand (using snapshots)";
			document.getElementById("generating-report").style.display = "block";
			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
			location.reload(true);
		}

		function onCommitAjaxError(jqXHR, textstatus, error) {
			console.log("ERROR:"+error+"|"+textstatus);
			alert("XHR errored1:\n" + error + "\n(" + textstatus + ")");
			document.getElementById("export-snapshot").disabled = false;
			document.getElementById("export-snapshot-text").innerText = "Generate the publish table on-demand (using snapshots)";
			/* document.getElementById("download-snapshot").disabled = false; */
			document.getElementById("generating-report").style.display = "block";
		}

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

		$("#snap_date_base").change(function(){
			snap_date_base = $("#snap_date_base").val();
			snap_date_top = $("#snap_date_top").val();
			if (snap_date_base > snap_date_top) {
				$("#snap_date_base").val(snap_date_top);
				$("#snap_date_top").val(snap_date_base);
				$("#snap_date_start").val(snap_date_top);
				$("#snap_date_stop").val(snap_date_base);
			} else {
				snap_date_start = $("#snap_date_start").val();
				snap_date_stop = $("#snap_date_stop").val();
				$("#snap_date_start").val(snap_date_base);
				if (snap_date_stop < snap_date_base) {
					$("#snap_date_stop").val(snap_date_top);
				}
			}
		});

		$("#snap_date_top").change(function(){
			snap_date_base = $("#snap_date_base").val();
			snap_date_top = $("#snap_date_top").val();
			if (snap_date_base > snap_date_top) {
				$("#snap_date_base").val(snap_date_top);
				$("#snap_date_top").val(snap_date_base);
				$("#snap_date_start").val(snap_date_top);
				$("#snap_date_stop").val(snap_date_base);
			} else {
				snap_date_start = $("#snap_date_start").val();
				snap_date_stop = $("#snap_date_stop").val();
				if (snap_date_start > snap_date_top) {
					$("#snap_date_start").val(snap_date_base);
				}
				$("#snap_date_stop").val(snap_date_top);
			}
		});

        $('#export-snapshot').click(function(){
			snap_date_base = $("#snap_date_base").val();
			snap_date_top = $("#snap_date_top").val();
			snap_date_start = $("#snap_date_start").val();
			snap_date_stop = $("#snap_date_stop").val();
			if (snap_date_start > snap_date_stop) {
				alert("Error: the start date is after the stop date");
				return;
			}
			if (snap_date_start < snap_date_base) {
				alert("Error: the start date is before the snapshot base date");
				return;
			}
			if (snap_date_stop > snap_date_top) {
				alert("Error: the stop date is after the snapshot top date");
				return;
			}
 			var result = confirm("Generate the report? This will take several minutes.");
			if (result){
		        document.getElementById("export-snapshot").disabled = true;
		        document.getElementById("export-snapshot-text").innerText = "... Generating the report - this will take a few minutes ...";

		        /* document.getElementById("download-snapshot").disabled = true; */
				document.getElementById("generating-report").style.display = "none";
				postCommitAjaxRequest({
					"action" : 'export-snapshot',
					"snap_date_base" : snap_date_base,
					"snap_date_top" : snap_date_top,
					"snap_date_start" : snap_date_start,
					"snap_date_stop" : snap_date_stop
				});
			}
        });


		/* Manage report files */

		$('.submit-downloadreport').click(function() {
			$("#downloadbanner-"+this.getAttribute("x-data")).submit();
		});

		$('.trash-report').click(function() {
			var result = confirm("Are you sure?");
			if (result){
				postCommitAjaxRequest({
					"action" : 'submit-trashreport',
					"report_name" : $(this).attr('x-data'),
				});
			}
		});



	});
</script>

{% endblock %}